tubeless 0.2.11 → 0.2.12

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.
@@ -28,7 +28,7 @@ type ChildInputs = Record<string, unknown>;
28
28
  export interface SingleChildExecutionConfig<TParentOptions extends object> {
29
29
  pipeline: ChildPipeline;
30
30
  controls?: PipelineRunControls | ((inputs: ChildInputs, context: PipelineExecutionContext<TParentOptions>) => PipelineRunControls);
31
- mapOptions(inputs: ChildInputs, context: PipelineExecutionContext<TParentOptions>): object;
31
+ mapOptions?(inputs: ChildInputs, context: PipelineExecutionContext<TParentOptions>): object;
32
32
  mapResult?(value: unknown, result: PipelineRun<unknown>, context: PipelineStepContext<TParentOptions>): unknown;
33
33
  }
34
34
  export interface MappedChildExecutionConfig<TParentOptions extends object> {
@@ -139,7 +139,7 @@ function hasProgressObserver(context) {
139
139
  }
140
140
  export function createSingleChildRunner(config) {
141
141
  return async (inputs, context) => {
142
- const domainOptions = config.mapOptions(inputs, context);
142
+ const domainOptions = config.mapOptions ? config.mapOptions(inputs, context) : context.options;
143
143
  const configuredControls = typeof config.controls === "function" ? config.controls(inputs, context) : config.controls;
144
144
  const controls = childRunControls(configuredControls, context.dryRun);
145
145
  const baseChildContext = {
@@ -1 +1 @@
1
- {"version":3,"file":"child-execution.js","sourceRoot":"","sources":["../../src/core/child-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAEvF,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,oB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CAAC,MAAM,GAAG,CAAC;gBACjB,CAAC,CAAC,yBAAyB,MAAM,CAAC,QAAQ,CAAC,EAAE,eAAe,QAAQ,CAAC,MAAM,aAAa,OAAO,EAAE;gBACjG,CAAC,CAAC,yBAAyB,MAAM,CAAC,QAAQ,CAAC,EAAE,YAAY,YAAY,EAAE,OAAO,IAAI,SAAS,EAAE,CAAC;YAClG,MAAM,IAAI,kBAAkB,CAAC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE;gBAC7D,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;oBAC9D,KAAK;oBACL,GAAG;oBACH,KAAK;oBACL,SAAS,EAAE,sBAAsB,CAAC,KAAK,EAAE,OAAO,CAAC;iBAClD,CAAC,CAAC;gBACH,YAAY,EAAE,QAAQ,CAAC,MAAM;gBAC7B,cAAc,EAAE,gBAAgB;aACjC,CAAC,CAAC;QACL,CAAC;QACD,uEAAuE;QACvE,uEAAuE;QACvE,2EAA2E;QAC3E,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAE,OAA0C,CAAC,KAAK,CAAC,CAAC;IACtF,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { throwIfAborted } from \"../utilities/abort.js\";\nimport { emitRejectedPlanLifecycle } from \"./lifecycle.js\";\nimport { runConcurrentPartial } from \"../utilities/batch.js\";\nimport { isPipelineCancellation, PipelineExecutionError } from \"./pipeline-execute.js\";\nimport type { ToMappedChildStepProgressOptions } from \"./mapped-child-progress.js\";\nimport { createRunId, RUN_MODEL_VERSION } from \"./pipeline-ids.js\";\nimport { duplicateValues } from \"../utilities/collections.js\";\nimport { EXECUTE_COMPILED_RUN, isCompiledPipeline } from \"./pipeline-identity.js\";\nimport { createMappedChildProgress, createSingleChildProgress } from \"./child-progress.js\";\nimport type {\n Pipeline,\n PipelineContext,\n PipelineExecutionContext,\n PipelineHooks,\n PipelinePlan,\n PipelineRun,\n PipelineRunControls,\n PipelineRuntime,\n PipelineStepContext,\n} from \"./pipeline-types.js\";\nimport type { PipelineTracingOptions } from \"../tracing/tracing-contracts.js\";\n\nexport class PipelineChildError extends Error {\n constructor(\n message: string,\n readonly cancelled = false,\n cause?: unknown,\n readonly fanOut?: {\n failures: readonly { error: Error; key: string; index: number; cancelled: boolean }[];\n failureCount: number;\n schedulerError?: Error;\n }\n ) {\n super(message, cause === undefined ? undefined : { cause });\n this.name = \"PipelineChildError\";\n }\n}\n\ntype ChildPipeline = Pipeline<object, unknown, string, string>;\n\ntype CompiledChildExecute = (\n plan: PipelinePlan,\n options: object,\n controls: PipelineRunControls,\n context?: Partial<PipelineContext>\n) => Promise<PipelineRun<unknown>>;\n\ntype ExecutableChild = ChildPipeline & {\n [EXECUTE_COMPILED_RUN]?: CompiledChildExecute;\n};\n\nfunction compiledChildExecute(pipeline: ChildPipeline): CompiledChildExecute | undefined {\n if (!isCompiledPipeline(pipeline)) return undefined;\n // SAFETY: branded pipelines are the `definePipeline` object, which always\n // stamps `EXECUTE_COMPILED_RUN`. Wrappers that inherit the symbol are rejected\n // by the identity check above.\n return (pipeline as ExecutableChild)[EXECUTE_COMPILED_RUN];\n}\n\nfunction executeCompiledChild(\n pipeline: ChildPipeline,\n plan: PipelinePlan,\n domainOptions: object,\n controls: PipelineRunControls,\n context: PipelineContext\n): Promise<PipelineRun<unknown>> {\n const execute = compiledChildExecute(pipeline);\n if (execute === undefined) {\n return pipeline.run(domainOptions, controls, context);\n }\n return execute(plan, domainOptions, controls, context);\n}\n\nfunction publicChildRuntime(context: PipelineContext): PipelineRuntime {\n const runtime: PipelineRuntime = {\n cwd: context.cwd,\n log: context.log,\n now: context.now ?? Date.now,\n sleep: context.sleep ?? (async () => undefined),\n };\n if (context.correlationId !== undefined) runtime.correlationId = context.correlationId;\n if (context.hooks) runtime.hooks = context.hooks;\n if (context.parentRunId) runtime.parentRunId = context.parentRunId;\n if (context.signal) runtime.signal = context.signal;\n if (context.tracing) runtime.tracing = context.tracing;\n return runtime;\n}\n\nasync function failedPublicChildPlanRun(\n pipeline: ChildPipeline,\n plan: PipelinePlan,\n controls: PipelineRunControls,\n context: PipelineContext\n): Promise<PipelineRun<unknown>> {\n const runtime = publicChildRuntime(context);\n const startedAtMs = runtime.now();\n const result: PipelineRun<unknown> = {\n pipelineId: pipeline.id,\n dryRun: controls.dryRun === true,\n errors: [...plan.errors],\n finalized: false,\n finishedAtMs: runtime.now(),\n runId: createRunId(pipeline.id),\n startedAtMs,\n status: \"failed\",\n steps: [],\n version: RUN_MODEL_VERSION,\n };\n const correlationId = context.correlationId;\n if (correlationId !== undefined) result.correlationId = correlationId;\n if (context.parentRunId) result.parentRunId = context.parentRunId;\n await emitRejectedPlanLifecycle(pipeline.id, pipeline.targetIds, plan, runtime, result);\n return result;\n}\n\nasync function rejectedChildPlanResult(\n pipeline: ChildPipeline,\n plan: PipelinePlan,\n domainOptions: object,\n controls: PipelineRunControls,\n context: PipelineContext\n): Promise<PipelineRun<unknown>> {\n const execute = compiledChildExecute(pipeline);\n if (execute === undefined) {\n return failedPublicChildPlanRun(pipeline, plan, controls, context);\n }\n return execute(plan, domainOptions, controls, context);\n}\n\ntype ChildInputs = Record<string, unknown>;\n\nexport interface SingleChildExecutionConfig<TParentOptions extends object> {\n pipeline: ChildPipeline;\n controls?:\n | PipelineRunControls\n | ((\n inputs: ChildInputs,\n context: PipelineExecutionContext<TParentOptions>\n ) => PipelineRunControls);\n mapOptions(inputs: ChildInputs, context: PipelineExecutionContext<TParentOptions>): object;\n mapResult?(\n value: unknown,\n result: PipelineRun<unknown>,\n context: PipelineStepContext<TParentOptions>\n ): unknown;\n}\n\nexport interface MappedChildExecutionConfig<TParentOptions extends object> {\n pipeline: ChildPipeline;\n items(\n inputs: ChildInputs,\n context: PipelineExecutionContext<TParentOptions>\n ): readonly unknown[] | Promise<readonly unknown[]>;\n key(item: unknown, index: number): string;\n concurrency?:\n | number\n | ((inputs: ChildInputs, context: PipelineExecutionContext<TParentOptions>) => number);\n progress?: ToMappedChildStepProgressOptions;\n controls?:\n | PipelineRunControls\n | ((\n item: unknown,\n index: number,\n inputs: ChildInputs,\n context: PipelineExecutionContext<TParentOptions>\n ) => PipelineRunControls);\n mapOptions(\n item: unknown,\n index: number,\n inputs: ChildInputs,\n context: PipelineExecutionContext<TParentOptions>\n ): object;\n mapResult?(\n value: unknown,\n result: PipelineRun<unknown>,\n item: unknown,\n index: number,\n context: PipelineStepContext<TParentOptions>\n ): unknown;\n}\n\nfunction childTracingOptions(\n context: PipelineExecutionContext<object>,\n itemKey = context.trace?.itemKey\n): PipelineTracingOptions | undefined {\n return context.tracing ? { ...context.tracing, itemKey } : undefined;\n}\n\nfunction childRunControls(\n controls: PipelineRunControls | undefined,\n parentDryRun: boolean\n): PipelineRunControls {\n const resolved: PipelineRunControls = {};\n if (controls?.continueOnError !== undefined) {\n resolved.continueOnError = controls.continueOnError;\n }\n if (controls?.maxConcurrency !== undefined) {\n resolved.maxConcurrency = controls.maxConcurrency;\n }\n if (controls?.stepIds !== undefined) resolved.stepIds = [...controls.stepIds];\n if (controls?.targets !== undefined) resolved.targets = [...controls.targets];\n if (parentDryRun || controls?.dryRun === true) {\n resolved.dryRun = true;\n } else if (controls?.dryRun !== undefined) {\n resolved.dryRun = false;\n }\n return resolved;\n}\n\nfunction isConcurrencyFunction<TOptions extends object>(\n concurrency:\n | number\n | ((inputs: ChildInputs, context: PipelineExecutionContext<TOptions>) => number)\n | undefined\n): concurrency is (inputs: ChildInputs, context: PipelineExecutionContext<TOptions>) => number {\n return typeof concurrency === \"function\";\n}\n\nfunction firstChildFailure(result: PipelineRun<unknown>) {\n const firstFailedStep = result.steps.find(\n ({ status }) => status === \"failed\" || status === \"cancelled\"\n );\n const firstError =\n firstFailedStep && \"error\" in firstFailedStep ? firstFailedStep.error : result.errors[0];\n return {\n failureLocation: firstFailedStep?.id ?? firstError?.stepId ?? \"unknown step\",\n message: firstError?.message ?? \"unknown error\",\n };\n}\n\nasync function runChildPipeline(\n pipeline: ChildPipeline,\n domainOptions: object,\n controls: PipelineRunControls,\n context: PipelineContext,\n hooks: PipelineHooks,\n messagePrefix = \"\",\n plan: PipelinePlan\n): Promise<PipelineRun<unknown>> {\n if (!plan.ok) {\n const firstError = plan.errors[0];\n const result = await rejectedChildPlanResult(pipeline, plan, domainOptions, controls, {\n ...context,\n hooks,\n });\n throw new PipelineExecutionError(\n result,\n `${messagePrefix}could not start: ${firstError?.message ?? \"invalid plan\"}`\n );\n }\n\n const result = await executeCompiledChild(pipeline, plan, domainOptions, controls, {\n ...context,\n hooks,\n });\n if (result.status !== \"completed\") {\n const { failureLocation, message } = firstChildFailure(result);\n throw new PipelineExecutionError(\n result,\n `${messagePrefix}failed at ${failureLocation}: ${message}`\n );\n }\n return result;\n}\n\nfunction hasProgressObserver(context: PipelineContext): boolean {\n const hooks = Array.isArray(context.hooks) ? context.hooks : [context.hooks];\n return (\n Boolean(context.tracing) || hooks.some((hook) => hook?.onStepProgress || hook?.onStepStatus)\n );\n}\n\nexport function createSingleChildRunner<TParentOptions extends object>(\n config: SingleChildExecutionConfig<TParentOptions>\n): (inputs: ChildInputs, context: PipelineStepContext<TParentOptions>) => Promise<unknown> {\n return async (inputs, context) => {\n const domainOptions = config.mapOptions(inputs, context);\n const configuredControls =\n typeof config.controls === \"function\" ? config.controls(inputs, context) : config.controls;\n const controls = childRunControls(configuredControls, context.dryRun);\n const baseChildContext: PipelineContext = {\n correlationId: context.correlationId,\n cwd: context.cwd,\n log: context.log,\n now: context.now,\n parentRunId: context.runId,\n signal: context.signal,\n sleep: context.sleep,\n tracing: childTracingOptions(context),\n };\n // Plan once for progress totals and execution. Invalid plans fail before child.run.\n const childPlan = config.pipeline.plan(controls);\n const childHooks = hasProgressObserver(context)\n ? createSingleChildProgress(childPlan, context.reportProgress)\n : {};\n const childResult = await runChildPipeline(\n config.pipeline,\n domainOptions,\n controls,\n baseChildContext,\n childHooks,\n `Child pipeline ${config.pipeline.id} `,\n childPlan\n );\n\n return config.mapResult\n ? config.mapResult(childResult.value, childResult, context)\n : childResult.value;\n };\n}\n\nexport function createMappedChildRunner<TParentOptions extends object>(\n config: MappedChildExecutionConfig<TParentOptions>\n): (inputs: ChildInputs, context: PipelineStepContext<TParentOptions>) => Promise<unknown[]> {\n return async (inputs, context) => {\n const items = [...(await config.items(inputs, context))];\n const keys = items.map((item, index) => config.key(item, index));\n const duplicateKeys = duplicateValues(keys);\n if (duplicateKeys.length > 0) {\n throw new PipelineChildError(\n `Mapped child pipeline ${config.pipeline.id} received duplicate item keys: ${duplicateKeys.join(\", \")}`\n );\n }\n const concurrency = Math.max(\n 1,\n isConcurrencyFunction(config.concurrency)\n ? config.concurrency(inputs, context)\n : (config.concurrency ?? 1)\n );\n type Outcome =\n | { key: string; ok: true; value: unknown }\n | { error: Error; key: string; index: number; ok: false };\n\n const progress = hasProgressObserver(context)\n ? createMappedChildProgress(keys, concurrency, config.progress, context.reportProgress)\n : undefined;\n progress?.publish();\n if (items.length === 0) return [];\n\n const partial = await runConcurrentPartial(\n items,\n { concurrency, signal: context.signal },\n async (item, itemIndex): Promise<Outcome> => {\n const key = keys[itemIndex]!;\n progress?.start(key);\n try {\n throwIfAborted(context.signal, `Mapped child pipeline ${config.pipeline.id}`);\n const domainOptions = config.mapOptions(item, itemIndex, inputs, context);\n const configuredControls =\n typeof config.controls === \"function\"\n ? config.controls(item, itemIndex, inputs, context)\n : config.controls;\n const controls = childRunControls(configuredControls, context.dryRun);\n // Plan once per mapped-options bag for progress and execution.\n const childPlan = config.pipeline.plan(controls);\n const childHooks = progress?.plan(key, childPlan) ?? {};\n const childResult = await runChildPipeline(\n config.pipeline,\n domainOptions,\n controls,\n {\n correlationId: context.correlationId,\n cwd: context.cwd,\n log: context.log,\n now: context.now,\n parentRunId: context.runId,\n signal: context.signal,\n sleep: context.sleep,\n tracing: childTracingOptions(context, key),\n },\n childHooks,\n \"\",\n childPlan\n );\n\n progress?.childCompleted(key);\n\n const value = config.mapResult\n ? config.mapResult(childResult.value, childResult, item, itemIndex, context)\n : childResult.value;\n progress?.complete(key);\n return { key, ok: true, value };\n } catch (error) {\n const cause = error instanceof Error ? error : new Error(String(error));\n progress?.fail(key, cause, isPipelineCancellation(cause, context));\n return { error: cause, key, index: itemIndex, ok: false };\n }\n }\n );\n\n progress?.finish();\n const outcomes = partial.ok\n ? partial.results\n : partial.results.filter((outcome): outcome is Outcome => outcome !== undefined);\n const schedulerFailure = partial.ok\n ? undefined\n : partial.failure instanceof Error\n ? partial.failure\n : new Error(String(partial.failure));\n\n const failures = outcomes.filter(\n (outcome): outcome is Extract<Outcome, { ok: false }> => !outcome.ok\n );\n if (failures.length > 0 || schedulerFailure !== undefined) {\n const details = failures.map(({ error, key }) => `${key}: ${error.message}`).join(\"; \");\n const cancelled =\n failures.every(({ error }) => isPipelineCancellation(error, context)) &&\n (schedulerFailure === undefined || isPipelineCancellation(schedulerFailure, context));\n const primaryError = cancelled\n ? (failures[0]?.error ?? schedulerFailure)\n : (failures.find(({ error }) => !isPipelineCancellation(error, context))?.error ??\n failures[0]?.error ??\n schedulerFailure);\n const message =\n failures.length > 0\n ? `Mapped child pipeline ${config.pipeline.id} failed for ${failures.length} item(s): ${details}`\n : `Mapped child pipeline ${config.pipeline.id} failed: ${primaryError?.message ?? \"aborted\"}`;\n throw new PipelineChildError(message, cancelled, primaryError, {\n failures: failures.slice(0, 32).map(({ error, key, index }) => ({\n error,\n key,\n index,\n cancelled: isPipelineCancellation(error, context),\n })),\n failureCount: failures.length,\n schedulerError: schedulerFailure,\n });\n }\n // SAFETY: when failures.length === 0 every outcome was produced by the\n // success branch (return { key, ok: true, value }), so each outcome is\n // necessarily `{ ok: true }`; the assertion narrows the union accordingly.\n return outcomes.map((outcome) => (outcome as Extract<Outcome, { ok: true }>).value);\n };\n}\n"]}
1
+ {"version":3,"file":"child-exec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AAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAE,OAA0C,CAAC,KAAK,CAAC,CAAC;IACtF,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { throwIfAborted } from \"../utilities/abort.js\";\nimport { emitRejectedPlanLifecycle } from \"./lifecycle.js\";\nimport { runConcurrentPartial } from \"../utilities/batch.js\";\nimport { isPipelineCancellation, PipelineExecutionError } from \"./pipeline-execute.js\";\nimport type { ToMappedChildStepProgressOptions } from \"./mapped-child-progress.js\";\nimport { createRunId, RUN_MODEL_VERSION } from \"./pipeline-ids.js\";\nimport { duplicateValues } from \"../utilities/collections.js\";\nimport { EXECUTE_COMPILED_RUN, isCompiledPipeline } from \"./pipeline-identity.js\";\nimport { createMappedChildProgress, createSingleChildProgress } from \"./child-progress.js\";\nimport type {\n Pipeline,\n PipelineContext,\n PipelineExecutionContext,\n PipelineHooks,\n PipelinePlan,\n PipelineRun,\n PipelineRunControls,\n PipelineRuntime,\n PipelineStepContext,\n} from \"./pipeline-types.js\";\nimport type { PipelineTracingOptions } from \"../tracing/tracing-contracts.js\";\n\nexport class PipelineChildError extends Error {\n constructor(\n message: string,\n readonly cancelled = false,\n cause?: unknown,\n readonly fanOut?: {\n failures: readonly { error: Error; key: string; index: number; cancelled: boolean }[];\n failureCount: number;\n schedulerError?: Error;\n }\n ) {\n super(message, cause === undefined ? undefined : { cause });\n this.name = \"PipelineChildError\";\n }\n}\n\ntype ChildPipeline = Pipeline<object, unknown, string, string>;\n\ntype CompiledChildExecute = (\n plan: PipelinePlan,\n options: object,\n controls: PipelineRunControls,\n context?: Partial<PipelineContext>\n) => Promise<PipelineRun<unknown>>;\n\ntype ExecutableChild = ChildPipeline & {\n [EXECUTE_COMPILED_RUN]?: CompiledChildExecute;\n};\n\nfunction compiledChildExecute(pipeline: ChildPipeline): CompiledChildExecute | undefined {\n if (!isCompiledPipeline(pipeline)) return undefined;\n // SAFETY: branded pipelines are the `definePipeline` object, which always\n // stamps `EXECUTE_COMPILED_RUN`. Wrappers that inherit the symbol are rejected\n // by the identity check above.\n return (pipeline as ExecutableChild)[EXECUTE_COMPILED_RUN];\n}\n\nfunction executeCompiledChild(\n pipeline: ChildPipeline,\n plan: PipelinePlan,\n domainOptions: object,\n controls: PipelineRunControls,\n context: PipelineContext\n): Promise<PipelineRun<unknown>> {\n const execute = compiledChildExecute(pipeline);\n if (execute === undefined) {\n return pipeline.run(domainOptions, controls, context);\n }\n return execute(plan, domainOptions, controls, context);\n}\n\nfunction publicChildRuntime(context: PipelineContext): PipelineRuntime {\n const runtime: PipelineRuntime = {\n cwd: context.cwd,\n log: context.log,\n now: context.now ?? Date.now,\n sleep: context.sleep ?? (async () => undefined),\n };\n if (context.correlationId !== undefined) runtime.correlationId = context.correlationId;\n if (context.hooks) runtime.hooks = context.hooks;\n if (context.parentRunId) runtime.parentRunId = context.parentRunId;\n if (context.signal) runtime.signal = context.signal;\n if (context.tracing) runtime.tracing = context.tracing;\n return runtime;\n}\n\nasync function failedPublicChildPlanRun(\n pipeline: ChildPipeline,\n plan: PipelinePlan,\n controls: PipelineRunControls,\n context: PipelineContext\n): Promise<PipelineRun<unknown>> {\n const runtime = publicChildRuntime(context);\n const startedAtMs = runtime.now();\n const result: PipelineRun<unknown> = {\n pipelineId: pipeline.id,\n dryRun: controls.dryRun === true,\n errors: [...plan.errors],\n finalized: false,\n finishedAtMs: runtime.now(),\n runId: createRunId(pipeline.id),\n startedAtMs,\n status: \"failed\",\n steps: [],\n version: RUN_MODEL_VERSION,\n };\n const correlationId = context.correlationId;\n if (correlationId !== undefined) result.correlationId = correlationId;\n if (context.parentRunId) result.parentRunId = context.parentRunId;\n await emitRejectedPlanLifecycle(pipeline.id, pipeline.targetIds, plan, runtime, result);\n return result;\n}\n\nasync function rejectedChildPlanResult(\n pipeline: ChildPipeline,\n plan: PipelinePlan,\n domainOptions: object,\n controls: PipelineRunControls,\n context: PipelineContext\n): Promise<PipelineRun<unknown>> {\n const execute = compiledChildExecute(pipeline);\n if (execute === undefined) {\n return failedPublicChildPlanRun(pipeline, plan, controls, context);\n }\n return execute(plan, domainOptions, controls, context);\n}\n\ntype ChildInputs = Record<string, unknown>;\n\nexport interface SingleChildExecutionConfig<TParentOptions extends object> {\n pipeline: ChildPipeline;\n controls?:\n | PipelineRunControls\n | ((\n inputs: ChildInputs,\n context: PipelineExecutionContext<TParentOptions>\n ) => PipelineRunControls);\n mapOptions?(inputs: ChildInputs, context: PipelineExecutionContext<TParentOptions>): object;\n mapResult?(\n value: unknown,\n result: PipelineRun<unknown>,\n context: PipelineStepContext<TParentOptions>\n ): unknown;\n}\n\nexport interface MappedChildExecutionConfig<TParentOptions extends object> {\n pipeline: ChildPipeline;\n items(\n inputs: ChildInputs,\n context: PipelineExecutionContext<TParentOptions>\n ): readonly unknown[] | Promise<readonly unknown[]>;\n key(item: unknown, index: number): string;\n concurrency?:\n | number\n | ((inputs: ChildInputs, context: PipelineExecutionContext<TParentOptions>) => number);\n progress?: ToMappedChildStepProgressOptions;\n controls?:\n | PipelineRunControls\n | ((\n item: unknown,\n index: number,\n inputs: ChildInputs,\n context: PipelineExecutionContext<TParentOptions>\n ) => PipelineRunControls);\n mapOptions(\n item: unknown,\n index: number,\n inputs: ChildInputs,\n context: PipelineExecutionContext<TParentOptions>\n ): object;\n mapResult?(\n value: unknown,\n result: PipelineRun<unknown>,\n item: unknown,\n index: number,\n context: PipelineStepContext<TParentOptions>\n ): unknown;\n}\n\nfunction childTracingOptions(\n context: PipelineExecutionContext<object>,\n itemKey = context.trace?.itemKey\n): PipelineTracingOptions | undefined {\n return context.tracing ? { ...context.tracing, itemKey } : undefined;\n}\n\nfunction childRunControls(\n controls: PipelineRunControls | undefined,\n parentDryRun: boolean\n): PipelineRunControls {\n const resolved: PipelineRunControls = {};\n if (controls?.continueOnError !== undefined) {\n resolved.continueOnError = controls.continueOnError;\n }\n if (controls?.maxConcurrency !== undefined) {\n resolved.maxConcurrency = controls.maxConcurrency;\n }\n if (controls?.stepIds !== undefined) resolved.stepIds = [...controls.stepIds];\n if (controls?.targets !== undefined) resolved.targets = [...controls.targets];\n if (parentDryRun || controls?.dryRun === true) {\n resolved.dryRun = true;\n } else if (controls?.dryRun !== undefined) {\n resolved.dryRun = false;\n }\n return resolved;\n}\n\nfunction isConcurrencyFunction<TOptions extends object>(\n concurrency:\n | number\n | ((inputs: ChildInputs, context: PipelineExecutionContext<TOptions>) => number)\n | undefined\n): concurrency is (inputs: ChildInputs, context: PipelineExecutionContext<TOptions>) => number {\n return typeof concurrency === \"function\";\n}\n\nfunction firstChildFailure(result: PipelineRun<unknown>) {\n const firstFailedStep = result.steps.find(\n ({ status }) => status === \"failed\" || status === \"cancelled\"\n );\n const firstError =\n firstFailedStep && \"error\" in firstFailedStep ? firstFailedStep.error : result.errors[0];\n return {\n failureLocation: firstFailedStep?.id ?? firstError?.stepId ?? \"unknown step\",\n message: firstError?.message ?? \"unknown error\",\n };\n}\n\nasync function runChildPipeline(\n pipeline: ChildPipeline,\n domainOptions: object,\n controls: PipelineRunControls,\n context: PipelineContext,\n hooks: PipelineHooks,\n messagePrefix = \"\",\n plan: PipelinePlan\n): Promise<PipelineRun<unknown>> {\n if (!plan.ok) {\n const firstError = plan.errors[0];\n const result = await rejectedChildPlanResult(pipeline, plan, domainOptions, controls, {\n ...context,\n hooks,\n });\n throw new PipelineExecutionError(\n result,\n `${messagePrefix}could not start: ${firstError?.message ?? \"invalid plan\"}`\n );\n }\n\n const result = await executeCompiledChild(pipeline, plan, domainOptions, controls, {\n ...context,\n hooks,\n });\n if (result.status !== \"completed\") {\n const { failureLocation, message } = firstChildFailure(result);\n throw new PipelineExecutionError(\n result,\n `${messagePrefix}failed at ${failureLocation}: ${message}`\n );\n }\n return result;\n}\n\nfunction hasProgressObserver(context: PipelineContext): boolean {\n const hooks = Array.isArray(context.hooks) ? context.hooks : [context.hooks];\n return (\n Boolean(context.tracing) || hooks.some((hook) => hook?.onStepProgress || hook?.onStepStatus)\n );\n}\n\nexport function createSingleChildRunner<TParentOptions extends object>(\n config: SingleChildExecutionConfig<TParentOptions>\n): (inputs: ChildInputs, context: PipelineStepContext<TParentOptions>) => Promise<unknown> {\n return async (inputs, context) => {\n const domainOptions = config.mapOptions ? config.mapOptions(inputs, context) : context.options;\n const configuredControls =\n typeof config.controls === \"function\" ? config.controls(inputs, context) : config.controls;\n const controls = childRunControls(configuredControls, context.dryRun);\n const baseChildContext: PipelineContext = {\n correlationId: context.correlationId,\n cwd: context.cwd,\n log: context.log,\n now: context.now,\n parentRunId: context.runId,\n signal: context.signal,\n sleep: context.sleep,\n tracing: childTracingOptions(context),\n };\n // Plan once for progress totals and execution. Invalid plans fail before child.run.\n const childPlan = config.pipeline.plan(controls);\n const childHooks = hasProgressObserver(context)\n ? createSingleChildProgress(childPlan, context.reportProgress)\n : {};\n const childResult = await runChildPipeline(\n config.pipeline,\n domainOptions,\n controls,\n baseChildContext,\n childHooks,\n `Child pipeline ${config.pipeline.id} `,\n childPlan\n );\n\n return config.mapResult\n ? config.mapResult(childResult.value, childResult, context)\n : childResult.value;\n };\n}\n\nexport function createMappedChildRunner<TParentOptions extends object>(\n config: MappedChildExecutionConfig<TParentOptions>\n): (inputs: ChildInputs, context: PipelineStepContext<TParentOptions>) => Promise<unknown[]> {\n return async (inputs, context) => {\n const items = [...(await config.items(inputs, context))];\n const keys = items.map((item, index) => config.key(item, index));\n const duplicateKeys = duplicateValues(keys);\n if (duplicateKeys.length > 0) {\n throw new PipelineChildError(\n `Mapped child pipeline ${config.pipeline.id} received duplicate item keys: ${duplicateKeys.join(\", \")}`\n );\n }\n const concurrency = Math.max(\n 1,\n isConcurrencyFunction(config.concurrency)\n ? config.concurrency(inputs, context)\n : (config.concurrency ?? 1)\n );\n type Outcome =\n | { key: string; ok: true; value: unknown }\n | { error: Error; key: string; index: number; ok: false };\n\n const progress = hasProgressObserver(context)\n ? createMappedChildProgress(keys, concurrency, config.progress, context.reportProgress)\n : undefined;\n progress?.publish();\n if (items.length === 0) return [];\n\n const partial = await runConcurrentPartial(\n items,\n { concurrency, signal: context.signal },\n async (item, itemIndex): Promise<Outcome> => {\n const key = keys[itemIndex]!;\n progress?.start(key);\n try {\n throwIfAborted(context.signal, `Mapped child pipeline ${config.pipeline.id}`);\n const domainOptions = config.mapOptions(item, itemIndex, inputs, context);\n const configuredControls =\n typeof config.controls === \"function\"\n ? config.controls(item, itemIndex, inputs, context)\n : config.controls;\n const controls = childRunControls(configuredControls, context.dryRun);\n // Plan once per mapped-options bag for progress and execution.\n const childPlan = config.pipeline.plan(controls);\n const childHooks = progress?.plan(key, childPlan) ?? {};\n const childResult = await runChildPipeline(\n config.pipeline,\n domainOptions,\n controls,\n {\n correlationId: context.correlationId,\n cwd: context.cwd,\n log: context.log,\n now: context.now,\n parentRunId: context.runId,\n signal: context.signal,\n sleep: context.sleep,\n tracing: childTracingOptions(context, key),\n },\n childHooks,\n \"\",\n childPlan\n );\n\n progress?.childCompleted(key);\n\n const value = config.mapResult\n ? config.mapResult(childResult.value, childResult, item, itemIndex, context)\n : childResult.value;\n progress?.complete(key);\n return { key, ok: true, value };\n } catch (error) {\n const cause = error instanceof Error ? error : new Error(String(error));\n progress?.fail(key, cause, isPipelineCancellation(cause, context));\n return { error: cause, key, index: itemIndex, ok: false };\n }\n }\n );\n\n progress?.finish();\n const outcomes = partial.ok\n ? partial.results\n : partial.results.filter((outcome): outcome is Outcome => outcome !== undefined);\n const schedulerFailure = partial.ok\n ? undefined\n : partial.failure instanceof Error\n ? partial.failure\n : new Error(String(partial.failure));\n\n const failures = outcomes.filter(\n (outcome): outcome is Extract<Outcome, { ok: false }> => !outcome.ok\n );\n if (failures.length > 0 || schedulerFailure !== undefined) {\n const details = failures.map(({ error, key }) => `${key}: ${error.message}`).join(\"; \");\n const cancelled =\n failures.every(({ error }) => isPipelineCancellation(error, context)) &&\n (schedulerFailure === undefined || isPipelineCancellation(schedulerFailure, context));\n const primaryError = cancelled\n ? (failures[0]?.error ?? schedulerFailure)\n : (failures.find(({ error }) => !isPipelineCancellation(error, context))?.error ??\n failures[0]?.error ??\n schedulerFailure);\n const message =\n failures.length > 0\n ? `Mapped child pipeline ${config.pipeline.id} failed for ${failures.length} item(s): ${details}`\n : `Mapped child pipeline ${config.pipeline.id} failed: ${primaryError?.message ?? \"aborted\"}`;\n throw new PipelineChildError(message, cancelled, primaryError, {\n failures: failures.slice(0, 32).map(({ error, key, index }) => ({\n error,\n key,\n index,\n cancelled: isPipelineCancellation(error, context),\n })),\n failureCount: failures.length,\n schedulerError: schedulerFailure,\n });\n }\n // SAFETY: when failures.length === 0 every outcome was produced by the\n // success branch (return { key, ok: true, value }), so each outcome is\n // necessarily `{ ok: true }`; the assertion narrows the union accordingly.\n return outcomes.map((outcome) => (outcome as Extract<Outcome, { ok: true }>).value);\n };\n}\n"]}
@@ -79,8 +79,11 @@ type ChildPipelineStepDefinitionBase<TParentOptions extends object, TDeps extend
79
79
  description?: string;
80
80
  dryRun?: "skip";
81
81
  controls?: PipelineRunControlsOf<TChildPipeline> | ((inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>, context: PipelineExecutionContext<TParentOptions>) => PipelineRunControlsOf<TChildPipeline>);
82
+ } & ([TParentOptions] extends [PipelineOptionsOf<NoInfer<TChildPipeline>>] ? {
83
+ mapOptions?(inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>, context: PipelineExecutionContext<TParentOptions>): PipelineOptionsOf<TChildPipeline>;
84
+ } : {
82
85
  mapOptions(inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>, context: PipelineExecutionContext<TParentOptions>): PipelineOptionsOf<TChildPipeline>;
83
- };
86
+ });
84
87
  /** Child step without policy skip (dependents see the full child result type). */
85
88
  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>;
86
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AAG,IAAI,CAAC;QACzB,CAAC;QACD,OAAO,SAAS,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;IACnC,CAAC,CAAC;IAgHF,SAAS,eAAe,CACtB,EAAU,EACV,UAAyD;QAEzD,OAAO,uBAAuB,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,OAAO,GAAG;QACd,IAAI;QACJ,YAAY;QACZ,UAAU;QACV,eAAe;KAChB,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { createMappedChildRunner, createSingleChildRunner } from \"./child-execution.js\";\nimport type { ToMappedChildStepProgressOptions } from \"./mapped-child-progress.js\";\nimport {\n STEP_NESTED_PIPELINE,\n STEP_OPTIONS_SCHEMA,\n STEP_REMOTE,\n} from \"./pipeline-step-metadata.js\";\nimport type {\n InferSchemaInput,\n InferSchemaOutput,\n Pipeline,\n PipelineExecutionContext,\n PipelinePlanStep,\n PipelineRun,\n PipelineRunControls,\n PipelineStepContext,\n RemoteStepAdapter,\n StandardSchemaV1,\n StepSkipDecision,\n} from \"./pipeline-types.js\";\n\n/**\n * A step's dependencies are references to the dependency's own step object, not string ids\n * into a hand-maintained output-type map. This buys two things no amount of extra generics\n * on a string-keyed design could:\n * - a step used before its dependency exists is a compile error (JS temporal dead zone on\n * `const`), so out-of-order and self/cyclic dependencies are caught by the language, not\n * a bespoke runtime check\n * - each step only ever states its own id/deps; the output-type map is derived, never\n * restated, and callers of `definePipeline`/`createSteps` never write out its generics\n */\ntype AnyStepDryRunHandler<TOptions extends object> = {\n bivarianceHack(\n inputs: Record<string, unknown>,\n context: PipelineStepContext<TOptions>\n ): unknown | Promise<unknown>;\n}[\"bivarianceHack\"];\n\n/** Runtime shape shared by every declared pipeline step. */\nexport interface AnyStep<TOptions extends object = object> {\n readonly [STEP_NESTED_PIPELINE]?: NonNullable<PipelinePlanStep[\"nestedPipeline\"]>;\n readonly [STEP_REMOTE]?: NonNullable<PipelinePlanStep[\"remote\"]>;\n readonly [STEP_OPTIONS_SCHEMA]?: StandardSchemaV1;\n readonly id: string;\n readonly dependsOn?: readonly AnyStep<TOptions>[];\n readonly optionalDependsOn?: readonly AnyStep<TOptions>[];\n readonly skipAfterFailureOf?: readonly AnyStep<TOptions>[];\n /** Optional human-facing display name. Stable machine identity remains `id`. */\n readonly name?: string;\n readonly description?: string;\n /**\n * Dry-run policy. Omitted runs the normal handler, `\"skip\"` structurally\n * skips it, and a handler substitutes for `run` while preserving its output.\n */\n readonly dryRun?: \"skip\" | AnyStepDryRunHandler<TOptions>;\n /** Optional Standard Schema for values published by this step. */\n readonly outputSchema?: StandardSchemaV1;\n /**\n * Optional runtime skip. Return a non-empty reason (or `{ reason, value }`) to\n * skip without calling `run`. Policy skips unlock dependents; structural skips\n * (dry-run, filtered, …) do not use this hook.\n */\n skip?(\n inputs: Record<string, unknown>,\n context: PipelineExecutionContext<TOptions>\n ): StepSkipDecision | Promise<StepSkipDecision>;\n run(inputs: Record<string, unknown>, context: PipelineStepContext<TOptions>): unknown;\n}\n\n/** The step fields that `buildStep` merges onto the id-bearing shell. */\ntype StepDefinitionBody<TOptions extends object> = Omit<AnyStep<TOptions>, \"id\">;\n\n/** Typed pipeline step carrying its stable ID, output, and option types. */\nexport interface Step<\n TId extends string,\n TOut,\n TOptions extends object,\n TInputOptions extends object = TOptions,\n TRunOut = TOut,\n TOptionsSchema extends StandardSchemaV1 | undefined = StandardSchemaV1 | undefined,\n> extends AnyStep<TOptions> {\n readonly [STEP_OPTIONS_SCHEMA]?: TOptionsSchema;\n readonly id: TId;\n run(\n inputs: Record<string, unknown>,\n context: PipelineStepContext<TOptions>\n ): TRunOut | Promise<TRunOut>;\n /** Type-only: carries this step's output type for sibling inference. Never set at runtime. */\n readonly __outputType?: TOut;\n /** Type-only: carries pre-validation run options for pipeline call-site inference. */\n readonly __inputOptionsType?: TInputOptions;\n}\n\n/**\n * Extract a step's output type for dependency typing.\n * Prefer matching `Step<…, TOut, …>` over `{ __outputType?: infer T }`: optional-property\n * inference collapses `TOut | undefined` to `TOut`, which hides policy-skip widening.\n */\nexport type StepOutput<S> =\n S extends Step<string, infer TOut, infer _TOptions, infer _TInputOptions, infer _TRunOut>\n ? TOut\n : never;\n\ninterface StepToken {\n readonly id: string;\n readonly __outputType?: unknown;\n}\n\ntype RequiredInputs<TDeps extends readonly StepToken[]> = {\n [S in TDeps[number] as S[\"id\"]]: StepOutput<S>;\n};\n\ntype OptionalInputs<TDeps extends readonly StepToken[]> = {\n [S in TDeps[number] as S[\"id\"]]?: StepOutput<S>;\n};\n\ntype PipelineResultOf<TPipeline> =\n TPipeline extends Pipeline<object, infer TResult, infer _TStepId, infer _TTargetId>\n ? TResult\n : never;\n\ntype PipelineOptionsOf<TPipeline> =\n TPipeline extends Pipeline<infer TOptions, unknown, infer _TStepId, infer _TTargetId>\n ? TOptions\n : never;\n\ntype PipelineRunControlsOf<TPipeline> =\n TPipeline extends Pipeline<infer _TOptions, unknown, infer TStepId, infer TTargetId>\n ? PipelineRunControls<TStepId, TTargetId>\n : never;\n\ntype ChildPipelineStepDefinitionBase<\n TParentOptions extends object,\n TDeps extends readonly AnyStep<TParentOptions>[],\n TOptionalDeps extends readonly AnyStep<TParentOptions>[],\n TChildPipeline extends Pipeline<object, unknown>,\n> = {\n pipeline: TChildPipeline;\n dependsOn?: TDeps;\n optionalDependsOn?: TOptionalDeps;\n skipAfterFailureOf?: readonly AnyStep<TParentOptions>[];\n name?: string;\n description?: string;\n dryRun?: \"skip\";\n controls?:\n | PipelineRunControlsOf<TChildPipeline>\n | ((\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ) => PipelineRunControlsOf<TChildPipeline>);\n mapOptions(\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ): PipelineOptionsOf<TChildPipeline>;\n};\n\n/** Child step without policy skip (dependents see the full child result type). */\ntype ChildPipelineStepDefinition<\n TParentOptions extends object,\n TDeps extends readonly AnyStep<TParentOptions>[],\n TOptionalDeps extends readonly AnyStep<TParentOptions>[],\n TChildPipeline extends Pipeline<object, unknown>,\n> = ChildPipelineStepDefinitionBase<TParentOptions, TDeps, TOptionalDeps, TChildPipeline>;\n\n/**\n * Presentation options for opaque `forEachPipeline` progress.\n * Defaults are domain-neutral (`N/M items · K running · key/step`).\n * Override `formatMessage` when a domain wants its own noun (images, shards, …).\n */\nexport type MappedChildProgressOptions = ToMappedChildStepProgressOptions;\n\ntype MappedChildPipelineStepDefinition<\n TParentOptions extends object,\n TDeps extends readonly AnyStep<TParentOptions>[],\n TOptionalDeps extends readonly AnyStep<TParentOptions>[],\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n> = {\n pipeline: TChildPipeline;\n dependsOn?: TDeps;\n optionalDependsOn?: TOptionalDeps;\n skipAfterFailureOf?: readonly AnyStep<TParentOptions>[];\n name?: string;\n description?: string;\n dryRun?: \"skip\";\n items(\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ): readonly TItem[] | Promise<readonly TItem[]>;\n key(item: TItem, index: number): string;\n concurrency?:\n | number\n | ((\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ) => number);\n /**\n * How the opaque parent step reports live fan-out progress.\n * Purely presentational — does not change scheduling or results.\n */\n progress?: MappedChildProgressOptions;\n controls?:\n | PipelineRunControlsOf<TChildPipeline>\n | ((\n item: TItem,\n index: number,\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ) => PipelineRunControlsOf<TChildPipeline>);\n mapOptions(\n item: TItem,\n index: number,\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ): PipelineOptionsOf<TChildPipeline>;\n};\n\ntype StepSkipPredicate<\n TOptions extends object,\n TDeps extends readonly AnyStep<TOptions>[],\n TOptionalDeps extends readonly AnyStep<TOptions>[],\n TOut,\n TDecision extends StepSkipDecision<TOut> = StepSkipDecision<TOut>,\n> = (\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TOptions>\n) => TDecision | Promise<TDecision>;\n\ntype PolicySkippedOutput<TOut, TDecision> = [\n Exclude<Awaited<TDecision>, false | null | undefined>,\n] extends [{ reason: string; value: unknown }]\n ? TOut\n : TOut | undefined;\n\ntype StepDryRunPolicy<\n TOptions extends object,\n TDeps extends readonly AnyStep<TOptions>[],\n TOptionalDeps extends readonly AnyStep<TOptions>[],\n TOut,\n> =\n | \"skip\"\n | ((\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineStepContext<TOptions>\n ) => TOut | Promise<TOut>);\n\ntype PlainStepFields<\n TOptions extends object,\n TDeps extends readonly AnyStep<TOptions>[],\n TOptionalDeps extends readonly AnyStep<TOptions>[],\n TOut,\n> = {\n dependsOn?: TDeps;\n optionalDependsOn?: TOptionalDeps;\n skipAfterFailureOf?: readonly AnyStep<TOptions>[];\n name?: string;\n description?: string;\n dryRun?: StepDryRunPolicy<TOptions, TDeps, TOptionalDeps, TOut>;\n outputSchema?: never;\n run(\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineStepContext<TOptions>\n ): TOut | Promise<TOut>;\n};\n\ntype SchemaStepFields<\n TOptions extends object,\n TDeps extends readonly AnyStep<TOptions>[],\n TOptionalDeps extends readonly AnyStep<TOptions>[],\n TSchema extends StandardSchemaV1,\n> = Omit<\n PlainStepFields<TOptions, TDeps, TOptionalDeps, InferSchemaInput<TSchema>>,\n \"outputSchema\"\n> & {\n outputSchema: TSchema;\n};\n\ntype RemoteStepDefinitionBase<\n TParentOptions extends object,\n TDeps extends readonly AnyStep<TParentOptions>[],\n TOptionalDeps extends readonly AnyStep<TParentOptions>[],\n TPayload,\n TSchema extends StandardSchemaV1,\n> = {\n adapter: RemoteStepAdapter<TParentOptions, TPayload, InferSchemaInput<TSchema>>;\n mapInput(\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineStepContext<TParentOptions>\n ): TPayload;\n outputSchema: TSchema;\n dependsOn?: TDeps;\n optionalDependsOn?: TOptionalDeps;\n skipAfterFailureOf?: readonly AnyStep<TParentOptions>[];\n name?: string;\n description?: string;\n dryRun?: StepDryRunPolicy<TParentOptions, TDeps, TOptionalDeps, InferSchemaInput<TSchema>>;\n};\n\n/** Step constructors scoped to one pipeline's domain option types. */\ntype StepFactory<\n TOptions extends object,\n TInputOptions extends object = TOptions,\n TOptionsSchema extends StandardSchemaV1 | undefined = undefined,\n> = ReturnType<typeof createStepFactory<TOptions, TInputOptions, TOptionsSchema>>;\n\n/**\n * Create typed step constructors for one pipeline definition.\n * Returns a step factory scoped to one pipeline's domain options. Pass built-in\n * run controls as the second argument to `run` / `runOrThrow`, or through a\n * child step's separate `controls` field.\n */\nexport function createSteps<TOptions extends object = {}>(): StepFactory<TOptions>;\nexport function createSteps<const TSchema extends StandardSchemaV1<object, object> | undefined>(\n optionsSchema: TSchema\n): StepFactory<\n TSchema extends StandardSchemaV1 ? InferSchemaOutput<TSchema> : object,\n TSchema extends StandardSchemaV1 ? InferSchemaInput<TSchema> : object,\n TSchema\n>;\nexport function createSteps(\n optionsSchema?: StandardSchemaV1<object, object>\n): StepFactory<object, object, StandardSchemaV1 | undefined> {\n return createStepFactory<object, object, StandardSchemaV1 | undefined>(optionsSchema);\n}\n\nfunction createStepFactory<\n TOptions extends object,\n TInputOptions extends object = TOptions,\n TOptionsSchema extends StandardSchemaV1 | undefined = undefined,\n>(optionsSchema?: TOptionsSchema) {\n // Preserve the runtime schema in the step type so adapters cannot infer flags\n // from erased TypeScript-only options.\n type BuiltStep<\n TId extends string,\n TOut,\n TStepOptions extends object,\n TInput extends object,\n TRunOut = TOut,\n > = TOptionsSchema extends StandardSchemaV1\n ? Step<TId, TOut, TStepOptions, TInput, TRunOut, TOptionsSchema>\n : Step<TId, TOut, TStepOptions, TInput, TRunOut>;\n const buildStep = (id: string, definition: StepDefinitionBody<TOptions>): AnyStep<TOptions> => {\n const built: AnyStep<TOptions> = { id, ...definition };\n if (optionsSchema) {\n Object.defineProperty(built, STEP_OPTIONS_SCHEMA, { value: optionsSchema });\n }\n return built;\n };\n\n function step<\n TId extends string,\n TSchema extends StandardSchemaV1,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TDecision extends StepSkipDecision<InferSchemaInput<TSchema>> = StepSkipDecision<\n InferSchemaInput<TSchema>\n >,\n >(\n id: TId,\n definition: SchemaStepFields<TOptions, TDeps, TOptionalDeps, TSchema> & {\n skip:\n | StepSkipPredicate<TOptions, TDeps, TOptionalDeps, InferSchemaInput<TSchema>, TDecision>\n | undefined;\n }\n ): BuiltStep<\n TId,\n PolicySkippedOutput<InferSchemaOutput<TSchema>, TDecision>,\n TOptions,\n TInputOptions,\n InferSchemaInput<TSchema>\n >;\n function step<\n TId extends string,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TOut = unknown,\n TDecision extends StepSkipDecision<NoInfer<TOut>> = StepSkipDecision<NoInfer<TOut>>,\n >(\n id: TId,\n definition: PlainStepFields<TOptions, TDeps, TOptionalDeps, TOut> & {\n skip: StepSkipPredicate<TOptions, TDeps, TOptionalDeps, NoInfer<TOut>, TDecision> | undefined;\n }\n ): BuiltStep<TId, PolicySkippedOutput<TOut, TDecision>, TOptions, TInputOptions>;\n function step<\n TId extends string,\n TSchema extends StandardSchemaV1,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: SchemaStepFields<TOptions, TDeps, TOptionalDeps, TSchema> & { skip?: never }\n ): BuiltStep<TId, InferSchemaOutput<TSchema>, TOptions, TInputOptions, InferSchemaInput<TSchema>>;\n function step<\n TId extends string,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TOut = unknown,\n >(\n id: TId,\n definition: PlainStepFields<TOptions, TDeps, TOptionalDeps, TOut> & { skip?: never }\n ): BuiltStep<TId, TOut, TOptions, TInputOptions>;\n function step(id: string, definition: StepDefinitionBody<TOptions>): AnyStep<TOptions> {\n return buildStep(id, definition);\n }\n\n const buildPipelineStep = (\n id: string,\n config: ChildPipelineStepDefinitionBase<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n Pipeline<object, unknown>\n > & {\n skip?: StepSkipPredicate<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n unknown\n >;\n mapResult?: (\n value: unknown,\n result: PipelineRun<unknown>,\n context: PipelineStepContext<TOptions>\n ) => unknown;\n }\n ) => {\n const definition: StepDefinitionBody<TOptions> = {\n [STEP_NESTED_PIPELINE]: {\n mode: \"single\" as const,\n pipelineId: config.pipeline.id,\n identity: config.pipeline.definition?.identity,\n stepIds: config.pipeline.stepIds,\n },\n dependsOn: config.dependsOn,\n optionalDependsOn: config.optionalDependsOn,\n skipAfterFailureOf: config.skipAfterFailureOf,\n name: config.name,\n description: config.description,\n dryRun: config.dryRun,\n run: createSingleChildRunner(config),\n };\n\n const skip = config.skip;\n if (skip !== undefined) {\n definition.skip = skip;\n }\n return buildStep(id, definition);\n };\n\n function fromPipeline<\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: ChildPipelineStepDefinition<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {\n skip?: never;\n mapResult?: undefined;\n }\n ): BuiltStep<TId, PipelineResultOf<TChildPipeline>, TOptions, TInputOptions>;\n function fromPipeline<\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TOut,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: ChildPipelineStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {\n skip?: never;\n mapResult(\n value: PipelineResultOf<TChildPipeline>,\n result: PipelineRun<PipelineResultOf<TChildPipeline>>,\n context: PipelineStepContext<TOptions>\n ): TOut;\n }\n ): BuiltStep<TId, Awaited<TOut>, TOptions, TInputOptions>;\n function fromPipeline<\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TDecision extends StepSkipDecision<PipelineResultOf<TChildPipeline>> = StepSkipDecision<\n PipelineResultOf<TChildPipeline>\n >,\n >(\n id: TId,\n definition: ChildPipelineStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {\n skip:\n | StepSkipPredicate<\n TOptions,\n TDeps,\n TOptionalDeps,\n PipelineResultOf<TChildPipeline>,\n TDecision\n >\n | undefined;\n mapResult?: undefined;\n }\n ): BuiltStep<\n TId,\n PolicySkippedOutput<PipelineResultOf<TChildPipeline>, TDecision>,\n TOptions,\n TInputOptions\n >;\n function fromPipeline<\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TOut,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TDecision extends StepSkipDecision<NoInfer<Awaited<TOut>>> = StepSkipDecision<\n NoInfer<Awaited<TOut>>\n >,\n >(\n id: TId,\n definition: ChildPipelineStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {\n skip:\n | StepSkipPredicate<TOptions, TDeps, TOptionalDeps, NoInfer<Awaited<TOut>>, TDecision>\n | undefined;\n mapResult(\n value: PipelineResultOf<TChildPipeline>,\n result: PipelineRun<PipelineResultOf<TChildPipeline>>,\n context: PipelineStepContext<TOptions>\n ): TOut;\n }\n ): BuiltStep<TId, PolicySkippedOutput<Awaited<TOut>, TDecision>, TOptions, TInputOptions>;\n function fromPipeline(\n id: string,\n definition: Parameters<typeof buildPipelineStep>[1]\n ): AnyStep<TOptions> {\n return buildPipelineStep(id, definition);\n }\n\n const buildRemoteStep = (\n id: string,\n config: {\n adapter: RemoteStepAdapter<object, unknown, unknown>;\n mapInput(inputs: Record<string, unknown>, context: PipelineStepContext<TOptions>): unknown;\n outputSchema: StandardSchemaV1;\n dependsOn?: readonly AnyStep<TOptions>[];\n optionalDependsOn?: readonly AnyStep<TOptions>[];\n skipAfterFailureOf?: readonly AnyStep<TOptions>[];\n name?: string;\n description?: string;\n dryRun?: \"skip\" | AnyStepDryRunHandler<TOptions>;\n skip?: StepSkipPredicate<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n unknown\n >;\n }\n ) => {\n const remote: NonNullable<PipelinePlanStep[\"remote\"]> = { engine: config.adapter.engine };\n if (config.adapter.target !== undefined) remote.target = config.adapter.target;\n const definition: StepDefinitionBody<TOptions> = {\n [STEP_REMOTE]: remote,\n dependsOn: config.dependsOn,\n optionalDependsOn: config.optionalDependsOn,\n skipAfterFailureOf: config.skipAfterFailureOf,\n name: config.name,\n description: config.description,\n dryRun: config.dryRun,\n outputSchema: config.outputSchema,\n run: (inputs: Record<string, unknown>, context: PipelineStepContext<TOptions>) =>\n config.adapter.invoke(config.mapInput(inputs, context), context),\n };\n const skip = config.skip;\n if (skip !== undefined) {\n definition.skip = skip;\n }\n return buildStep(id, definition);\n };\n\n function fromRemote<\n TId extends string,\n TSchema extends StandardSchemaV1,\n TPayload,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: RemoteStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TPayload, TSchema> & {\n skip?: never;\n }\n ): BuiltStep<TId, InferSchemaOutput<TSchema>, TOptions, TInputOptions, InferSchemaInput<TSchema>>;\n function fromRemote<\n TId extends string,\n TSchema extends StandardSchemaV1,\n TPayload,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TDecision extends StepSkipDecision<InferSchemaInput<TSchema>> = StepSkipDecision<\n InferSchemaInput<TSchema>\n >,\n >(\n id: TId,\n definition: RemoteStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TPayload, TSchema> & {\n skip:\n | StepSkipPredicate<TOptions, TDeps, TOptionalDeps, InferSchemaInput<TSchema>, TDecision>\n | undefined;\n }\n ): BuiltStep<\n TId,\n PolicySkippedOutput<InferSchemaOutput<TSchema>, TDecision>,\n TOptions,\n TInputOptions,\n InferSchemaInput<TSchema>\n >;\n function fromRemote(\n id: string,\n definition: Parameters<typeof buildRemoteStep>[1]\n ): AnyStep<TOptions> {\n return buildRemoteStep(id, definition);\n }\n\n const buildMappedPipelineStep = (\n id: string,\n config: MappedChildPipelineStepDefinition<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n Pipeline<object, unknown>,\n unknown\n > & {\n mapResult?: (\n value: unknown,\n result: PipelineRun<unknown>,\n item: unknown,\n index: number,\n context: PipelineStepContext<TOptions>\n ) => unknown;\n skip?: StepSkipPredicate<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n unknown\n >;\n }\n ) => {\n const definition: StepDefinitionBody<TOptions> = {\n [STEP_NESTED_PIPELINE]: {\n mode: \"for-each\" as const,\n concurrency:\n typeof config.concurrency === \"function\" ? \"dynamic\" : (config.concurrency ?? 1),\n pipelineId: config.pipeline.id,\n identity: config.pipeline.definition?.identity,\n stepIds: config.pipeline.stepIds,\n },\n dependsOn: config.dependsOn,\n optionalDependsOn: config.optionalDependsOn,\n skipAfterFailureOf: config.skipAfterFailureOf,\n name: config.name,\n description: config.description,\n dryRun: config.dryRun,\n run: createMappedChildRunner(config),\n };\n\n const skip = config.skip;\n if (skip !== undefined) {\n definition.skip = skip;\n }\n return buildStep(id, definition);\n };\n\n function forEachPipeline<\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: MappedChildPipelineStepDefinition<\n TOptions,\n TDeps,\n TOptionalDeps,\n TChildPipeline,\n TItem\n > & {\n skip?: never;\n mapResult?: undefined;\n }\n ): BuiltStep<TId, readonly PipelineResultOf<TChildPipeline>[], TOptions, TInputOptions>;\n function forEachPipeline<\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n TOut,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: MappedChildPipelineStepDefinition<\n TOptions,\n TDeps,\n TOptionalDeps,\n TChildPipeline,\n TItem\n > & {\n skip?: never;\n mapResult(\n value: PipelineResultOf<TChildPipeline>,\n result: PipelineRun<PipelineResultOf<TChildPipeline>>,\n item: TItem,\n index: number,\n context: PipelineStepContext<TOptions>\n ): TOut;\n }\n ): BuiltStep<TId, readonly TOut[], TOptions, TInputOptions>;\n function forEachPipeline<\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TDecision extends StepSkipDecision<readonly PipelineResultOf<TChildPipeline>[]> =\n StepSkipDecision<readonly PipelineResultOf<TChildPipeline>[]>,\n >(\n id: TId,\n definition: MappedChildPipelineStepDefinition<\n TOptions,\n TDeps,\n TOptionalDeps,\n TChildPipeline,\n TItem\n > & {\n skip:\n | StepSkipPredicate<\n TOptions,\n TDeps,\n TOptionalDeps,\n readonly PipelineResultOf<TChildPipeline>[],\n TDecision\n >\n | undefined;\n mapResult?: undefined;\n }\n ): BuiltStep<\n TId,\n PolicySkippedOutput<readonly PipelineResultOf<TChildPipeline>[], TDecision>,\n TOptions,\n TInputOptions\n >;\n function forEachPipeline<\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n TOut,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TDecision extends StepSkipDecision<NoInfer<readonly TOut[]>> = StepSkipDecision<\n NoInfer<readonly TOut[]>\n >,\n >(\n id: TId,\n definition: MappedChildPipelineStepDefinition<\n TOptions,\n TDeps,\n TOptionalDeps,\n TChildPipeline,\n TItem\n > & {\n skip:\n | StepSkipPredicate<TOptions, TDeps, TOptionalDeps, NoInfer<readonly TOut[]>, TDecision>\n | undefined;\n mapResult(\n value: PipelineResultOf<TChildPipeline>,\n result: PipelineRun<PipelineResultOf<TChildPipeline>>,\n item: TItem,\n index: number,\n context: PipelineStepContext<TOptions>\n ): TOut;\n }\n ): BuiltStep<TId, PolicySkippedOutput<readonly TOut[], TDecision>, TOptions, TInputOptions>;\n function forEachPipeline(\n id: string,\n definition: Parameters<typeof buildMappedPipelineStep>[1]\n ): AnyStep<TOptions> {\n return buildMappedPipelineStep(id, definition);\n }\n\n const factory = {\n step,\n fromPipeline,\n fromRemote,\n forEachPipeline,\n };\n\n return factory;\n}\n"]}
1
+ {"version":3,"file":"pipeline-steps.js","sourceRoot":"","sources":["../../src/core/pipeline-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAExF,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,GACZ,MAAM,6BAA6B,CAAC;AAiUrC,MAAM,UAAU,WAAW,CACzB,aAAgD;IAEhD,OAAO,iBAAiB,CAA+C,aAAa,CAAC,CAAC;AACxF,CAAC;AAED,SA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ner, createSingleChildRunner } from \"./child-execution.js\";\nimport type { ToMappedChildStepProgressOptions } from \"./mapped-child-progress.js\";\nimport {\n STEP_NESTED_PIPELINE,\n STEP_OPTIONS_SCHEMA,\n STEP_REMOTE,\n} from \"./pipeline-step-metadata.js\";\nimport type {\n InferSchemaInput,\n InferSchemaOutput,\n Pipeline,\n PipelineExecutionContext,\n PipelinePlanStep,\n PipelineRun,\n PipelineRunControls,\n PipelineStepContext,\n RemoteStepAdapter,\n StandardSchemaV1,\n StepSkipDecision,\n} from \"./pipeline-types.js\";\n\n/**\n * A step's dependencies are references to the dependency's own step object, not string ids\n * into a hand-maintained output-type map. This buys two things no amount of extra generics\n * on a string-keyed design could:\n * - a step used before its dependency exists is a compile error (JS temporal dead zone on\n * `const`), so out-of-order and self/cyclic dependencies are caught by the language, not\n * a bespoke runtime check\n * - each step only ever states its own id/deps; the output-type map is derived, never\n * restated, and callers of `definePipeline`/`createSteps` never write out its generics\n */\ntype AnyStepDryRunHandler<TOptions extends object> = {\n bivarianceHack(\n inputs: Record<string, unknown>,\n context: PipelineStepContext<TOptions>\n ): unknown | Promise<unknown>;\n}[\"bivarianceHack\"];\n\n/** Runtime shape shared by every declared pipeline step. */\nexport interface AnyStep<TOptions extends object = object> {\n readonly [STEP_NESTED_PIPELINE]?: NonNullable<PipelinePlanStep[\"nestedPipeline\"]>;\n readonly [STEP_REMOTE]?: NonNullable<PipelinePlanStep[\"remote\"]>;\n readonly [STEP_OPTIONS_SCHEMA]?: StandardSchemaV1;\n readonly id: string;\n readonly dependsOn?: readonly AnyStep<TOptions>[];\n readonly optionalDependsOn?: readonly AnyStep<TOptions>[];\n readonly skipAfterFailureOf?: readonly AnyStep<TOptions>[];\n /** Optional human-facing display name. Stable machine identity remains `id`. */\n readonly name?: string;\n readonly description?: string;\n /**\n * Dry-run policy. Omitted runs the normal handler, `\"skip\"` structurally\n * skips it, and a handler substitutes for `run` while preserving its output.\n */\n readonly dryRun?: \"skip\" | AnyStepDryRunHandler<TOptions>;\n /** Optional Standard Schema for values published by this step. */\n readonly outputSchema?: StandardSchemaV1;\n /**\n * Optional runtime skip. Return a non-empty reason (or `{ reason, value }`) to\n * skip without calling `run`. Policy skips unlock dependents; structural skips\n * (dry-run, filtered, …) do not use this hook.\n */\n skip?(\n inputs: Record<string, unknown>,\n context: PipelineExecutionContext<TOptions>\n ): StepSkipDecision | Promise<StepSkipDecision>;\n run(inputs: Record<string, unknown>, context: PipelineStepContext<TOptions>): unknown;\n}\n\n/** The step fields that `buildStep` merges onto the id-bearing shell. */\ntype StepDefinitionBody<TOptions extends object> = Omit<AnyStep<TOptions>, \"id\">;\n\n/** Typed pipeline step carrying its stable ID, output, and option types. */\nexport interface Step<\n TId extends string,\n TOut,\n TOptions extends object,\n TInputOptions extends object = TOptions,\n TRunOut = TOut,\n TOptionsSchema extends StandardSchemaV1 | undefined = StandardSchemaV1 | undefined,\n> extends AnyStep<TOptions> {\n readonly [STEP_OPTIONS_SCHEMA]?: TOptionsSchema;\n readonly id: TId;\n run(\n inputs: Record<string, unknown>,\n context: PipelineStepContext<TOptions>\n ): TRunOut | Promise<TRunOut>;\n /** Type-only: carries this step's output type for sibling inference. Never set at runtime. */\n readonly __outputType?: TOut;\n /** Type-only: carries pre-validation run options for pipeline call-site inference. */\n readonly __inputOptionsType?: TInputOptions;\n}\n\n/**\n * Extract a step's output type for dependency typing.\n * Prefer matching `Step<…, TOut, …>` over `{ __outputType?: infer T }`: optional-property\n * inference collapses `TOut | undefined` to `TOut`, which hides policy-skip widening.\n */\nexport type StepOutput<S> =\n S extends Step<string, infer TOut, infer _TOptions, infer _TInputOptions, infer _TRunOut>\n ? TOut\n : never;\n\ninterface StepToken {\n readonly id: string;\n readonly __outputType?: unknown;\n}\n\ntype RequiredInputs<TDeps extends readonly StepToken[]> = {\n [S in TDeps[number] as S[\"id\"]]: StepOutput<S>;\n};\n\ntype OptionalInputs<TDeps extends readonly StepToken[]> = {\n [S in TDeps[number] as S[\"id\"]]?: StepOutput<S>;\n};\n\ntype PipelineResultOf<TPipeline> =\n TPipeline extends Pipeline<object, infer TResult, infer _TStepId, infer _TTargetId>\n ? TResult\n : never;\n\ntype PipelineOptionsOf<TPipeline> =\n TPipeline extends Pipeline<infer TOptions, unknown, infer _TStepId, infer _TTargetId>\n ? TOptions\n : never;\n\ntype PipelineRunControlsOf<TPipeline> =\n TPipeline extends Pipeline<infer _TOptions, unknown, infer TStepId, infer TTargetId>\n ? PipelineRunControls<TStepId, TTargetId>\n : never;\n\ntype ChildPipelineStepDefinitionBase<\n TParentOptions extends object,\n TDeps extends readonly AnyStep<TParentOptions>[],\n TOptionalDeps extends readonly AnyStep<TParentOptions>[],\n TChildPipeline extends Pipeline<object, unknown>,\n> = {\n pipeline: TChildPipeline;\n dependsOn?: TDeps;\n optionalDependsOn?: TOptionalDeps;\n skipAfterFailureOf?: readonly AnyStep<TParentOptions>[];\n name?: string;\n description?: string;\n dryRun?: \"skip\";\n controls?:\n | PipelineRunControlsOf<TChildPipeline>\n | ((\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ) => PipelineRunControlsOf<TChildPipeline>);\n} & ([TParentOptions] extends [PipelineOptionsOf<NoInfer<TChildPipeline>>]\n ? {\n mapOptions?(\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ): PipelineOptionsOf<TChildPipeline>;\n }\n : {\n mapOptions(\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ): PipelineOptionsOf<TChildPipeline>;\n });\n\n/** Child step without policy skip (dependents see the full child result type). */\ntype ChildPipelineStepDefinition<\n TParentOptions extends object,\n TDeps extends readonly AnyStep<TParentOptions>[],\n TOptionalDeps extends readonly AnyStep<TParentOptions>[],\n TChildPipeline extends Pipeline<object, unknown>,\n> = ChildPipelineStepDefinitionBase<TParentOptions, TDeps, TOptionalDeps, TChildPipeline>;\n\n/**\n * Presentation options for opaque `forEachPipeline` progress.\n * Defaults are domain-neutral (`N/M items · K running · key/step`).\n * Override `formatMessage` when a domain wants its own noun (images, shards, …).\n */\nexport type MappedChildProgressOptions = ToMappedChildStepProgressOptions;\n\ntype MappedChildPipelineStepDefinition<\n TParentOptions extends object,\n TDeps extends readonly AnyStep<TParentOptions>[],\n TOptionalDeps extends readonly AnyStep<TParentOptions>[],\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n> = {\n pipeline: TChildPipeline;\n dependsOn?: TDeps;\n optionalDependsOn?: TOptionalDeps;\n skipAfterFailureOf?: readonly AnyStep<TParentOptions>[];\n name?: string;\n description?: string;\n dryRun?: \"skip\";\n items(\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ): readonly TItem[] | Promise<readonly TItem[]>;\n key(item: TItem, index: number): string;\n concurrency?:\n | number\n | ((\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ) => number);\n /**\n * How the opaque parent step reports live fan-out progress.\n * Purely presentational — does not change scheduling or results.\n */\n progress?: MappedChildProgressOptions;\n controls?:\n | PipelineRunControlsOf<TChildPipeline>\n | ((\n item: TItem,\n index: number,\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ) => PipelineRunControlsOf<TChildPipeline>);\n mapOptions(\n item: TItem,\n index: number,\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TParentOptions>\n ): PipelineOptionsOf<TChildPipeline>;\n};\n\ntype StepSkipPredicate<\n TOptions extends object,\n TDeps extends readonly AnyStep<TOptions>[],\n TOptionalDeps extends readonly AnyStep<TOptions>[],\n TOut,\n TDecision extends StepSkipDecision<TOut> = StepSkipDecision<TOut>,\n> = (\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineExecutionContext<TOptions>\n) => TDecision | Promise<TDecision>;\n\ntype PolicySkippedOutput<TOut, TDecision> = [\n Exclude<Awaited<TDecision>, false | null | undefined>,\n] extends [{ reason: string; value: unknown }]\n ? TOut\n : TOut | undefined;\n\ntype StepDryRunPolicy<\n TOptions extends object,\n TDeps extends readonly AnyStep<TOptions>[],\n TOptionalDeps extends readonly AnyStep<TOptions>[],\n TOut,\n> =\n | \"skip\"\n | ((\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineStepContext<TOptions>\n ) => TOut | Promise<TOut>);\n\ntype PlainStepFields<\n TOptions extends object,\n TDeps extends readonly AnyStep<TOptions>[],\n TOptionalDeps extends readonly AnyStep<TOptions>[],\n TOut,\n> = {\n dependsOn?: TDeps;\n optionalDependsOn?: TOptionalDeps;\n skipAfterFailureOf?: readonly AnyStep<TOptions>[];\n name?: string;\n description?: string;\n dryRun?: StepDryRunPolicy<TOptions, TDeps, TOptionalDeps, TOut>;\n outputSchema?: never;\n run(\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineStepContext<TOptions>\n ): TOut | Promise<TOut>;\n};\n\ntype SchemaStepFields<\n TOptions extends object,\n TDeps extends readonly AnyStep<TOptions>[],\n TOptionalDeps extends readonly AnyStep<TOptions>[],\n TSchema extends StandardSchemaV1,\n> = Omit<\n PlainStepFields<TOptions, TDeps, TOptionalDeps, InferSchemaInput<TSchema>>,\n \"outputSchema\"\n> & {\n outputSchema: TSchema;\n};\n\ntype RemoteStepDefinitionBase<\n TParentOptions extends object,\n TDeps extends readonly AnyStep<TParentOptions>[],\n TOptionalDeps extends readonly AnyStep<TParentOptions>[],\n TPayload,\n TSchema extends StandardSchemaV1,\n> = {\n adapter: RemoteStepAdapter<TParentOptions, TPayload, InferSchemaInput<TSchema>>;\n mapInput(\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineStepContext<TParentOptions>\n ): TPayload;\n outputSchema: TSchema;\n dependsOn?: TDeps;\n optionalDependsOn?: TOptionalDeps;\n skipAfterFailureOf?: readonly AnyStep<TParentOptions>[];\n name?: string;\n description?: string;\n dryRun?: StepDryRunPolicy<TParentOptions, TDeps, TOptionalDeps, InferSchemaInput<TSchema>>;\n};\n\n/** Step constructors scoped to one pipeline's domain option types. */\ntype StepFactory<\n TOptions extends object,\n TInputOptions extends object = TOptions,\n TOptionsSchema extends StandardSchemaV1 | undefined = undefined,\n> = ReturnType<typeof createStepFactory<TOptions, TInputOptions, TOptionsSchema>>;\n\n/**\n * Create typed step constructors for one pipeline definition.\n * Returns a step factory scoped to one pipeline's domain options. Pass built-in\n * run controls as the second argument to `run` / `runOrThrow`, or through a\n * child step's separate `controls` field.\n */\nexport function createSteps<TOptions extends object = {}>(): StepFactory<TOptions>;\nexport function createSteps<const TSchema extends StandardSchemaV1<object, object> | undefined>(\n optionsSchema: TSchema\n): StepFactory<\n TSchema extends StandardSchemaV1 ? InferSchemaOutput<TSchema> : object,\n TSchema extends StandardSchemaV1 ? InferSchemaInput<TSchema> : object,\n TSchema\n>;\nexport function createSteps(\n optionsSchema?: StandardSchemaV1<object, object>\n): StepFactory<object, object, StandardSchemaV1 | undefined> {\n return createStepFactory<object, object, StandardSchemaV1 | undefined>(optionsSchema);\n}\n\nfunction createStepFactory<\n TOptions extends object,\n TInputOptions extends object = TOptions,\n TOptionsSchema extends StandardSchemaV1 | undefined = undefined,\n>(optionsSchema?: TOptionsSchema) {\n // Preserve the runtime schema in the step type so adapters cannot infer flags\n // from erased TypeScript-only options.\n type BuiltStep<\n TId extends string,\n TOut,\n TStepOptions extends object,\n TInput extends object,\n TRunOut = TOut,\n > = TOptionsSchema extends StandardSchemaV1\n ? Step<TId, TOut, TStepOptions, TInput, TRunOut, TOptionsSchema>\n : Step<TId, TOut, TStepOptions, TInput, TRunOut>;\n const buildStep = (id: string, definition: StepDefinitionBody<TOptions>): AnyStep<TOptions> => {\n const built: AnyStep<TOptions> = { id, ...definition };\n if (optionsSchema) {\n Object.defineProperty(built, STEP_OPTIONS_SCHEMA, { value: optionsSchema });\n }\n return built;\n };\n\n function step<\n TId extends string,\n TSchema extends StandardSchemaV1,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TDecision extends StepSkipDecision<InferSchemaInput<TSchema>> = StepSkipDecision<\n InferSchemaInput<TSchema>\n >,\n >(\n id: TId,\n definition: SchemaStepFields<TOptions, TDeps, TOptionalDeps, TSchema> & {\n skip:\n | StepSkipPredicate<TOptions, TDeps, TOptionalDeps, InferSchemaInput<TSchema>, TDecision>\n | undefined;\n }\n ): BuiltStep<\n TId,\n PolicySkippedOutput<InferSchemaOutput<TSchema>, TDecision>,\n TOptions,\n TInputOptions,\n InferSchemaInput<TSchema>\n >;\n function step<\n TId extends string,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TOut = unknown,\n TDecision extends StepSkipDecision<NoInfer<TOut>> = StepSkipDecision<NoInfer<TOut>>,\n >(\n id: TId,\n definition: PlainStepFields<TOptions, TDeps, TOptionalDeps, TOut> & {\n skip: StepSkipPredicate<TOptions, TDeps, TOptionalDeps, NoInfer<TOut>, TDecision> | undefined;\n }\n ): BuiltStep<TId, PolicySkippedOutput<TOut, TDecision>, TOptions, TInputOptions>;\n function step<\n TId extends string,\n TSchema extends StandardSchemaV1,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: SchemaStepFields<TOptions, TDeps, TOptionalDeps, TSchema> & { skip?: never }\n ): BuiltStep<TId, InferSchemaOutput<TSchema>, TOptions, TInputOptions, InferSchemaInput<TSchema>>;\n function step<\n TId extends string,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TOut = unknown,\n >(\n id: TId,\n definition: PlainStepFields<TOptions, TDeps, TOptionalDeps, TOut> & { skip?: never }\n ): BuiltStep<TId, TOut, TOptions, TInputOptions>;\n function step(id: string, definition: StepDefinitionBody<TOptions>): AnyStep<TOptions> {\n return buildStep(id, definition);\n }\n\n const buildPipelineStep = (\n id: string,\n config: ChildPipelineStepDefinitionBase<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n Pipeline<object, unknown>\n > & {\n skip?: StepSkipPredicate<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n unknown\n >;\n mapResult?: (\n value: unknown,\n result: PipelineRun<unknown>,\n context: PipelineStepContext<TOptions>\n ) => unknown;\n }\n ) => {\n const definition: StepDefinitionBody<TOptions> = {\n [STEP_NESTED_PIPELINE]: {\n mode: \"single\" as const,\n pipelineId: config.pipeline.id,\n identity: config.pipeline.definition?.identity,\n stepIds: config.pipeline.stepIds,\n },\n dependsOn: config.dependsOn,\n optionalDependsOn: config.optionalDependsOn,\n skipAfterFailureOf: config.skipAfterFailureOf,\n name: config.name,\n description: config.description,\n dryRun: config.dryRun,\n run: createSingleChildRunner(config),\n };\n\n const skip = config.skip;\n if (skip !== undefined) {\n definition.skip = skip;\n }\n return buildStep(id, definition);\n };\n\n function fromPipeline<\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: ChildPipelineStepDefinition<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {\n skip?: never;\n mapResult?: undefined;\n }\n ): BuiltStep<TId, PipelineResultOf<TChildPipeline>, TOptions, TInputOptions>;\n function fromPipeline<\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TOut,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: ChildPipelineStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {\n skip?: never;\n mapResult(\n value: PipelineResultOf<TChildPipeline>,\n result: PipelineRun<PipelineResultOf<TChildPipeline>>,\n context: PipelineStepContext<TOptions>\n ): TOut;\n }\n ): BuiltStep<TId, Awaited<TOut>, TOptions, TInputOptions>;\n function fromPipeline<\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TDecision extends StepSkipDecision<PipelineResultOf<TChildPipeline>> = StepSkipDecision<\n PipelineResultOf<TChildPipeline>\n >,\n >(\n id: TId,\n definition: ChildPipelineStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {\n skip:\n | StepSkipPredicate<\n TOptions,\n TDeps,\n TOptionalDeps,\n PipelineResultOf<TChildPipeline>,\n TDecision\n >\n | undefined;\n mapResult?: undefined;\n }\n ): BuiltStep<\n TId,\n PolicySkippedOutput<PipelineResultOf<TChildPipeline>, TDecision>,\n TOptions,\n TInputOptions\n >;\n function fromPipeline<\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TOut,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TDecision extends StepSkipDecision<NoInfer<Awaited<TOut>>> = StepSkipDecision<\n NoInfer<Awaited<TOut>>\n >,\n >(\n id: TId,\n definition: ChildPipelineStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {\n skip:\n | StepSkipPredicate<TOptions, TDeps, TOptionalDeps, NoInfer<Awaited<TOut>>, TDecision>\n | undefined;\n mapResult(\n value: PipelineResultOf<TChildPipeline>,\n result: PipelineRun<PipelineResultOf<TChildPipeline>>,\n context: PipelineStepContext<TOptions>\n ): TOut;\n }\n ): BuiltStep<TId, PolicySkippedOutput<Awaited<TOut>, TDecision>, TOptions, TInputOptions>;\n function fromPipeline(\n id: string,\n definition: Parameters<typeof buildPipelineStep>[1]\n ): AnyStep<TOptions> {\n return buildPipelineStep(id, definition);\n }\n\n const buildRemoteStep = (\n id: string,\n config: {\n adapter: RemoteStepAdapter<object, unknown, unknown>;\n mapInput(inputs: Record<string, unknown>, context: PipelineStepContext<TOptions>): unknown;\n outputSchema: StandardSchemaV1;\n dependsOn?: readonly AnyStep<TOptions>[];\n optionalDependsOn?: readonly AnyStep<TOptions>[];\n skipAfterFailureOf?: readonly AnyStep<TOptions>[];\n name?: string;\n description?: string;\n dryRun?: \"skip\" | AnyStepDryRunHandler<TOptions>;\n skip?: StepSkipPredicate<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n unknown\n >;\n }\n ) => {\n const remote: NonNullable<PipelinePlanStep[\"remote\"]> = { engine: config.adapter.engine };\n if (config.adapter.target !== undefined) remote.target = config.adapter.target;\n const definition: StepDefinitionBody<TOptions> = {\n [STEP_REMOTE]: remote,\n dependsOn: config.dependsOn,\n optionalDependsOn: config.optionalDependsOn,\n skipAfterFailureOf: config.skipAfterFailureOf,\n name: config.name,\n description: config.description,\n dryRun: config.dryRun,\n outputSchema: config.outputSchema,\n run: (inputs: Record<string, unknown>, context: PipelineStepContext<TOptions>) =>\n config.adapter.invoke(config.mapInput(inputs, context), context),\n };\n const skip = config.skip;\n if (skip !== undefined) {\n definition.skip = skip;\n }\n return buildStep(id, definition);\n };\n\n function fromRemote<\n TId extends string,\n TSchema extends StandardSchemaV1,\n TPayload,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: RemoteStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TPayload, TSchema> & {\n skip?: never;\n }\n ): BuiltStep<TId, InferSchemaOutput<TSchema>, TOptions, TInputOptions, InferSchemaInput<TSchema>>;\n function fromRemote<\n TId extends string,\n TSchema extends StandardSchemaV1,\n TPayload,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TDecision extends StepSkipDecision<InferSchemaInput<TSchema>> = StepSkipDecision<\n InferSchemaInput<TSchema>\n >,\n >(\n id: TId,\n definition: RemoteStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TPayload, TSchema> & {\n skip:\n | StepSkipPredicate<TOptions, TDeps, TOptionalDeps, InferSchemaInput<TSchema>, TDecision>\n | undefined;\n }\n ): BuiltStep<\n TId,\n PolicySkippedOutput<InferSchemaOutput<TSchema>, TDecision>,\n TOptions,\n TInputOptions,\n InferSchemaInput<TSchema>\n >;\n function fromRemote(\n id: string,\n definition: Parameters<typeof buildRemoteStep>[1]\n ): AnyStep<TOptions> {\n return buildRemoteStep(id, definition);\n }\n\n const buildMappedPipelineStep = (\n id: string,\n config: MappedChildPipelineStepDefinition<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n Pipeline<object, unknown>,\n unknown\n > & {\n mapResult?: (\n value: unknown,\n result: PipelineRun<unknown>,\n item: unknown,\n index: number,\n context: PipelineStepContext<TOptions>\n ) => unknown;\n skip?: StepSkipPredicate<\n TOptions,\n readonly AnyStep<TOptions>[],\n readonly AnyStep<TOptions>[],\n unknown\n >;\n }\n ) => {\n const definition: StepDefinitionBody<TOptions> = {\n [STEP_NESTED_PIPELINE]: {\n mode: \"for-each\" as const,\n concurrency:\n typeof config.concurrency === \"function\" ? \"dynamic\" : (config.concurrency ?? 1),\n pipelineId: config.pipeline.id,\n identity: config.pipeline.definition?.identity,\n stepIds: config.pipeline.stepIds,\n },\n dependsOn: config.dependsOn,\n optionalDependsOn: config.optionalDependsOn,\n skipAfterFailureOf: config.skipAfterFailureOf,\n name: config.name,\n description: config.description,\n dryRun: config.dryRun,\n run: createMappedChildRunner(config),\n };\n\n const skip = config.skip;\n if (skip !== undefined) {\n definition.skip = skip;\n }\n return buildStep(id, definition);\n };\n\n function forEachPipeline<\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: MappedChildPipelineStepDefinition<\n TOptions,\n TDeps,\n TOptionalDeps,\n TChildPipeline,\n TItem\n > & {\n skip?: never;\n mapResult?: undefined;\n }\n ): BuiltStep<TId, readonly PipelineResultOf<TChildPipeline>[], TOptions, TInputOptions>;\n function forEachPipeline<\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n TOut,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: MappedChildPipelineStepDefinition<\n TOptions,\n TDeps,\n TOptionalDeps,\n TChildPipeline,\n TItem\n > & {\n skip?: never;\n mapResult(\n value: PipelineResultOf<TChildPipeline>,\n result: PipelineRun<PipelineResultOf<TChildPipeline>>,\n item: TItem,\n index: number,\n context: PipelineStepContext<TOptions>\n ): TOut;\n }\n ): BuiltStep<TId, readonly TOut[], TOptions, TInputOptions>;\n function forEachPipeline<\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TDecision extends StepSkipDecision<readonly PipelineResultOf<TChildPipeline>[]> =\n StepSkipDecision<readonly PipelineResultOf<TChildPipeline>[]>,\n >(\n id: TId,\n definition: MappedChildPipelineStepDefinition<\n TOptions,\n TDeps,\n TOptionalDeps,\n TChildPipeline,\n TItem\n > & {\n skip:\n | StepSkipPredicate<\n TOptions,\n TDeps,\n TOptionalDeps,\n readonly PipelineResultOf<TChildPipeline>[],\n TDecision\n >\n | undefined;\n mapResult?: undefined;\n }\n ): BuiltStep<\n TId,\n PolicySkippedOutput<readonly PipelineResultOf<TChildPipeline>[], TDecision>,\n TOptions,\n TInputOptions\n >;\n function forEachPipeline<\n TId extends string,\n TChildPipeline extends Pipeline<object, unknown>,\n TItem,\n TOut,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TDecision extends StepSkipDecision<NoInfer<readonly TOut[]>> = StepSkipDecision<\n NoInfer<readonly TOut[]>\n >,\n >(\n id: TId,\n definition: MappedChildPipelineStepDefinition<\n TOptions,\n TDeps,\n TOptionalDeps,\n TChildPipeline,\n TItem\n > & {\n skip:\n | StepSkipPredicate<TOptions, TDeps, TOptionalDeps, NoInfer<readonly TOut[]>, TDecision>\n | undefined;\n mapResult(\n value: PipelineResultOf<TChildPipeline>,\n result: PipelineRun<PipelineResultOf<TChildPipeline>>,\n item: TItem,\n index: number,\n context: PipelineStepContext<TOptions>\n ): TOut;\n }\n ): BuiltStep<TId, PolicySkippedOutput<readonly TOut[], TDecision>, TOptions, TInputOptions>;\n function forEachPipeline(\n id: string,\n definition: Parameters<typeof buildMappedPipelineStep>[1]\n ): AnyStep<TOptions> {\n return buildMappedPipelineStep(id, definition);\n }\n\n const factory = {\n step,\n fromPipeline,\n fromRemote,\n forEachPipeline,\n };\n\n return factory;\n}\n"]}
@@ -483,6 +483,15 @@ export interface PipelineMermaidOptions {
483
483
  /** Append each operational description to its node label. Defaults to false. */
484
484
  includeDescriptions?: boolean;
485
485
  }
486
+ type PipelineRunArguments<TOptions, TStepId extends string, TTargetId extends string> = {} extends TOptions ? [
487
+ options?: TOptions,
488
+ controls?: PipelineRunControls<TStepId, TTargetId>,
489
+ context?: Partial<PipelineContext>
490
+ ] : [
491
+ options: TOptions,
492
+ controls?: PipelineRunControls<TStepId, TTargetId>,
493
+ context?: Partial<PipelineContext>
494
+ ];
486
495
  /** Compiled pipeline that can be planned, executed, and rendered as a graph. */
487
496
  export interface Pipeline<TOptions extends object, TResult, TStepId extends string = string, TTargetId extends string = TStepId, TId extends string = string> {
488
497
  readonly id: TId;
@@ -499,13 +508,16 @@ export interface Pipeline<TOptions extends object, TResult, TStepId extends stri
499
508
  /** Stable declared goal ids that support dependency-aware target execution. */
500
509
  readonly targetIds: readonly TTargetId[];
501
510
  plan(controls?: PipelineRunControls<TStepId, TTargetId>): PipelinePlan;
511
+ /** Omitted options default to {} when the input type has no required fields. */
502
512
  run(options: TOptions, controls?: PipelineRunControls<TStepId, TTargetId>, context?: Partial<PipelineContext>): Promise<PipelineRun<TResult>>;
513
+ run(...args: PipelineRunArguments<TOptions, TStepId, TTargetId>): Promise<PipelineRun<TResult>>;
503
514
  runOrThrow(options: TOptions, controls?: PipelineRunControls<TStepId, TTargetId>, context?: Partial<PipelineContext>): Promise<TResult>;
515
+ runOrThrow(...args: PipelineRunArguments<TOptions, TStepId, TTargetId>): Promise<TResult>;
504
516
  /** Generate a static Mermaid flowchart without running or planning the pipeline. */
505
517
  toMermaid(options?: PipelineMermaidOptions): string;
506
518
  }
507
519
  /** Input accepted by a pipeline run before any options schema transformation. */
508
- export type PipelineInput<TPipeline extends Pipeline<object, unknown>> = Parameters<TPipeline["run"]>[0];
520
+ export type PipelineInput<TPipeline extends Pipeline<object, unknown>> = Exclude<Parameters<TPipeline["run"]>[0], undefined>;
509
521
  /** Successful result produced by a pipeline run. */
510
522
  export type PipelineResult<TPipeline extends Pipeline<object, unknown>> = Awaited<ReturnType<TPipeline["runOrThrow"]>>;
511
523
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline-types.js","sourceRoot":"","sources":["../../src/core/pipeline-types.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,oBAAoB,IAAI,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AA4JlG,yEAAyE;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;AAK9E,MAAM,oBAAoB,GAAwB,IAAI,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAEhF,qFAAqF;AACrF,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC;AA2UD,0DAA0D;AAC1D,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC","sourcesContent":["import type {\n PipelineDefinitionIdentityContract,\n PipelineDefinitionSnapshotContract,\n} from \"../tracing/tracing-schema.js\";\n\n/** Versioned graph identity, separate from the optional handler implementation version. */\nexport type PipelineDefinitionIdentity = Readonly<PipelineDefinitionIdentityContract>;\n/** Serializable compiled semantics; no handlers, inputs, or application imports. */\ntype ReadonlyDefinition<T> = T extends object\n ? { readonly [K in keyof T]: ReadonlyDefinition<T[K]> }\n : T;\n/** Immutable snapshot of the compiled pipeline definition recorded for inspection and tracing. */\nexport type PipelineDefinitionSnapshot = ReadonlyDefinition<PipelineDefinitionSnapshotContract>;\n\nimport type { RUN_MODEL_VERSION } from \"./pipeline-ids.js\";\nimport { PIPELINE_ERROR_CODES as PIPELINE_ERROR_CODE_VALUES } from \"../tracing/tracing-schema.js\";\nimport type {\n PipelineErrorKindContract,\n PipelineErrorPhaseContract,\n} from \"../tracing/tracing-schema.js\";\nimport type {\n PipelineTraceAttributes,\n PipelineTraceContext,\n PipelineTracingOptions,\n} from \"../tracing/tracing-contracts.js\";\n\n/** Minimal logger used by pipeline execution, reporters, and CLI adapters. */\nexport interface PipelineLogger {\n error(message?: unknown, ...optionalParams: unknown[]): void;\n log(message?: unknown, ...optionalParams: unknown[]): void;\n warn(message?: unknown, ...optionalParams: unknown[]): void;\n}\n\n/** Caller-supplied services and metadata shared by one pipeline execution. */\nexport interface PipelineContext {\n /** Optional caller-owned identifier used to correlate separate executions. */\n correlationId?: string;\n cwd: string;\n /** Hook sets run in order and failures are isolated per set. */\n hooks?: PipelineHooks | readonly PipelineHooks[];\n log: PipelineLogger;\n /** Timestamp source for persisted run records. Defaults to `Date.now`. */\n now?: () => number;\n /** Optional package-generated execution identity of this run's parent. */\n parentRunId?: string;\n signal?: AbortSignal;\n sleep?: (durationMs: number, signal?: AbortSignal) => Promise<void>;\n /** Optional structured lifecycle tracing configuration for this run. */\n tracing?: PipelineTracingOptions;\n}\n\n/** Built-in run controls. Choose targets or stepIds, or omit both to run every step. */\nexport type PipelineRunControls<\n TStepId extends string = string,\n TTargetId extends string = string,\n> = {\n /** Maximum simultaneous steps, including skip predicates and output validation. Defaults to 1. */\n maxConcurrency?: number;\n /** Continue eligible branches after failure; otherwise stop dispatch and drain active steps. */\n continueOnError?: boolean;\n dryRun?: boolean;\n} & (\n | {\n /**\n * Run only these steps, without adding prerequisites. Omit both stepIds and\n * targets to run every step. An empty array is invalid and fails planning.\n */\n stepIds?: readonly TStepId[];\n targets?: undefined;\n }\n | {\n stepIds?: undefined;\n /**\n * Run these declared targets and their required inputs and failure gates,\n * recursively; optional-only inputs are not included. Omit both targets\n * and stepIds to run every step; no target is selected automatically.\n */\n targets?: readonly TTargetId[];\n }\n);\n\n/** Resolved caller context. Core fills `now` and `sleep` before execution. */\nexport interface PipelineRuntime extends PipelineContext {\n now: () => number;\n sleep: (durationMs: number, signal?: AbortSignal) => Promise<void>;\n}\n\n/** Resolved execution context provided to pipeline handlers. */\nexport interface PipelineExecutionContext<TOptions extends object> extends PipelineRuntime {\n dryRun: boolean;\n options: TOptions;\n /** Stable identity for this execution, whether or not tracing is configured. */\n runId: string;\n /** Stable identities for this traced run; absent unless `context.tracing` is configured. */\n trace?: PipelineTraceContext;\n}\n\n/**\n * Lifecycle status displayed for an optional nested progress row.\n *\n * Detail rows are indented under a parent step's progress.\n * Domain-agnostic: mapped children, nested work units, per-file status, etc.\n */\nexport type PipelineStepProgressDetailStatus =\n | \"cancelled\"\n | \"completed\"\n | \"failed\"\n | \"pending\"\n | \"running\"\n | \"skipped\";\n\n/** One optional nested row in a step progress snapshot. */\nexport interface PipelineStepProgressDetail {\n /** Stable identity for the row (item key, path, job id, …). */\n id: string;\n /** Optional display name; identity remains `id`. */\n name?: string;\n /** Indentation relative to direct child rows (0). Rows are in tree preorder. */\n depth?: number;\n /** Inner work counts, independent of the parent's lifecycle count. */\n completed?: number;\n total?: number;\n /** Short status text shown after the id. */\n label?: string;\n /** Controls the detail row symbol. Defaults to `running`. */\n status?: PipelineStepProgressDetailStatus;\n}\n\n/** Latest progress snapshot reported by a running step. */\nexport interface PipelineStepProgress {\n /** Work completed so far. Values outside the reported total are allowed but renderers may clamp them. */\n completed: number;\n /** Total work when known. Omit for indeterminate progress. */\n total?: number;\n /** Optional short status shown next to the step. Prefer one-line summaries. */\n message?: string;\n /**\n * Optional multi-line detail rows for capable reporters (interactive TTY).\n * Keep the parent `message` as a summary; put per-item status here so high\n * concurrency does not collapse onto one truncated line.\n */\n details?: readonly PipelineStepProgressDetail[];\n}\n\n/** Step execution context with attempt identity and progress reporting helpers. */\nexport interface PipelineStepContext<\n TOptions extends object,\n> extends PipelineExecutionContext<TOptions> {\n /** Stable identity for this execution of the current step. */\n attemptId: string;\n /** Emit a retry/attempt trace event for this step when tracing is enabled. */\n reportAttempt(attempt: number, attributes?: PipelineTraceAttributes): void;\n /** Publish the latest progress snapshot for this step. */\n reportProgress(progress: PipelineStepProgress): void;\n}\n\n/** Adapter that invokes one step on an external execution engine. */\nexport interface RemoteStepAdapter<TOptions extends object, TPayload, TResult> {\n /** Presentation only. The kernel never switches on this. */\n readonly engine: string;\n /** Function name, workflow type, URL, queue. Presentation only. */\n readonly target?: string;\n invoke(payload: TPayload, context: PipelineStepContext<TOptions>): Promise<TResult>;\n}\n\n/** Pipeline lifecycle phase in which an error occurred. */\nexport type PipelineErrorPhase = PipelineErrorPhaseContract;\n\n/** Broad category of a structured pipeline error. */\nexport type PipelineErrorKind = PipelineErrorKindContract;\n\n/** Ordered catalog of every stable package-owned pipeline error code. */\nexport const PIPELINE_ERROR_CODES = Object.freeze(PIPELINE_ERROR_CODE_VALUES);\n\n/** Stable package-owned code for a pipeline error. */\nexport type PipelineErrorCode = (typeof PIPELINE_ERROR_CODES)[number];\n\nconst pipelineErrorCodeSet: ReadonlySet<string> = new Set(PIPELINE_ERROR_CODES);\n\n/** Return whether an unknown value is a stable package-owned pipeline error code. */\nexport function isPipelineErrorCode(value: unknown): value is PipelineErrorCode {\n return typeof value === \"string\" && pipelineErrorCodeSet.has(value);\n}\n\n/** One dependency-free Standard Schema issue normalized for reports and traces. */\nexport interface PipelineValidationIssue {\n message: string;\n path?: readonly (number | string)[];\n}\n\n/** Bounded diagnostics for a failed or cancelled runtime fan-out. */\nexport interface PipelineFanOutFailure {\n /** Original input position, including when the key is truncated. */\n index: number;\n /** At most 1024 UTF-16 code units; do not rerun by key when keyTruncated is true. */\n key: string;\n keyTruncated: boolean;\n cancelled: boolean;\n error: PipelineErrorCause;\n}\n\n/** Bounded diagnostics collected from a failed or cancelled fan-out step. */\nexport interface PipelineFanOutDiagnostics {\n /** Failed started items, in input order; at most 32 entries. */\n failures: readonly PipelineFanOutFailure[];\n /** Total failed started items, including omitted diagnostics. */\n failureCount: number;\n omittedFailureCount: number;\n /** Scheduler failure is separate and never assigned an item key. */\n schedulerError?: PipelineErrorCause;\n}\n\n/** Structured, machine-readable error stored in plans, runs, and traces. */\nexport interface PipelineError {\n /** Present for aggregated fan-out failures; absent for setup errors. */\n fanOut?: PipelineFanOutDiagnostics;\n /** Bounded, JSON-safe snapshot of the thrown error's cause chain. */\n cause?: PipelineErrorCause;\n code: PipelineErrorCode;\n kind: PipelineErrorKind;\n message: string;\n phase: PipelineErrorPhase;\n /** Present when a Standard Schema rejected a boundary value. */\n issues?: readonly PipelineValidationIssue[];\n stepId?: string;\n /** Machine-readable code copied from the original thrown error, when present. */\n sourceCode?: string;\n stack?: string;\n}\n\n/** Dependency-free subset of the Standard Schema V1 protocol. */\nexport interface StandardSchemaV1<TInput = unknown, TOutput = TInput> {\n readonly \"~standard\": StandardSchemaV1Props<TInput, TOutput>;\n}\n\n/** Standard Schema V1 metadata and validation contract consumed by Tubeless. */\ninterface StandardSchemaV1Props<TInput = unknown, TOutput = TInput> {\n /** Optional Standard JSON Schema input converter, used to infer CLI flags. */\n readonly jsonSchema?: {\n readonly input: (options: { readonly target: \"draft-2020-12\" }) => Record<string, unknown>;\n };\n readonly types?: { readonly input: TInput; readonly output: TOutput };\n readonly validate: (\n value: unknown,\n options?: { readonly libraryOptions?: Record<string, unknown> }\n ) => StandardSchemaV1Result<TOutput> | Promise<StandardSchemaV1Result<TOutput>>;\n readonly vendor: string;\n readonly version: 1;\n}\n\n/** Successful value or validation issues returned by a Standard Schema V1 validator. */\nexport type StandardSchemaV1Result<TOutput> =\n | { readonly issues?: undefined; readonly value: TOutput }\n | { readonly issues: readonly StandardSchemaV1Issue[] };\n\n/** Validation issue shape accepted from a Standard Schema V1 validator. */\nexport interface StandardSchemaV1Issue {\n readonly message: string;\n readonly path?: readonly (PropertyKey | { readonly key: PropertyKey })[];\n}\n\n/** Infer the accepted input type from a Standard Schema without importing its package. */\nexport type InferSchemaInput<TSchema extends StandardSchemaV1> = NonNullable<\n TSchema[\"~standard\"][\"types\"]\n>[\"input\"];\n\n/** Infer the validated output type from a Standard Schema without importing its package. */\nexport type InferSchemaOutput<TSchema extends StandardSchemaV1> = NonNullable<\n TSchema[\"~standard\"][\"types\"]\n>[\"output\"];\n\n/** Bounded JSON-safe snapshot of a thrown value and its cause chain. */\nexport interface PipelineErrorCause {\n cause?: PipelineErrorCause;\n message: string;\n name?: string;\n /** Machine-readable code copied from this cause, when present. */\n sourceCode?: string;\n}\n\ninterface PipelineStepReportBase {\n /** Present when the step started an execution attempt. */\n attemptId?: string;\n id: string;\n /** Optional human-facing display name. Stable machine identity remains `id`. */\n name?: string;\n description?: string;\n /** Wall-clock time when this terminal report was recorded. */\n finishedAtMs: number;\n /** Wall-clock time when execution began; absent when the step never started. */\n startedAtMs?: number;\n}\n\n/** Terminal report for a successfully completed step. */\nexport interface PipelineStepCompleteReport extends PipelineStepReportBase {\n attemptId: string;\n startedAtMs: number;\n status: \"completed\";\n}\n\n/** Terminal report for a structurally or intentionally skipped step. */\nexport interface PipelineStepSkippedReport extends PipelineStepReportBase {\n /** Dependency that blocked this step, when applicable. */\n dependencyId?: string;\n /** Human-readable skip detail, especially for policy and fail-fast skips. */\n message?: string;\n reason: PipelineStepSkipReason;\n status: \"skipped\";\n}\n\n/** Terminal report for a cancelled step. */\nexport interface PipelineStepCancelledReport extends PipelineStepReportBase {\n error: PipelineError;\n status: \"cancelled\";\n}\n\n/** Terminal report for a failed step. */\nexport interface PipelineStepFailedReport extends PipelineStepReportBase {\n attemptId: string;\n error: PipelineError;\n startedAtMs: number;\n status: \"failed\";\n}\n\n/** Terminal state recorded for one step after a run. */\nexport type PipelineStepReport =\n | PipelineStepCancelledReport\n | PipelineStepFailedReport\n | PipelineStepSkippedReport\n | PipelineStepCompleteReport;\n\n/** Terminal status recorded in a step report. */\nexport type PipelineStepReportStatus = PipelineStepReport[\"status\"];\n\n/** Terminal disposition of a completed run record. */\nexport type PipelineRunStatus = \"cancelled\" | \"completed\" | \"failed\";\n\ninterface PipelineRunRecord {\n definitionIdentity?: PipelineDefinitionIdentity;\n /** Caller-owned identifier shared by related executions, when supplied. */\n correlationId?: string;\n pipelineId: string;\n dryRun: boolean;\n /** Run-level errors first, step errors in plan order, then finalization errors. */\n errors: PipelineError[];\n finishedAtMs: number;\n parentRunId?: string;\n runId: string;\n startedAtMs: number;\n status: PipelineRunStatus;\n /** Terminal step reports in stable plan order, independent of completion order. */\n steps: PipelineStepReport[];\n version: typeof RUN_MODEL_VERSION;\n}\n\n/** Versioned public record returned for one pipeline execution. */\nexport type PipelineRun<TResult = unknown> =\n | (PipelineRunRecord & {\n /** Finalization did not produce a result. Independent of terminal run status. */\n finalized: false;\n value?: undefined;\n })\n | (PipelineRunRecord & {\n /** Finalization produced a result. Independent of terminal run status. */\n finalized: true;\n value: TResult;\n });\n\n/**\n * Why a step did not run. Built-in structural reasons keep dependency semantics;\n * `\"policy\"` is an intentional skip from `step.skip()` (still unlocks dependents).\n */\nexport type PipelineStepSkipReason =\n | \"dry-run\"\n | \"failed-dependency\"\n | \"fail-fast\"\n | \"filtered\"\n | \"policy\"\n | \"unmet-dependency\";\n\n/**\n * Decision from an optional `skip` predicate.\n * - falsy / `false` → run the step\n * - non-empty string → skip with that message (`reason: \"policy\"`); the step's\n * published output is `undefined`\n * - `{ reason, value? }` → skip and optionally publish `value` for dependents\n * (`value` may be intentionally `undefined` if passed explicitly)\n *\n * Policy skips unlock required dependents. A bare-string skip (or a `{ reason }`\n * without `value`) makes dependents see `TOut | undefined`. When every skip\n * branch returns `{ reason, value }`, the step retains `TOut`; schema-backed\n * values use the schema input type and publish its transformed output type.\n */\nexport type StepSkipDecision<TOut = unknown> =\n | false\n | null\n | undefined\n | string\n | { reason: string; value?: TOut };\n\n/** One observable status in a step's planned → running → terminal lifecycle. */\nexport type PipelineStepStatus =\n | { pipelineId: string; status: \"planned\"; step: PipelinePlanStep }\n | {\n attemptId: string;\n pipelineId: string;\n progress?: PipelineStepProgress;\n status: \"running\";\n step: PipelinePlanStep;\n }\n | ({ pipelineId: string; step: PipelinePlanStep } & PipelineStepCancelledReport)\n | ({ pipelineId: string; step: PipelinePlanStep } & PipelineStepFailedReport)\n | ({ pipelineId: string; step: PipelinePlanStep } & PipelineStepSkippedReport)\n | ({ pipelineId: string; step: PipelinePlanStep } & PipelineStepCompleteReport);\n\n/** Any planned, running, or terminal step lifecycle status. */\nexport type PipelineStepLifecycleStatus = PipelineStepStatus[\"status\"];\n\n/** Lifecycle event emitted when a step is planned. */\nexport type PipelineStepPlannedEvent = Extract<PipelineStepStatus, { status: \"planned\" }>;\ntype PipelineStepRunningStatus = Extract<PipelineStepStatus, { status: \"running\" }>;\n/** Lifecycle event emitted when a step begins running. */\nexport type PipelineStepStartEvent = Omit<PipelineStepRunningStatus, \"progress\"> & {\n progress?: undefined;\n};\n/** Lifecycle event emitted when a running step reports progress. */\nexport type PipelineStepProgressEvent = Omit<PipelineStepRunningStatus, \"progress\"> & {\n progress: PipelineStepProgress;\n};\n/** Lifecycle event emitted when a step is cancelled. */\nexport type PipelineStepCancelledEvent = Extract<PipelineStepStatus, { status: \"cancelled\" }>;\n/** Lifecycle event emitted when a step fails. */\nexport type PipelineStepFailedEvent = Extract<PipelineStepStatus, { status: \"failed\" }>;\n/** Lifecycle event emitted when a step is skipped. */\nexport type PipelineStepSkippedEvent = Extract<PipelineStepStatus, { status: \"skipped\" }>;\n/** Lifecycle event emitted when a step completes successfully. */\nexport type PipelineStepCompleteEvent = Extract<PipelineStepStatus, { status: \"completed\" }>;\n\n/**\n * Optional lifecycle callbacks, each receiving its own metadata snapshot.\n * Domain result values retain their identity; hooks must treat them as read-only.\n */\nexport interface PipelineHooks<TResult = unknown> {\n onFinalizeComplete?(event: { durationMs: number; pipelineId: string; value: TResult }): void;\n onFinalizeError?(event: { durationMs: number; error: PipelineError; pipelineId: string }): void;\n onFinalizeStart?(event: { pipelineId: string }): void;\n onPipelineComplete?(event: PipelineRun<TResult>): void;\n onPipelineStart?(event: PipelinePlan): void;\n onStepCancel?(event: PipelineStepCancelledEvent): void;\n onStepFail?(event: PipelineStepFailedEvent): void;\n onStepPlan?(event: PipelineStepPlannedEvent): void;\n onStepProgress?(event: PipelineStepProgressEvent): void;\n onStepSkip?(event: PipelineStepSkippedEvent): void;\n onStepStart?(event: PipelineStepStartEvent): void;\n onStepStatus?(event: PipelineStepStatus): void;\n onStepComplete?(event: PipelineStepCompleteEvent): void;\n}\n\n/** Machine-readable explanation of why a planned step was included or omitted. */\nexport type PipelineStepSelectionReason =\n | { kind: \"all\" }\n | { kind: \"exact\" }\n | { kind: \"target\"; targetId: string }\n | { dependentId: string; kind: \"required-dependency\"; targetId: string }\n | { dependentId: string; kind: \"failure-gate\"; targetId: string }\n | { dependentId: string; kind: \"optional-only\"; targetId: string }\n | { kind: \"outside-target-closure\" }\n | { kind: \"not-selected\" };\n\n/** Planned representation of one declared step and its selection state. */\nexport interface PipelinePlanStep {\n dependencies: string[];\n description?: string;\n /** How this step behaves when the pipeline is run with `dryRun: true`. */\n dryRun: \"custom\" | \"run\" | \"skip\";\n id: string;\n /** Optional human-facing display name. Stable machine identity remains `id`. */\n name?: string;\n /** Static child structure when this opaque step executes another pipeline. */\n nestedPipeline?: {\n /** One child execution or one child execution per runtime item. */\n mode: \"single\" | \"for-each\";\n identity?: PipelineDefinitionIdentity;\n concurrency?: number | \"dynamic\";\n pipelineId: string;\n /** All declared child step ids; runtime selection may execute only a subset. */\n stepIds: readonly string[];\n };\n /** Static remote adapter metadata when this opaque step calls an external engine. */\n remote?: {\n engine: string;\n target?: string;\n };\n optionalDependencies: string[];\n /** True when the step's runtime policy may elect not to run it. */\n runtimeSkipPossible: boolean;\n selected: boolean;\n /** Stable reasons for selection or omission; shared prerequisites can have several. */\n selectionReasons: readonly PipelineStepSelectionReason[];\n skipAfterFailureOf: string[];\n skipReason?: PipelineStepSkipReason;\n}\n\n/** Side-effect-free validation and selection result for a pipeline run. */\nexport interface PipelinePlan {\n definition?: PipelineDefinitionSnapshot;\n dryRun: boolean;\n errors: PipelineError[];\n ok: boolean;\n pipelineId: string;\n steps: PipelinePlanStep[];\n}\n\n/** Layout directions for generated Mermaid flowcharts. */\nexport const PIPELINE_MERMAID_DIRECTIONS = [\"BT\", \"LR\", \"RL\", \"TB\", \"TD\"] as const;\n/** Supported Mermaid flowchart direction. */\nexport type PipelineMermaidDirection = (typeof PIPELINE_MERMAID_DIRECTIONS)[number];\n\n/** Rendering options for a pipeline Mermaid flowchart. */\nexport interface PipelineMermaidOptions {\n /** Mermaid flowchart direction. Defaults to top-down (`TD`). */\n direction?: PipelineMermaidDirection;\n /** Append each operational description to its node label. Defaults to false. */\n includeDescriptions?: boolean;\n}\n\n/** Compiled pipeline that can be planned, executed, and rendered as a graph. */\nexport interface Pipeline<\n TOptions extends object,\n TResult,\n TStepId extends string = string,\n TTargetId extends string = TStepId,\n TId extends string = string,\n> {\n readonly id: TId;\n /** Optional display name; stable identity remains `id`. */\n readonly name?: string;\n /** Human-readable purpose for command and discovery surfaces. */\n readonly description?: string;\n /** Compiled definition metadata. Absent only on externally implemented pipelines. */\n readonly definition?: PipelineDefinitionSnapshot;\n /** Runtime domain schema supplied to createSteps; CLI adapters can infer its input flags. */\n readonly optionsSchema?: StandardSchemaV1;\n /** Stable definition-order step ids for discovery surfaces such as CLI help. */\n readonly stepIds: readonly TStepId[];\n /** Stable declared goal ids that support dependency-aware target execution. */\n readonly targetIds: readonly TTargetId[];\n plan(controls?: PipelineRunControls<TStepId, TTargetId>): PipelinePlan;\n run(\n options: TOptions,\n controls?: PipelineRunControls<TStepId, TTargetId>,\n context?: Partial<PipelineContext>\n ): Promise<PipelineRun<TResult>>;\n runOrThrow(\n options: TOptions,\n controls?: PipelineRunControls<TStepId, TTargetId>,\n context?: Partial<PipelineContext>\n ): Promise<TResult>;\n /** Generate a static Mermaid flowchart without running or planning the pipeline. */\n toMermaid(options?: PipelineMermaidOptions): string;\n}\n\n/** Input accepted by a pipeline run before any options schema transformation. */\nexport type PipelineInput<TPipeline extends Pipeline<object, unknown>> = Parameters<\n TPipeline[\"run\"]\n>[0];\n\n/** Successful result produced by a pipeline run. */\nexport type PipelineResult<TPipeline extends Pipeline<object, unknown>> = Awaited<\n ReturnType<TPipeline[\"runOrThrow\"]>\n>;\n"]}
1
+ {"version":3,"file":"pipeline-types.js","sourceRoot":"","sources":["../../src/core/pipeline-types.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,oBAAoB,IAAI,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AA4JlG,yEAAyE;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;AAK9E,MAAM,oBAAoB,GAAwB,IAAI,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAEhF,qFAAqF;AACrF,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC;AA2UD,0DAA0D;AAC1D,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC","sourcesContent":["import type {\n PipelineDefinitionIdentityContract,\n PipelineDefinitionSnapshotContract,\n} from \"../tracing/tracing-schema.js\";\n\n/** Versioned graph identity, separate from the optional handler implementation version. */\nexport type PipelineDefinitionIdentity = Readonly<PipelineDefinitionIdentityContract>;\n/** Serializable compiled semantics; no handlers, inputs, or application imports. */\ntype ReadonlyDefinition<T> = T extends object\n ? { readonly [K in keyof T]: ReadonlyDefinition<T[K]> }\n : T;\n/** Immutable snapshot of the compiled pipeline definition recorded for inspection and tracing. */\nexport type PipelineDefinitionSnapshot = ReadonlyDefinition<PipelineDefinitionSnapshotContract>;\n\nimport type { RUN_MODEL_VERSION } from \"./pipeline-ids.js\";\nimport { PIPELINE_ERROR_CODES as PIPELINE_ERROR_CODE_VALUES } from \"../tracing/tracing-schema.js\";\nimport type {\n PipelineErrorKindContract,\n PipelineErrorPhaseContract,\n} from \"../tracing/tracing-schema.js\";\nimport type {\n PipelineTraceAttributes,\n PipelineTraceContext,\n PipelineTracingOptions,\n} from \"../tracing/tracing-contracts.js\";\n\n/** Minimal logger used by pipeline execution, reporters, and CLI adapters. */\nexport interface PipelineLogger {\n error(message?: unknown, ...optionalParams: unknown[]): void;\n log(message?: unknown, ...optionalParams: unknown[]): void;\n warn(message?: unknown, ...optionalParams: unknown[]): void;\n}\n\n/** Caller-supplied services and metadata shared by one pipeline execution. */\nexport interface PipelineContext {\n /** Optional caller-owned identifier used to correlate separate executions. */\n correlationId?: string;\n cwd: string;\n /** Hook sets run in order and failures are isolated per set. */\n hooks?: PipelineHooks | readonly PipelineHooks[];\n log: PipelineLogger;\n /** Timestamp source for persisted run records. Defaults to `Date.now`. */\n now?: () => number;\n /** Optional package-generated execution identity of this run's parent. */\n parentRunId?: string;\n signal?: AbortSignal;\n sleep?: (durationMs: number, signal?: AbortSignal) => Promise<void>;\n /** Optional structured lifecycle tracing configuration for this run. */\n tracing?: PipelineTracingOptions;\n}\n\n/** Built-in run controls. Choose targets or stepIds, or omit both to run every step. */\nexport type PipelineRunControls<\n TStepId extends string = string,\n TTargetId extends string = string,\n> = {\n /** Maximum simultaneous steps, including skip predicates and output validation. Defaults to 1. */\n maxConcurrency?: number;\n /** Continue eligible branches after failure; otherwise stop dispatch and drain active steps. */\n continueOnError?: boolean;\n dryRun?: boolean;\n} & (\n | {\n /**\n * Run only these steps, without adding prerequisites. Omit both stepIds and\n * targets to run every step. An empty array is invalid and fails planning.\n */\n stepIds?: readonly TStepId[];\n targets?: undefined;\n }\n | {\n stepIds?: undefined;\n /**\n * Run these declared targets and their required inputs and failure gates,\n * recursively; optional-only inputs are not included. Omit both targets\n * and stepIds to run every step; no target is selected automatically.\n */\n targets?: readonly TTargetId[];\n }\n);\n\n/** Resolved caller context. Core fills `now` and `sleep` before execution. */\nexport interface PipelineRuntime extends PipelineContext {\n now: () => number;\n sleep: (durationMs: number, signal?: AbortSignal) => Promise<void>;\n}\n\n/** Resolved execution context provided to pipeline handlers. */\nexport interface PipelineExecutionContext<TOptions extends object> extends PipelineRuntime {\n dryRun: boolean;\n options: TOptions;\n /** Stable identity for this execution, whether or not tracing is configured. */\n runId: string;\n /** Stable identities for this traced run; absent unless `context.tracing` is configured. */\n trace?: PipelineTraceContext;\n}\n\n/**\n * Lifecycle status displayed for an optional nested progress row.\n *\n * Detail rows are indented under a parent step's progress.\n * Domain-agnostic: mapped children, nested work units, per-file status, etc.\n */\nexport type PipelineStepProgressDetailStatus =\n | \"cancelled\"\n | \"completed\"\n | \"failed\"\n | \"pending\"\n | \"running\"\n | \"skipped\";\n\n/** One optional nested row in a step progress snapshot. */\nexport interface PipelineStepProgressDetail {\n /** Stable identity for the row (item key, path, job id, …). */\n id: string;\n /** Optional display name; identity remains `id`. */\n name?: string;\n /** Indentation relative to direct child rows (0). Rows are in tree preorder. */\n depth?: number;\n /** Inner work counts, independent of the parent's lifecycle count. */\n completed?: number;\n total?: number;\n /** Short status text shown after the id. */\n label?: string;\n /** Controls the detail row symbol. Defaults to `running`. */\n status?: PipelineStepProgressDetailStatus;\n}\n\n/** Latest progress snapshot reported by a running step. */\nexport interface PipelineStepProgress {\n /** Work completed so far. Values outside the reported total are allowed but renderers may clamp them. */\n completed: number;\n /** Total work when known. Omit for indeterminate progress. */\n total?: number;\n /** Optional short status shown next to the step. Prefer one-line summaries. */\n message?: string;\n /**\n * Optional multi-line detail rows for capable reporters (interactive TTY).\n * Keep the parent `message` as a summary; put per-item status here so high\n * concurrency does not collapse onto one truncated line.\n */\n details?: readonly PipelineStepProgressDetail[];\n}\n\n/** Step execution context with attempt identity and progress reporting helpers. */\nexport interface PipelineStepContext<\n TOptions extends object,\n> extends PipelineExecutionContext<TOptions> {\n /** Stable identity for this execution of the current step. */\n attemptId: string;\n /** Emit a retry/attempt trace event for this step when tracing is enabled. */\n reportAttempt(attempt: number, attributes?: PipelineTraceAttributes): void;\n /** Publish the latest progress snapshot for this step. */\n reportProgress(progress: PipelineStepProgress): void;\n}\n\n/** Adapter that invokes one step on an external execution engine. */\nexport interface RemoteStepAdapter<TOptions extends object, TPayload, TResult> {\n /** Presentation only. The kernel never switches on this. */\n readonly engine: string;\n /** Function name, workflow type, URL, queue. Presentation only. */\n readonly target?: string;\n invoke(payload: TPayload, context: PipelineStepContext<TOptions>): Promise<TResult>;\n}\n\n/** Pipeline lifecycle phase in which an error occurred. */\nexport type PipelineErrorPhase = PipelineErrorPhaseContract;\n\n/** Broad category of a structured pipeline error. */\nexport type PipelineErrorKind = PipelineErrorKindContract;\n\n/** Ordered catalog of every stable package-owned pipeline error code. */\nexport const PIPELINE_ERROR_CODES = Object.freeze(PIPELINE_ERROR_CODE_VALUES);\n\n/** Stable package-owned code for a pipeline error. */\nexport type PipelineErrorCode = (typeof PIPELINE_ERROR_CODES)[number];\n\nconst pipelineErrorCodeSet: ReadonlySet<string> = new Set(PIPELINE_ERROR_CODES);\n\n/** Return whether an unknown value is a stable package-owned pipeline error code. */\nexport function isPipelineErrorCode(value: unknown): value is PipelineErrorCode {\n return typeof value === \"string\" && pipelineErrorCodeSet.has(value);\n}\n\n/** One dependency-free Standard Schema issue normalized for reports and traces. */\nexport interface PipelineValidationIssue {\n message: string;\n path?: readonly (number | string)[];\n}\n\n/** Bounded diagnostics for a failed or cancelled runtime fan-out. */\nexport interface PipelineFanOutFailure {\n /** Original input position, including when the key is truncated. */\n index: number;\n /** At most 1024 UTF-16 code units; do not rerun by key when keyTruncated is true. */\n key: string;\n keyTruncated: boolean;\n cancelled: boolean;\n error: PipelineErrorCause;\n}\n\n/** Bounded diagnostics collected from a failed or cancelled fan-out step. */\nexport interface PipelineFanOutDiagnostics {\n /** Failed started items, in input order; at most 32 entries. */\n failures: readonly PipelineFanOutFailure[];\n /** Total failed started items, including omitted diagnostics. */\n failureCount: number;\n omittedFailureCount: number;\n /** Scheduler failure is separate and never assigned an item key. */\n schedulerError?: PipelineErrorCause;\n}\n\n/** Structured, machine-readable error stored in plans, runs, and traces. */\nexport interface PipelineError {\n /** Present for aggregated fan-out failures; absent for setup errors. */\n fanOut?: PipelineFanOutDiagnostics;\n /** Bounded, JSON-safe snapshot of the thrown error's cause chain. */\n cause?: PipelineErrorCause;\n code: PipelineErrorCode;\n kind: PipelineErrorKind;\n message: string;\n phase: PipelineErrorPhase;\n /** Present when a Standard Schema rejected a boundary value. */\n issues?: readonly PipelineValidationIssue[];\n stepId?: string;\n /** Machine-readable code copied from the original thrown error, when present. */\n sourceCode?: string;\n stack?: string;\n}\n\n/** Dependency-free subset of the Standard Schema V1 protocol. */\nexport interface StandardSchemaV1<TInput = unknown, TOutput = TInput> {\n readonly \"~standard\": StandardSchemaV1Props<TInput, TOutput>;\n}\n\n/** Standard Schema V1 metadata and validation contract consumed by Tubeless. */\ninterface StandardSchemaV1Props<TInput = unknown, TOutput = TInput> {\n /** Optional Standard JSON Schema input converter, used to infer CLI flags. */\n readonly jsonSchema?: {\n readonly input: (options: { readonly target: \"draft-2020-12\" }) => Record<string, unknown>;\n };\n readonly types?: { readonly input: TInput; readonly output: TOutput };\n readonly validate: (\n value: unknown,\n options?: { readonly libraryOptions?: Record<string, unknown> }\n ) => StandardSchemaV1Result<TOutput> | Promise<StandardSchemaV1Result<TOutput>>;\n readonly vendor: string;\n readonly version: 1;\n}\n\n/** Successful value or validation issues returned by a Standard Schema V1 validator. */\nexport type StandardSchemaV1Result<TOutput> =\n | { readonly issues?: undefined; readonly value: TOutput }\n | { readonly issues: readonly StandardSchemaV1Issue[] };\n\n/** Validation issue shape accepted from a Standard Schema V1 validator. */\nexport interface StandardSchemaV1Issue {\n readonly message: string;\n readonly path?: readonly (PropertyKey | { readonly key: PropertyKey })[];\n}\n\n/** Infer the accepted input type from a Standard Schema without importing its package. */\nexport type InferSchemaInput<TSchema extends StandardSchemaV1> = NonNullable<\n TSchema[\"~standard\"][\"types\"]\n>[\"input\"];\n\n/** Infer the validated output type from a Standard Schema without importing its package. */\nexport type InferSchemaOutput<TSchema extends StandardSchemaV1> = NonNullable<\n TSchema[\"~standard\"][\"types\"]\n>[\"output\"];\n\n/** Bounded JSON-safe snapshot of a thrown value and its cause chain. */\nexport interface PipelineErrorCause {\n cause?: PipelineErrorCause;\n message: string;\n name?: string;\n /** Machine-readable code copied from this cause, when present. */\n sourceCode?: string;\n}\n\ninterface PipelineStepReportBase {\n /** Present when the step started an execution attempt. */\n attemptId?: string;\n id: string;\n /** Optional human-facing display name. Stable machine identity remains `id`. */\n name?: string;\n description?: string;\n /** Wall-clock time when this terminal report was recorded. */\n finishedAtMs: number;\n /** Wall-clock time when execution began; absent when the step never started. */\n startedAtMs?: number;\n}\n\n/** Terminal report for a successfully completed step. */\nexport interface PipelineStepCompleteReport extends PipelineStepReportBase {\n attemptId: string;\n startedAtMs: number;\n status: \"completed\";\n}\n\n/** Terminal report for a structurally or intentionally skipped step. */\nexport interface PipelineStepSkippedReport extends PipelineStepReportBase {\n /** Dependency that blocked this step, when applicable. */\n dependencyId?: string;\n /** Human-readable skip detail, especially for policy and fail-fast skips. */\n message?: string;\n reason: PipelineStepSkipReason;\n status: \"skipped\";\n}\n\n/** Terminal report for a cancelled step. */\nexport interface PipelineStepCancelledReport extends PipelineStepReportBase {\n error: PipelineError;\n status: \"cancelled\";\n}\n\n/** Terminal report for a failed step. */\nexport interface PipelineStepFailedReport extends PipelineStepReportBase {\n attemptId: string;\n error: PipelineError;\n startedAtMs: number;\n status: \"failed\";\n}\n\n/** Terminal state recorded for one step after a run. */\nexport type PipelineStepReport =\n | PipelineStepCancelledReport\n | PipelineStepFailedReport\n | PipelineStepSkippedReport\n | PipelineStepCompleteReport;\n\n/** Terminal status recorded in a step report. */\nexport type PipelineStepReportStatus = PipelineStepReport[\"status\"];\n\n/** Terminal disposition of a completed run record. */\nexport type PipelineRunStatus = \"cancelled\" | \"completed\" | \"failed\";\n\ninterface PipelineRunRecord {\n definitionIdentity?: PipelineDefinitionIdentity;\n /** Caller-owned identifier shared by related executions, when supplied. */\n correlationId?: string;\n pipelineId: string;\n dryRun: boolean;\n /** Run-level errors first, step errors in plan order, then finalization errors. */\n errors: PipelineError[];\n finishedAtMs: number;\n parentRunId?: string;\n runId: string;\n startedAtMs: number;\n status: PipelineRunStatus;\n /** Terminal step reports in stable plan order, independent of completion order. */\n steps: PipelineStepReport[];\n version: typeof RUN_MODEL_VERSION;\n}\n\n/** Versioned public record returned for one pipeline execution. */\nexport type PipelineRun<TResult = unknown> =\n | (PipelineRunRecord & {\n /** Finalization did not produce a result. Independent of terminal run status. */\n finalized: false;\n value?: undefined;\n })\n | (PipelineRunRecord & {\n /** Finalization produced a result. Independent of terminal run status. */\n finalized: true;\n value: TResult;\n });\n\n/**\n * Why a step did not run. Built-in structural reasons keep dependency semantics;\n * `\"policy\"` is an intentional skip from `step.skip()` (still unlocks dependents).\n */\nexport type PipelineStepSkipReason =\n | \"dry-run\"\n | \"failed-dependency\"\n | \"fail-fast\"\n | \"filtered\"\n | \"policy\"\n | \"unmet-dependency\";\n\n/**\n * Decision from an optional `skip` predicate.\n * - falsy / `false` → run the step\n * - non-empty string → skip with that message (`reason: \"policy\"`); the step's\n * published output is `undefined`\n * - `{ reason, value? }` → skip and optionally publish `value` for dependents\n * (`value` may be intentionally `undefined` if passed explicitly)\n *\n * Policy skips unlock required dependents. A bare-string skip (or a `{ reason }`\n * without `value`) makes dependents see `TOut | undefined`. When every skip\n * branch returns `{ reason, value }`, the step retains `TOut`; schema-backed\n * values use the schema input type and publish its transformed output type.\n */\nexport type StepSkipDecision<TOut = unknown> =\n | false\n | null\n | undefined\n | string\n | { reason: string; value?: TOut };\n\n/** One observable status in a step's planned → running → terminal lifecycle. */\nexport type PipelineStepStatus =\n | { pipelineId: string; status: \"planned\"; step: PipelinePlanStep }\n | {\n attemptId: string;\n pipelineId: string;\n progress?: PipelineStepProgress;\n status: \"running\";\n step: PipelinePlanStep;\n }\n | ({ pipelineId: string; step: PipelinePlanStep } & PipelineStepCancelledReport)\n | ({ pipelineId: string; step: PipelinePlanStep } & PipelineStepFailedReport)\n | ({ pipelineId: string; step: PipelinePlanStep } & PipelineStepSkippedReport)\n | ({ pipelineId: string; step: PipelinePlanStep } & PipelineStepCompleteReport);\n\n/** Any planned, running, or terminal step lifecycle status. */\nexport type PipelineStepLifecycleStatus = PipelineStepStatus[\"status\"];\n\n/** Lifecycle event emitted when a step is planned. */\nexport type PipelineStepPlannedEvent = Extract<PipelineStepStatus, { status: \"planned\" }>;\ntype PipelineStepRunningStatus = Extract<PipelineStepStatus, { status: \"running\" }>;\n/** Lifecycle event emitted when a step begins running. */\nexport type PipelineStepStartEvent = Omit<PipelineStepRunningStatus, \"progress\"> & {\n progress?: undefined;\n};\n/** Lifecycle event emitted when a running step reports progress. */\nexport type PipelineStepProgressEvent = Omit<PipelineStepRunningStatus, \"progress\"> & {\n progress: PipelineStepProgress;\n};\n/** Lifecycle event emitted when a step is cancelled. */\nexport type PipelineStepCancelledEvent = Extract<PipelineStepStatus, { status: \"cancelled\" }>;\n/** Lifecycle event emitted when a step fails. */\nexport type PipelineStepFailedEvent = Extract<PipelineStepStatus, { status: \"failed\" }>;\n/** Lifecycle event emitted when a step is skipped. */\nexport type PipelineStepSkippedEvent = Extract<PipelineStepStatus, { status: \"skipped\" }>;\n/** Lifecycle event emitted when a step completes successfully. */\nexport type PipelineStepCompleteEvent = Extract<PipelineStepStatus, { status: \"completed\" }>;\n\n/**\n * Optional lifecycle callbacks, each receiving its own metadata snapshot.\n * Domain result values retain their identity; hooks must treat them as read-only.\n */\nexport interface PipelineHooks<TResult = unknown> {\n onFinalizeComplete?(event: { durationMs: number; pipelineId: string; value: TResult }): void;\n onFinalizeError?(event: { durationMs: number; error: PipelineError; pipelineId: string }): void;\n onFinalizeStart?(event: { pipelineId: string }): void;\n onPipelineComplete?(event: PipelineRun<TResult>): void;\n onPipelineStart?(event: PipelinePlan): void;\n onStepCancel?(event: PipelineStepCancelledEvent): void;\n onStepFail?(event: PipelineStepFailedEvent): void;\n onStepPlan?(event: PipelineStepPlannedEvent): void;\n onStepProgress?(event: PipelineStepProgressEvent): void;\n onStepSkip?(event: PipelineStepSkippedEvent): void;\n onStepStart?(event: PipelineStepStartEvent): void;\n onStepStatus?(event: PipelineStepStatus): void;\n onStepComplete?(event: PipelineStepCompleteEvent): void;\n}\n\n/** Machine-readable explanation of why a planned step was included or omitted. */\nexport type PipelineStepSelectionReason =\n | { kind: \"all\" }\n | { kind: \"exact\" }\n | { kind: \"target\"; targetId: string }\n | { dependentId: string; kind: \"required-dependency\"; targetId: string }\n | { dependentId: string; kind: \"failure-gate\"; targetId: string }\n | { dependentId: string; kind: \"optional-only\"; targetId: string }\n | { kind: \"outside-target-closure\" }\n | { kind: \"not-selected\" };\n\n/** Planned representation of one declared step and its selection state. */\nexport interface PipelinePlanStep {\n dependencies: string[];\n description?: string;\n /** How this step behaves when the pipeline is run with `dryRun: true`. */\n dryRun: \"custom\" | \"run\" | \"skip\";\n id: string;\n /** Optional human-facing display name. Stable machine identity remains `id`. */\n name?: string;\n /** Static child structure when this opaque step executes another pipeline. */\n nestedPipeline?: {\n /** One child execution or one child execution per runtime item. */\n mode: \"single\" | \"for-each\";\n identity?: PipelineDefinitionIdentity;\n concurrency?: number | \"dynamic\";\n pipelineId: string;\n /** All declared child step ids; runtime selection may execute only a subset. */\n stepIds: readonly string[];\n };\n /** Static remote adapter metadata when this opaque step calls an external engine. */\n remote?: {\n engine: string;\n target?: string;\n };\n optionalDependencies: string[];\n /** True when the step's runtime policy may elect not to run it. */\n runtimeSkipPossible: boolean;\n selected: boolean;\n /** Stable reasons for selection or omission; shared prerequisites can have several. */\n selectionReasons: readonly PipelineStepSelectionReason[];\n skipAfterFailureOf: string[];\n skipReason?: PipelineStepSkipReason;\n}\n\n/** Side-effect-free validation and selection result for a pipeline run. */\nexport interface PipelinePlan {\n definition?: PipelineDefinitionSnapshot;\n dryRun: boolean;\n errors: PipelineError[];\n ok: boolean;\n pipelineId: string;\n steps: PipelinePlanStep[];\n}\n\n/** Layout directions for generated Mermaid flowcharts. */\nexport const PIPELINE_MERMAID_DIRECTIONS = [\"BT\", \"LR\", \"RL\", \"TB\", \"TD\"] as const;\n/** Supported Mermaid flowchart direction. */\nexport type PipelineMermaidDirection = (typeof PIPELINE_MERMAID_DIRECTIONS)[number];\n\n/** Rendering options for a pipeline Mermaid flowchart. */\nexport interface PipelineMermaidOptions {\n /** Mermaid flowchart direction. Defaults to top-down (`TD`). */\n direction?: PipelineMermaidDirection;\n /** Append each operational description to its node label. Defaults to false. */\n includeDescriptions?: boolean;\n}\n\ntype PipelineRunArguments<\n TOptions,\n TStepId extends string,\n TTargetId extends string,\n> = {} extends TOptions\n ? [\n options?: TOptions,\n controls?: PipelineRunControls<TStepId, TTargetId>,\n context?: Partial<PipelineContext>,\n ]\n : [\n options: TOptions,\n controls?: PipelineRunControls<TStepId, TTargetId>,\n context?: Partial<PipelineContext>,\n ];\n\n/** Compiled pipeline that can be planned, executed, and rendered as a graph. */\nexport interface Pipeline<\n TOptions extends object,\n TResult,\n TStepId extends string = string,\n TTargetId extends string = TStepId,\n TId extends string = string,\n> {\n readonly id: TId;\n /** Optional display name; stable identity remains `id`. */\n readonly name?: string;\n /** Human-readable purpose for command and discovery surfaces. */\n readonly description?: string;\n /** Compiled definition metadata. Absent only on externally implemented pipelines. */\n readonly definition?: PipelineDefinitionSnapshot;\n /** Runtime domain schema supplied to createSteps; CLI adapters can infer its input flags. */\n readonly optionsSchema?: StandardSchemaV1;\n /** Stable definition-order step ids for discovery surfaces such as CLI help. */\n readonly stepIds: readonly TStepId[];\n /** Stable declared goal ids that support dependency-aware target execution. */\n readonly targetIds: readonly TTargetId[];\n plan(controls?: PipelineRunControls<TStepId, TTargetId>): PipelinePlan;\n /** Omitted options default to {} when the input type has no required fields. */\n run(\n options: TOptions,\n controls?: PipelineRunControls<TStepId, TTargetId>,\n context?: Partial<PipelineContext>\n ): Promise<PipelineRun<TResult>>;\n run(...args: PipelineRunArguments<TOptions, TStepId, TTargetId>): Promise<PipelineRun<TResult>>;\n runOrThrow(\n options: TOptions,\n controls?: PipelineRunControls<TStepId, TTargetId>,\n context?: Partial<PipelineContext>\n ): Promise<TResult>;\n runOrThrow(...args: PipelineRunArguments<TOptions, TStepId, TTargetId>): Promise<TResult>;\n /** Generate a static Mermaid flowchart without running or planning the pipeline. */\n toMermaid(options?: PipelineMermaidOptions): string;\n}\n\n/** Input accepted by a pipeline run before any options schema transformation. */\nexport type PipelineInput<TPipeline extends Pipeline<object, unknown>> = Exclude<\n Parameters<TPipeline[\"run\"]>[0],\n undefined\n>;\n\n/** Successful result produced by a pipeline run. */\nexport type PipelineResult<TPipeline extends Pipeline<object, unknown>> = Awaited<\n ReturnType<TPipeline[\"runOrThrow\"]>\n>;\n"]}
@@ -61,7 +61,10 @@ export function definePipeline(definition) {
61
61
  }
62
62
  async function run(options, controls = {}, context = defaultPipelineContext()) {
63
63
  const prepared = prepareRun(controls);
64
- return executeCompiled(prepared.plan, options, prepared.controls, context);
64
+ // SAFETY: the public signature permits omission only when {} satisfies the
65
+ // input type. Schemas still validate the default object during execution.
66
+ const input = options === undefined ? {} : options;
67
+ return executeCompiled(prepared.plan, input, prepared.controls, context);
65
68
  }
66
69
  async function runOrThrow(options, controls = {}, context = defaultPipelineContext()) {
67
70
  const result = await run(options, controls, context);
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/core/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAUzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAcvD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,CAAC;AA+EnD,SAAS,oBAAoB,CAC3B,QAAiD;IAEjD,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;IAC/E,MA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AAC,UAAU;QAC/B,mFAAmF;QACnF,aAAa,EAAE,QAAQ,CAAC,aACQ;QAChC,OAAO;QACP,SAAS;QACT,IAAI;QACJ,GAAG;QACH,UAAU;QACV,SAAS;KACV,CAAC;IACF,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,oBAAoB,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,CAAC;IAClF,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAChC,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {\n defaultPipelineContext,\n executePlannedRun,\n PipelineExecutionError,\n resolvePipelineRuntime,\n} from \"./pipeline-execute.js\";\nimport { RUN_MODEL_VERSION } from \"./pipeline-ids.js\";\nimport { compilePipeline } from \"./pipeline-compiler.js\";\nimport type {\n DefaultPipelineResult,\n DefaultPipelineTargets,\n PipelineDefinition,\n StepIds,\n StepsInputOptions,\n StepsOptionsSchema,\n TargetIds,\n} from \"./pipeline-definition.js\";\nimport { PipelineDefinitionError } from \"./pipeline-errors.js\";\nimport { requireOutputs } from \"./pipeline-finalizer.js\";\nimport { brandCompiledPipeline, EXECUTE_COMPILED_RUN } from \"./pipeline-identity.js\";\nimport { renderPipelineMermaid } from \"./pipeline-mermaid.js\";\nimport { buildPipelinePlan } from \"./pipeline-plan.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport type {\n InferSchemaOutput,\n Pipeline,\n PipelineContext,\n PipelineDefinitionSnapshot,\n PipelineMermaidOptions,\n PipelinePlan,\n PipelineRun,\n PipelineRunControls,\n StandardSchemaV1,\n} from \"./pipeline-types.js\";\n\nexport { PipelineExecutionError, RUN_MODEL_VERSION };\nexport { isPipelineErrorCode, PIPELINE_ERROR_CODES } from \"./pipeline-types.js\";\nexport { createSteps } from \"./pipeline-steps.js\";\nexport { PipelineDefinitionError, requireOutputs };\nexport type {\n PipelineDefinitionIdentity,\n PipelineDefinitionSnapshot,\n PipelineLogger,\n PipelineContext,\n PipelineRunControls,\n PipelineExecutionContext,\n PipelineStepProgressDetailStatus,\n PipelineStepProgressDetail,\n PipelineStepProgress,\n PipelineStepContext,\n RemoteStepAdapter,\n PipelineErrorPhase,\n PipelineErrorKind,\n PipelineErrorCode,\n PipelineValidationIssue,\n PipelineError,\n PipelineFanOutDiagnostics,\n PipelineFanOutFailure,\n StandardSchemaV1,\n PipelineErrorCause,\n PipelineStepCompleteReport,\n PipelineStepSkippedReport,\n PipelineStepCancelledReport,\n PipelineStepFailedReport,\n PipelineStepReport,\n PipelineStepReportStatus,\n PipelineRunStatus,\n PipelineRun,\n PipelineStepSkipReason,\n StepSkipDecision,\n PipelineStepStatus,\n PipelineStepLifecycleStatus,\n PipelineStepPlannedEvent,\n PipelineStepStartEvent,\n PipelineStepProgressEvent,\n PipelineStepCancelledEvent,\n PipelineStepFailedEvent,\n PipelineStepSkippedEvent,\n PipelineStepCompleteEvent,\n PipelineHooks,\n PipelineStepSelectionReason,\n PipelinePlanStep,\n PipelinePlan,\n PipelineMermaidDirection,\n PipelineMermaidOptions,\n Pipeline,\n PipelineInput,\n PipelineResult,\n} from \"./pipeline-types.js\";\n\nexport type { PipelineDefinition } from \"./pipeline-definition.js\";\n\nexport type { Step, MappedChildProgressOptions } from \"./pipeline-steps.js\";\n\ntype DuplicateStepIds<\n TSteps extends readonly AnyStep[],\n TSeen extends string = never,\n> = TSteps extends readonly [infer THead, ...infer TTail]\n ? THead extends AnyStep\n ? TTail extends readonly AnyStep[]\n ? THead[\"id\"] extends TSeen\n ? THead[\"id\"] | DuplicateStepIds<TTail, TSeen>\n : DuplicateStepIds<TTail, TSeen | THead[\"id\"]>\n : never\n : never\n : never;\n\ntype CheckedStepTuple<TSteps extends readonly AnyStep[]> =\n string extends StepIds<TSteps>\n ? unknown\n : DuplicateStepIds<TSteps> extends never\n ? unknown\n : {\n /** Compile-time diagnostic: every literal step ID in a definition must be unique. */\n readonly __duplicateStepIds: DuplicateStepIds<TSteps>;\n };\n\nfunction normalizeRunControls<TStepId extends string, TTargetId extends string>(\n controls: PipelineRunControls<TStepId, TTargetId>\n): PipelineRunControls<TStepId, TTargetId> {\n const { continueOnError, dryRun, maxConcurrency, stepIds, targets } = controls;\n const snapshot: PipelineRunControls<TStepId, TTargetId> = {};\n if (continueOnError !== undefined) snapshot.continueOnError = continueOnError;\n if (dryRun !== undefined) snapshot.dryRun = dryRun;\n if (maxConcurrency !== undefined) snapshot.maxConcurrency = maxConcurrency;\n if (stepIds !== undefined) snapshot.stepIds = [...stepIds];\n if (targets !== undefined) snapshot.targets = [...targets];\n return snapshot;\n}\n\n/**\n * Compile a typed step graph into a validated, executable pipeline.\n * Prefer inferred type arguments to preserve the literal id. For an explicit\n * result contract, annotate the finalizer's return type; partially supplied type\n * arguments use defaults for remaining parameters, including the id's string type.\n */\nexport function definePipeline<\n const TSteps extends readonly AnyStep[],\n TResult = DefaultPipelineResult<TSteps>,\n const TTargets extends readonly TSteps[number][] = DefaultPipelineTargets<TSteps>,\n const TResultSchema extends StandardSchemaV1 | undefined = undefined,\n const TId extends string = string,\n>(\n definition: PipelineDefinition<TSteps, TResult, TTargets, TResultSchema> &\n CheckedStepTuple<TSteps> & { readonly id: TId }\n): Pipeline<\n StepsInputOptions<TSteps>,\n TResultSchema extends StandardSchemaV1 ? InferSchemaOutput<TResultSchema> : TResult,\n StepIds<TSteps>,\n TargetIds<TTargets>,\n TId\n> & {\n readonly definition: PipelineDefinitionSnapshot;\n readonly optionsSchema: StepsOptionsSchema<TSteps>;\n} {\n const compiled = compilePipeline<TSteps, TResult, TTargets, TResultSchema>(definition);\n type TInputOptions = StepsInputOptions<TSteps>;\n type TPipelineResult = TResultSchema extends StandardSchemaV1\n ? InferSchemaOutput<TResultSchema>\n : TResult;\n type TStepId = StepIds<TSteps>;\n type TTargetId = TargetIds<TTargets>;\n // SAFETY: each compiled step id is a string key of `TSteps`.\n const stepIds = compiled.stepIds as readonly TStepId[];\n // SAFETY: each compiled target id is a string key of `TTargets`.\n const targetIds = compiled.targetIds as readonly TTargetId[];\n\n function prepareRun(controls: PipelineRunControls<TStepId, TTargetId>): {\n controls: PipelineRunControls<TStepId, TTargetId>;\n plan: PipelinePlan;\n } {\n const normalizedControls = normalizeRunControls(controls);\n return {\n controls: normalizedControls,\n plan: buildPipelinePlan(compiled, normalizedControls),\n };\n }\n\n function plan(controls: PipelineRunControls<TStepId, TTargetId> = {}): PipelinePlan {\n return prepareRun(controls).plan;\n }\n\n function toMermaid(options: PipelineMermaidOptions = {}): string {\n return renderPipelineMermaid(compiled.orderedSteps, options, compiled.stepGraph);\n }\n\n async function executeCompiled(\n runPlan: PipelinePlan,\n options: TInputOptions,\n controls: PipelineRunControls<TStepId, TTargetId>,\n context: Partial<PipelineContext> = defaultPipelineContext()\n ): Promise<PipelineRun<TPipelineResult>> {\n return executePlannedRun({\n compiled,\n controls,\n domainOptions: options,\n plan: runPlan,\n runtime: resolvePipelineRuntime(context),\n });\n }\n\n async function run(\n options: TInputOptions,\n controls: PipelineRunControls<TStepId, TTargetId> = {},\n context: Partial<PipelineContext> = defaultPipelineContext()\n ): Promise<PipelineRun<TPipelineResult>> {\n const prepared = prepareRun(controls);\n return executeCompiled(prepared.plan, options, prepared.controls, context);\n }\n\n async function runOrThrow(\n options: TInputOptions,\n controls: PipelineRunControls<TStepId, TTargetId> = {},\n context: Partial<PipelineContext> = defaultPipelineContext()\n ): Promise<TPipelineResult> {\n const result = await run(options, controls, context);\n if (result.status !== \"completed\") {\n throw new PipelineExecutionError(result);\n }\n // SAFETY: a completed run always carries its `TPipelineResult` value.\n return result.value as TPipelineResult;\n }\n\n const pipeline = {\n id: definition.id,\n ...(definition.name === undefined ? {} : { name: definition.name }),\n ...(definition.description === undefined ? {} : { description: definition.description }),\n definition: compiled.definition,\n // SAFETY: compilation verifies that every step belongs to the same options schema.\n optionsSchema: compiled.optionsSchema as StepsOptionsSchema<TSteps> &\n (StandardSchemaV1 | undefined),\n stepIds,\n targetIds,\n plan,\n run,\n runOrThrow,\n toMermaid,\n };\n Object.defineProperty(pipeline, EXECUTE_COMPILED_RUN, { value: executeCompiled });\n brandCompiledPipeline(pipeline);\n return pipeline;\n}\n"]}
1
+ {"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/core/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAUzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAcvD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,CAAC;AA+EnD,SAAS,oBAAoB,CAC3B,QAAiD;IAEjD,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;IAC/E,MAAM,QAAQ,GAA4C,EAAE,CAAC;IAC7D,IAAI,eAAe,KAAK,SAAS;QAAE,QAAQ,CAAC,eAAe,GAAG,eAAe,CAAC;IAC9E,IAAI,MAAM,KAAK,SAAS;QAAE,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;IACnD,IAAI,cAAc,KAAK,SAAS;QAAE,QAAQ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AAI;QACJ,GAAG;QACH,UAAU;QACV,SAAS;KACV,CAAC;IACF,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,oBAAoB,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,CAAC;IAClF,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAChC,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {\n defaultPipelineContext,\n executePlannedRun,\n PipelineExecutionError,\n resolvePipelineRuntime,\n} from \"./pipeline-execute.js\";\nimport { RUN_MODEL_VERSION } from \"./pipeline-ids.js\";\nimport { compilePipeline } from \"./pipeline-compiler.js\";\nimport type {\n DefaultPipelineResult,\n DefaultPipelineTargets,\n PipelineDefinition,\n StepIds,\n StepsInputOptions,\n StepsOptionsSchema,\n TargetIds,\n} from \"./pipeline-definition.js\";\nimport { PipelineDefinitionError } from \"./pipeline-errors.js\";\nimport { requireOutputs } from \"./pipeline-finalizer.js\";\nimport { brandCompiledPipeline, EXECUTE_COMPILED_RUN } from \"./pipeline-identity.js\";\nimport { renderPipelineMermaid } from \"./pipeline-mermaid.js\";\nimport { buildPipelinePlan } from \"./pipeline-plan.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport type {\n InferSchemaOutput,\n Pipeline,\n PipelineContext,\n PipelineDefinitionSnapshot,\n PipelineMermaidOptions,\n PipelinePlan,\n PipelineRun,\n PipelineRunControls,\n StandardSchemaV1,\n} from \"./pipeline-types.js\";\n\nexport { PipelineExecutionError, RUN_MODEL_VERSION };\nexport { isPipelineErrorCode, PIPELINE_ERROR_CODES } from \"./pipeline-types.js\";\nexport { createSteps } from \"./pipeline-steps.js\";\nexport { PipelineDefinitionError, requireOutputs };\nexport type {\n PipelineDefinitionIdentity,\n PipelineDefinitionSnapshot,\n PipelineLogger,\n PipelineContext,\n PipelineRunControls,\n PipelineExecutionContext,\n PipelineStepProgressDetailStatus,\n PipelineStepProgressDetail,\n PipelineStepProgress,\n PipelineStepContext,\n RemoteStepAdapter,\n PipelineErrorPhase,\n PipelineErrorKind,\n PipelineErrorCode,\n PipelineValidationIssue,\n PipelineError,\n PipelineFanOutDiagnostics,\n PipelineFanOutFailure,\n StandardSchemaV1,\n PipelineErrorCause,\n PipelineStepCompleteReport,\n PipelineStepSkippedReport,\n PipelineStepCancelledReport,\n PipelineStepFailedReport,\n PipelineStepReport,\n PipelineStepReportStatus,\n PipelineRunStatus,\n PipelineRun,\n PipelineStepSkipReason,\n StepSkipDecision,\n PipelineStepStatus,\n PipelineStepLifecycleStatus,\n PipelineStepPlannedEvent,\n PipelineStepStartEvent,\n PipelineStepProgressEvent,\n PipelineStepCancelledEvent,\n PipelineStepFailedEvent,\n PipelineStepSkippedEvent,\n PipelineStepCompleteEvent,\n PipelineHooks,\n PipelineStepSelectionReason,\n PipelinePlanStep,\n PipelinePlan,\n PipelineMermaidDirection,\n PipelineMermaidOptions,\n Pipeline,\n PipelineInput,\n PipelineResult,\n} from \"./pipeline-types.js\";\n\nexport type { PipelineDefinition } from \"./pipeline-definition.js\";\n\nexport type { Step, MappedChildProgressOptions } from \"./pipeline-steps.js\";\n\ntype DuplicateStepIds<\n TSteps extends readonly AnyStep[],\n TSeen extends string = never,\n> = TSteps extends readonly [infer THead, ...infer TTail]\n ? THead extends AnyStep\n ? TTail extends readonly AnyStep[]\n ? THead[\"id\"] extends TSeen\n ? THead[\"id\"] | DuplicateStepIds<TTail, TSeen>\n : DuplicateStepIds<TTail, TSeen | THead[\"id\"]>\n : never\n : never\n : never;\n\ntype CheckedStepTuple<TSteps extends readonly AnyStep[]> =\n string extends StepIds<TSteps>\n ? unknown\n : DuplicateStepIds<TSteps> extends never\n ? unknown\n : {\n /** Compile-time diagnostic: every literal step ID in a definition must be unique. */\n readonly __duplicateStepIds: DuplicateStepIds<TSteps>;\n };\n\nfunction normalizeRunControls<TStepId extends string, TTargetId extends string>(\n controls: PipelineRunControls<TStepId, TTargetId>\n): PipelineRunControls<TStepId, TTargetId> {\n const { continueOnError, dryRun, maxConcurrency, stepIds, targets } = controls;\n const snapshot: PipelineRunControls<TStepId, TTargetId> = {};\n if (continueOnError !== undefined) snapshot.continueOnError = continueOnError;\n if (dryRun !== undefined) snapshot.dryRun = dryRun;\n if (maxConcurrency !== undefined) snapshot.maxConcurrency = maxConcurrency;\n if (stepIds !== undefined) snapshot.stepIds = [...stepIds];\n if (targets !== undefined) snapshot.targets = [...targets];\n return snapshot;\n}\n\n/**\n * Compile a typed step graph into a validated, executable pipeline.\n * Prefer inferred type arguments to preserve the literal id. For an explicit\n * result contract, annotate the finalizer's return type; partially supplied type\n * arguments use defaults for remaining parameters, including the id's string type.\n */\nexport function definePipeline<\n const TSteps extends readonly AnyStep[],\n TResult = DefaultPipelineResult<TSteps>,\n const TTargets extends readonly TSteps[number][] = DefaultPipelineTargets<TSteps>,\n const TResultSchema extends StandardSchemaV1 | undefined = undefined,\n const TId extends string = string,\n>(\n definition: PipelineDefinition<TSteps, TResult, TTargets, TResultSchema> &\n CheckedStepTuple<TSteps> & { readonly id: TId }\n): Pipeline<\n StepsInputOptions<TSteps>,\n TResultSchema extends StandardSchemaV1 ? InferSchemaOutput<TResultSchema> : TResult,\n StepIds<TSteps>,\n TargetIds<TTargets>,\n TId\n> & {\n readonly definition: PipelineDefinitionSnapshot;\n readonly optionsSchema: StepsOptionsSchema<TSteps>;\n} {\n const compiled = compilePipeline<TSteps, TResult, TTargets, TResultSchema>(definition);\n type TInputOptions = StepsInputOptions<TSteps>;\n type TPipelineResult = TResultSchema extends StandardSchemaV1\n ? InferSchemaOutput<TResultSchema>\n : TResult;\n type TStepId = StepIds<TSteps>;\n type TTargetId = TargetIds<TTargets>;\n // SAFETY: each compiled step id is a string key of `TSteps`.\n const stepIds = compiled.stepIds as readonly TStepId[];\n // SAFETY: each compiled target id is a string key of `TTargets`.\n const targetIds = compiled.targetIds as readonly TTargetId[];\n\n function prepareRun(controls: PipelineRunControls<TStepId, TTargetId>): {\n controls: PipelineRunControls<TStepId, TTargetId>;\n plan: PipelinePlan;\n } {\n const normalizedControls = normalizeRunControls(controls);\n return {\n controls: normalizedControls,\n plan: buildPipelinePlan(compiled, normalizedControls),\n };\n }\n\n function plan(controls: PipelineRunControls<TStepId, TTargetId> = {}): PipelinePlan {\n return prepareRun(controls).plan;\n }\n\n function toMermaid(options: PipelineMermaidOptions = {}): string {\n return renderPipelineMermaid(compiled.orderedSteps, options, compiled.stepGraph);\n }\n\n async function executeCompiled(\n runPlan: PipelinePlan,\n options: TInputOptions,\n controls: PipelineRunControls<TStepId, TTargetId>,\n context: Partial<PipelineContext> = defaultPipelineContext()\n ): Promise<PipelineRun<TPipelineResult>> {\n return executePlannedRun({\n compiled,\n controls,\n domainOptions: options,\n plan: runPlan,\n runtime: resolvePipelineRuntime(context),\n });\n }\n\n async function run(\n options?: TInputOptions,\n controls: PipelineRunControls<TStepId, TTargetId> = {},\n context: Partial<PipelineContext> = defaultPipelineContext()\n ): Promise<PipelineRun<TPipelineResult>> {\n const prepared = prepareRun(controls);\n // SAFETY: the public signature permits omission only when {} satisfies the\n // input type. Schemas still validate the default object during execution.\n const input = options === undefined ? ({} as TInputOptions) : options;\n return executeCompiled(prepared.plan, input, prepared.controls, context);\n }\n\n async function runOrThrow(\n options?: TInputOptions,\n controls: PipelineRunControls<TStepId, TTargetId> = {},\n context: Partial<PipelineContext> = defaultPipelineContext()\n ): Promise<TPipelineResult> {\n const result = await run(options, controls, context);\n if (result.status !== \"completed\") {\n throw new PipelineExecutionError(result);\n }\n // SAFETY: a completed run always carries its `TPipelineResult` value.\n return result.value as TPipelineResult;\n }\n\n const pipeline = {\n id: definition.id,\n ...(definition.name === undefined ? {} : { name: definition.name }),\n ...(definition.description === undefined ? {} : { description: definition.description }),\n definition: compiled.definition,\n // SAFETY: compilation verifies that every step belongs to the same options schema.\n optionsSchema: compiled.optionsSchema as StepsOptionsSchema<TSteps> &\n (StandardSchemaV1 | undefined),\n stepIds,\n targetIds,\n plan,\n run,\n runOrThrow,\n toMermaid,\n };\n Object.defineProperty(pipeline, EXECUTE_COMPILED_RUN, { value: executeCompiled });\n brandCompiledPipeline(pipeline);\n return pipeline;\n}\n"]}
@@ -61,6 +61,9 @@ dry runs with fake I/O. The general `tubeless` skill supports ongoing authoring.
61
61
  option types contain domain input only;
62
62
  callers pass those options and optional built-in controls to
63
63
  `run(options, controls?)`, while `plan(controls)` accepts controls alone.
64
+ Omit options with `run()` or `runOrThrow()` when no input fields are required;
65
+ each call supplies a fresh `{}` to schema validation. Pass `undefined` as the
66
+ first argument when supplying controls without input.
64
67
  - Opt in to parallel independent steps with `run(options, { maxConcurrency: 4 })`.
65
68
  `plan(controls)` validates this and all other static controls before execution;
66
69
  it still does not invoke domain schemas.
@@ -93,6 +96,9 @@ dry runs with fake I/O. The general `tubeless` skill supports ongoing authoring.
93
96
  output remains `T`.
94
97
  - Use `fromPipeline` for one independently useful child workflow and
95
98
  `forEachPipeline` for runtime fan-out with stable keys and bounded concurrency.
99
+ Omit `fromPipeline.mapOptions` when the parent's validated domain options satisfy
100
+ the child's input type; those options are forwarded unchanged and validated by
101
+ the child. Otherwise provide a mapper. Fan-out still requires per-item mapping.
96
102
  Keep `mapOptions` exclusively about child domain inputs. Put child `targets`,
97
103
  `stepIds`, concurrency, failure policy, and optional dry-run opt-in in the separate
98
104
  `controls` value or callback. A child cannot disable its parent's dry run.
@@ -10,14 +10,14 @@ Package: `tubeless`
10
10
 
11
11
  | Entrypoint | Declaration | Surface hash | Exported symbols |
12
12
  | --------------------- | ---------------------------------- | ------------------------------------------------------------------ | ---------------: |
13
- | `tubeless` | `./dist/core/pipeline.d.ts` | `e2556c8b5aca25c748d697ce9d7ba7bf2ce59a8ea5ee970a9937de43b67b2715` | 59 |
14
- | `tubeless/cli` | `./dist/cli/cli.d.ts` | `76c86c5626336ad4fbca69b255f5c28b74216bafb571423d10f4907694a17f1e` | 31 |
13
+ | `tubeless` | `./dist/core/pipeline.d.ts` | `53afa8330a5403caec68c88aac341de42bf057421721fe40d978635260615db8` | 59 |
14
+ | `tubeless/cli` | `./dist/cli/cli.d.ts` | `69978854bc4e2796935636c7f0e5cd912bdd5d4519e563aad9b42d262d172318` | 31 |
15
15
  | `tubeless/batch` | `./dist/utilities/batch.d.ts` | `7dbfbd4d894f2e9cc737b5373d1f654f5f08e8b5b5cce27511ef876779713656` | 6 |
16
- | `tubeless/node` | `./dist/node/node.d.ts` | `867100a0a8a083a06fc23199a79fc29f492211fb892e45ec13e721eda3519f32` | 12 |
16
+ | `tubeless/node` | `./dist/node/node.d.ts` | `24461d789a0449a25aadc0e1150c3307581162af692223ca829250684c21428f` | 12 |
17
17
  | `tubeless/rate-limit` | `./dist/utilities/rate-limit.d.ts` | `01029b2a9f1504a66e396804ccc63a5b43dbcb63c002dd47918e315a90ac2a3a` | 1 |
18
18
  | `tubeless/retry` | `./dist/utilities/retry.d.ts` | `55fca324a49d3c077f24c3a11c7392cfc2d48dd576fa481246623b6a75ecbe30` | 4 |
19
- | `tubeless/project` | `./dist/project/project.d.ts` | `1c727809fa087e73fe65901e6152ef345551e20c569aa386587ec8754ecfab84` | 8 |
20
- | `tubeless/testing` | `./dist/testing/testing.d.ts` | `06fdc0b9e3834b2b7512df85dca80de2c3a36a8820d22bfe54d9a16ca5278394` | 7 |
19
+ | `tubeless/project` | `./dist/project/project.d.ts` | `049b1488810e664e4a46638195861db2f1589006a34d486e8b90d651ac92a02b` | 8 |
20
+ | `tubeless/testing` | `./dist/testing/testing.d.ts` | `586298e4d141586955569a195aeec12deaf1e811bddf7310c66d3db31afdcbf7` | 7 |
21
21
  | `tubeless/tracing` | `./dist/tracing/tracing.d.ts` | `bde2a6b18d95b6d6311fec6ae8719ff432208e650803635c9355ec1af62dad27` | 3 |
22
22
 
23
23
  ## Symbols
@@ -26,11 +26,11 @@ Package: `tubeless`
26
26
 
27
27
  | Symbol | Description |
28
28
  | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
29
- | [`createSteps`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-steps.ts#L312) | Create typed step constructors for one pipeline definition. |
29
+ | [`createSteps`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-steps.ts#L320) | Create typed step constructors for one pipeline definition. |
30
30
  | [`definePipeline`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline.ts#L137) | Compile a typed step graph into a validated, executable pipeline. |
31
31
  | [`isPipelineErrorCode`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L181) | Return whether an unknown value is a stable package-owned pipeline error code. |
32
- | [`MappedChildProgressOptions`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-steps.ts#L170) | Presentation options for opaque `forEachPipeline` progress. |
33
- | [`Pipeline`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L528) | Compiled pipeline that can be planned, executed, and rendered as a graph. |
32
+ | [`MappedChildProgressOptions`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-steps.ts#L178) | Presentation options for opaque `forEachPipeline` progress. |
33
+ | [`Pipeline`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L544) | Compiled pipeline that can be planned, executed, and rendered as a graph. |
34
34
  | [`PIPELINE_ERROR_CODES`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L173) | Ordered catalog of every stable package-owned pipeline error code. |
35
35
  | [`PipelineContext`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L35) | Caller-supplied services and metadata shared by one pipeline execution. |
36
36
  | [`PipelineDefinition`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-definition.ts#L85) | Declarative configuration for compiling a typed pipeline. |
@@ -47,13 +47,13 @@ Package: `tubeless`
47
47
  | [`PipelineFanOutDiagnostics`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L203) | Bounded diagnostics collected from a failed or cancelled fan-out step. |
48
48
  | [`PipelineFanOutFailure`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L192) | Bounded diagnostics for a failed or cancelled runtime fan-out. |
49
49
  | [`PipelineHooks`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L443) | Optional lifecycle callbacks, each receiving its own metadata snapshot. |
50
- | [`PipelineInput`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L564) | Input accepted by a pipeline run before any options schema transformation. |
50
+ | [`PipelineInput`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L583) | Input accepted by a pipeline run before any options schema transformation. |
51
51
  | [`PipelineLogger`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L28) | Minimal logger used by pipeline execution, reporters, and CLI adapters. |
52
52
  | [`PipelineMermaidDirection`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L517) | Supported Mermaid flowchart direction. |
53
53
  | [`PipelineMermaidOptions`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L520) | Rendering options for a pipeline Mermaid flowchart. |
54
54
  | [`PipelinePlan`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L505) | Side-effect-free validation and selection result for a pipeline run. |
55
55
  | [`PipelinePlanStep`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L471) | Planned representation of one declared step and its selection state. |
56
- | [`PipelineResult`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L569) | Successful result produced by a pipeline run. |
56
+ | [`PipelineResult`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L589) | Successful result produced by a pipeline run. |
57
57
  | [`PipelineRun`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L357) | Versioned public record returned for one pipeline execution. |
58
58
  | [`PipelineRunControls`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L53) | Built-in run controls. |
59
59
  | [`PipelineRunStatus`](https://github.com/chetmancini/tubeless/blob/main/src/core/pipeline-types.ts#L336) | Terminal disposition of a completed run record. |
@@ -63,7 +63,7 @@
63
63
  "Step",
64
64
  "StepSkipDecision"
65
65
  ],
66
- "sha256": "e2556c8b5aca25c748d697ce9d7ba7bf2ce59a8ea5ee970a9937de43b67b2715",
66
+ "sha256": "53afa8330a5403caec68c88aac341de42bf057421721fe40d978635260615db8",
67
67
  "specifier": "tubeless"
68
68
  },
69
69
  {
@@ -101,7 +101,7 @@
101
101
  "ReporterSymbolMode",
102
102
  "ReporterTerminalCapabilities"
103
103
  ],
104
- "sha256": "76c86c5626336ad4fbca69b255f5c28b74216bafb571423d10f4907694a17f1e",
104
+ "sha256": "69978854bc4e2796935636c7f0e5cd912bdd5d4519e563aad9b42d262d172318",
105
105
  "specifier": "tubeless/cli"
106
106
  },
107
107
  {
@@ -133,7 +133,7 @@
133
133
  "WorkerThreadContext",
134
134
  "writeJson"
135
135
  ],
136
- "sha256": "867100a0a8a083a06fc23199a79fc29f492211fb892e45ec13e721eda3519f32",
136
+ "sha256": "24461d789a0449a25aadc0e1150c3307581162af692223ca829250684c21428f",
137
137
  "specifier": "tubeless/node"
138
138
  },
139
139
  {
@@ -160,7 +160,7 @@
160
160
  "ProjectOptions",
161
161
  "ProjectRegistry"
162
162
  ],
163
- "sha256": "1c727809fa087e73fe65901e6152ef345551e20c569aa386587ec8754ecfab84",
163
+ "sha256": "049b1488810e664e4a46638195861db2f1589006a34d486e8b90d651ac92a02b",
164
164
  "specifier": "tubeless/project"
165
165
  },
166
166
  {
@@ -174,7 +174,7 @@
174
174
  "PipelineTestRuntimeOptions",
175
175
  "PipelineTestSleep"
176
176
  ],
177
- "sha256": "06fdc0b9e3834b2b7512df85dca80de2c3a36a8820d22bfe54d9a16ca5278394",
177
+ "sha256": "586298e4d141586955569a195aeec12deaf1e811bddf7310c66d3db31afdcbf7",
178
178
  "specifier": "tubeless/testing"
179
179
  },
180
180
  {
@@ -15,9 +15,24 @@ Start with the [single-child example](../examples/child-pipeline.ts) or the
15
15
 
16
16
  ## Run a child pipeline
17
17
 
18
- Use `fromPipeline` with `pipeline` and `mapOptions`. The mapper receives the
19
- parent step's dependency outputs and context, and returns the inputs the child
20
- needs. Add `mapResult` if the parent needs a different result shape.
18
+ Use `fromPipeline` with `pipeline`. When the parent's domain options satisfy the
19
+ child's input type, omit `mapOptions` to forward `context.options` unchanged:
20
+
21
+ ```ts
22
+ const { fromPipeline } = createSteps<NormalizeOptions>();
23
+ const normalize = fromPipeline("normalize", { pipeline: NormalizePipeline });
24
+ ```
25
+
26
+ Inherited options are the parent's validated, transformed options. The child
27
+ still validates them through its own input schema. All parent fields are forwarded;
28
+ use an explicit mapper to remove extra fields if the child schema rejects them.
29
+ Execution controls are separate and are never merged into these options. See the
30
+ [inherited inputs example](../examples/inherited-inputs.ts).
31
+
32
+ When the input types differ, `mapOptions` is required. It receives the parent
33
+ step's dependency outputs and context, and returns the inputs the child needs.
34
+ You can also supply it to override otherwise compatible inputs. Add `mapResult`
35
+ if the parent needs a different result shape.
21
36
 
22
37
  ```ts
23
38
  const { fromPipeline } = createSteps<ImportOptions>();
@@ -37,7 +52,8 @@ same `(inputs, context)` arguments as `mapOptions`.
37
52
  ## Run a child for each item
38
53
 
39
54
  Use `items` to return the list to process, `key` for stable item IDs, and
40
- `concurrency` to limit simultaneous child runs:
55
+ `concurrency` to limit simultaneous child runs. `forEachPipeline` always requires
56
+ an explicit per-item `mapOptions`:
41
57
 
42
58
  ```ts
43
59
  const { forEachPipeline } = createSteps<ParentOptions>();
@@ -115,8 +131,8 @@ The parent plan contains one step for the child workflow. This is what
115
131
  The parent's `nestedPipeline` metadata still identifies the child pipeline,
116
132
  its declared step IDs, and whether it runs once or for multiple items.
117
133
 
118
- Selecting the parent step runs the child using the values returned by
119
- `mapOptions`. Parent and child step IDs are separate. A parent target does not
134
+ Selecting the parent step runs the child using mapped inputs, or inherited parent
135
+ options for `fromPipeline` without a mapper. Parent and child step IDs are separate. A parent target does not
120
136
  select an identically named child step, and `parent.child-step` selection is
121
137
  not supported.
122
138
 
package/docs/concepts.md CHANGED
@@ -71,6 +71,15 @@ await pipeline.run(options, { maxConcurrency: 4 });
71
71
  await pipeline.runOrThrow(options, { targets: ["publish"] });
72
72
  ```
73
73
 
74
+ When the input type has no required fields, use `pipeline.run()` or
75
+ `pipeline.runOrThrow()`. Omitted or `undefined` input becomes a fresh `{}` on each
76
+ run and still passes through the input schema, including validation and defaults.
77
+ Required input fields remain required at compile time. To supply controls or
78
+ context while omitting input, use `run(undefined, controls, context)`; the first
79
+ argument always represents domain input. `PipelineInput<typeof pipeline>` remains
80
+ the domain object type, without the call's optional `undefined`.
81
+ See the [inherited inputs recipe](../examples/inherited-inputs.ts).
82
+
74
83
  | Control | Default | Effect |
75
84
  | ----------------- | --------- | -------------------------------------------------------------------------- |
76
85
  | `dryRun` | `false` | Applies each step's dry-run policy; unmarked steps still run |
package/docs/recipes.md CHANGED
@@ -12,6 +12,7 @@ one of these recipes.
12
12
  | --------------------------------------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------- |
13
13
  | Run all steps with a default result | [`minimal-pipeline.ts`](../examples/minimal-pipeline.ts) | `definePipeline({ id, steps })` |
14
14
  | Return one step's exact result type | [`precise-result.ts`](../examples/precise-result.ts) | `finalize: step`, required output, inferred result type |
15
+ | Omit empty inputs and identity child mapping | [`inherited-inputs.ts`](../examples/inherited-inputs.ts) | `runOrThrow()`, compatible parent inputs through `fromPipeline` |
15
16
  | Run independent DAG branches concurrently | [`parallel-dag.ts`](../examples/parallel-dag.ts) | `maxConcurrency`, `plan()` checks controls, dependency joins, stable final reports |
16
17
  | CPU parallelism on Node worker threads | [`worker-threads.ts`](../examples/worker-threads.ts) | `createWorkerThreadAdapter`, `fromRemote`, structured clone, pool ownership |
17
18
  | Sequential import or ETL | [`typed-import.ts`](../examples/typed-import.ts) | `createSteps`, `dependsOn`, `requireOutputs`, `targets` |
@@ -0,0 +1,28 @@
1
+ import { createSteps, definePipeline } from "tubeless";
2
+
3
+ interface WelcomeOptions {
4
+ name?: string;
5
+ }
6
+
7
+ const { step } = createSteps<WelcomeOptions>();
8
+ const greet = step("greet", {
9
+ run: (_inputs, context) => `Hello, ${context.options.name ?? "world"}!`,
10
+ });
11
+ const GreetingPipeline = definePipeline({ id: "greeting", steps: [greet], finalize: greet });
12
+
13
+ const { fromPipeline } = createSteps<WelcomeOptions>();
14
+ const greeting = fromPipeline("greeting", {
15
+ pipeline: GreetingPipeline,
16
+ // Matching parent inputs are inherited; mapOptions is only needed to change them.
17
+ });
18
+
19
+ export const WelcomePipeline = definePipeline({
20
+ id: "welcome",
21
+ steps: [greeting],
22
+ finalize: greeting,
23
+ });
24
+
25
+ export async function runInheritedInputsExample(): Promise<string> {
26
+ // All input fields are optional, so omitted input defaults to a fresh {}.
27
+ return WelcomePipeline.runOrThrow();
28
+ }
@@ -2,6 +2,7 @@ import { definePipelineCommand } from "tubeless/cli";
2
2
  import { defineProject } from "tubeless/project";
3
3
  import { ValidatedPipeline } from "../validated-boundaries.ts";
4
4
  import { CountPipeline } from "../precise-result.ts";
5
+ import { WelcomePipeline } from "../inherited-inputs.ts";
5
6
  import { YamlImportCommand, YamlPreviewCommand } from "../yaml-pipelines.ts";
6
7
  import { YamlPelotonCommand } from "../yaml-peloton.ts";
7
8
  import { NormalizePipeline } from "./pipelines/normalize.ts";
@@ -16,6 +17,9 @@ export default defineProject(
16
17
  "example-jobs",
17
18
  [
18
19
  ValidatedPipeline,
20
+ definePipelineCommand(WelcomePipeline, {
21
+ params: { name: { type: "string" } },
22
+ }),
19
23
  definePipelineCommand(CountPipeline, {
20
24
  params: { text: { type: "string", required: true } },
21
25
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tubeless",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "description": "Typed pipeline primitives for composable data-processing workflows.",
5
5
  "author": {
6
6
  "name": "Chet Mancini",
@@ -29,6 +29,9 @@ the installed declarations before using them; do not silently upgrade Tubeless.
29
29
  constructor it needs: `step`, `fromPipeline`, `fromRemote`, and/or
30
30
  `forEachPipeline`. Domain options contain business inputs; pass built-in
31
31
  controls separately to `run(options, controls?)`.
32
+ Use `run()` or `runOrThrow()` when all input fields are optional; omitted input
33
+ becomes a fresh `{}` and still undergoes schema validation. Supply controls with
34
+ `run(undefined, controls)` in that case.
32
35
  - Use `plan(controls)` to validate static controls and selection without invoking
33
36
  domain schemas or handlers. Runs reuse the same control validation.
34
37
  - Opt in to independent DAG parallelism with `run(options, { maxConcurrency: 4 })`;
@@ -116,7 +119,10 @@ Read the corresponding package recipe before using these features:
116
119
 
117
120
  - `fromPipeline` for an independently useful child workflow;
118
121
  `forEachPipeline` for runtime fan-out with stable keys and bounded concurrency.
119
- Keep `mapOptions` limited to child domain input. Supply child execution controls
122
+ Omit `fromPipeline.mapOptions` when the parent's validated options satisfy the
123
+ child's input type; it forwards them unchanged through child validation. Fan-out
124
+ still requires explicit per-item mapping. Keep `mapOptions` limited to child
125
+ domain input. Supply child execution controls
120
126
  separately through `controls`, either as a typed value or a callback. A child's
121
127
  `dryRun: false` never disables a dry-running parent.
122
128
  Use ordinary helpers or `runConcurrent` for lightweight work without child