tubeless 0.2.12 → 0.2.13

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.
Files changed (195) hide show
  1. package/dist/core/child-execution.d.ts +0 -23
  2. package/dist/core/child-execution.js +10 -12
  3. package/dist/core/child-execution.js.map +1 -1
  4. package/dist/core/child-progress.js +7 -2
  5. package/dist/core/child-progress.js.map +1 -1
  6. package/dist/core/iteration.d.ts +27 -0
  7. package/dist/core/iteration.js +111 -0
  8. package/dist/core/iteration.js.map +1 -0
  9. package/dist/core/lifecycle.d.ts +7 -5
  10. package/dist/core/lifecycle.js +36 -4
  11. package/dist/core/lifecycle.js.map +1 -1
  12. package/dist/core/pipeline-artifacts.d.ts +11 -0
  13. package/dist/core/pipeline-artifacts.js +2 -0
  14. package/dist/core/pipeline-artifacts.js.map +1 -0
  15. package/dist/core/pipeline-compiler.d.ts +1 -0
  16. package/dist/core/pipeline-compiler.js +1 -0
  17. package/dist/core/pipeline-compiler.js.map +1 -1
  18. package/dist/core/pipeline-definition-identity.d.ts +2 -2
  19. package/dist/core/pipeline-definition-identity.js +28 -5
  20. package/dist/core/pipeline-definition-identity.js.map +1 -1
  21. package/dist/core/pipeline-execute.d.ts +1 -6
  22. package/dist/core/pipeline-execute.js +28 -215
  23. package/dist/core/pipeline-execute.js.map +1 -1
  24. package/dist/core/pipeline-execution-error.d.ts +35 -0
  25. package/dist/core/pipeline-execution-error.js +195 -0
  26. package/dist/core/pipeline-execution-error.js.map +1 -0
  27. package/dist/core/pipeline-identity.d.ts +1 -0
  28. package/dist/core/pipeline-identity.js +1 -0
  29. package/dist/core/pipeline-identity.js.map +1 -1
  30. package/dist/core/pipeline-mermaid.js +4 -1
  31. package/dist/core/pipeline-mermaid.js.map +1 -1
  32. package/dist/core/pipeline-run-state.d.ts +4 -4
  33. package/dist/core/pipeline-run-state.js +10 -16
  34. package/dist/core/pipeline-run-state.js.map +1 -1
  35. package/dist/core/pipeline-step-executor.d.ts +2 -0
  36. package/dist/core/pipeline-step-executor.js +11 -3
  37. package/dist/core/pipeline-step-executor.js.map +1 -1
  38. package/dist/core/pipeline-steps.d.ts +20 -0
  39. package/dist/core/pipeline-steps.js +62 -0
  40. package/dist/core/pipeline-steps.js.map +1 -1
  41. package/dist/core/pipeline-types.d.ts +15 -2
  42. package/dist/core/pipeline-types.js.map +1 -1
  43. package/dist/core/pipeline.d.ts +4 -1
  44. package/dist/core/pipeline.js +18 -3
  45. package/dist/core/pipeline.js.map +1 -1
  46. package/dist/project/project-compiler.d.ts +3 -31
  47. package/dist/project/project-compiler.js +11 -180
  48. package/dist/project/project-compiler.js.map +1 -1
  49. package/dist/project/project-registry.d.ts +44 -0
  50. package/dist/project/project-registry.js +107 -0
  51. package/dist/project/project-registry.js.map +1 -0
  52. package/dist/project/project-step-graph.d.ts +9 -0
  53. package/dist/project/project-step-graph.js +99 -0
  54. package/dist/project/project-step-graph.js.map +1 -0
  55. package/dist/render/render.js +1 -1
  56. package/dist/render/render.js.map +1 -1
  57. package/dist/reporter/interactive-reporter.js +6 -3
  58. package/dist/reporter/interactive-reporter.js.map +1 -1
  59. package/dist/reporter/live-ticker-frame.d.ts +21 -0
  60. package/dist/reporter/live-ticker-frame.js +196 -0
  61. package/dist/reporter/live-ticker-frame.js.map +1 -0
  62. package/dist/reporter/live-ticker-protocol.d.ts +41 -0
  63. package/dist/reporter/live-ticker-protocol.js +59 -0
  64. package/dist/reporter/live-ticker-protocol.js.map +1 -0
  65. package/dist/reporter/live-ticker-worker.js +11 -25
  66. package/dist/reporter/live-ticker-worker.js.map +1 -1
  67. package/dist/reporter/live-ticker.d.ts +0 -15
  68. package/dist/reporter/live-ticker.js +11 -216
  69. package/dist/reporter/live-ticker.js.map +1 -1
  70. package/dist/reporter/reporter.js +7 -6
  71. package/dist/reporter/reporter.js.map +1 -1
  72. package/dist/run-store/definition-projection.d.ts +8 -0
  73. package/dist/run-store/definition-projection.js +89 -0
  74. package/dist/run-store/definition-projection.js.map +1 -0
  75. package/dist/run-store/run-projection.d.ts +15 -0
  76. package/dist/run-store/run-projection.js +203 -0
  77. package/dist/run-store/run-projection.js.map +1 -0
  78. package/dist/run-store/run-store-codec.d.ts +2 -0
  79. package/dist/run-store/run-store-codec.js +11 -0
  80. package/dist/run-store/run-store-codec.js.map +1 -1
  81. package/dist/run-store/run-store-event-decoder.js +3 -0
  82. package/dist/run-store/run-store-event-decoder.js.map +1 -1
  83. package/dist/run-store/run-store-reader.d.ts +7 -0
  84. package/dist/run-store/run-store-reader.js +31 -0
  85. package/dist/run-store/run-store-reader.js.map +1 -0
  86. package/dist/run-store/run-store-sqlite.js +23 -7
  87. package/dist/run-store/run-store-sqlite.js.map +1 -1
  88. package/dist/run-store/run-store.d.ts +16 -4
  89. package/dist/run-store/run-store.js +14 -263
  90. package/dist/run-store/run-store.js.map +1 -1
  91. package/dist/studio/run-store-ui-api.d.ts +13 -0
  92. package/dist/studio/run-store-ui-api.js +163 -0
  93. package/dist/studio/run-store-ui-api.js.map +1 -0
  94. package/dist/studio/run-store-ui-client-browser.js +2 -2
  95. package/dist/studio/run-store-ui-client-transport.js +28 -3
  96. package/dist/studio/run-store-ui-client-transport.js.map +1 -1
  97. package/dist/studio/run-store-ui-client.d.ts +2 -1
  98. package/dist/studio/run-store-ui-client.js +15 -9
  99. package/dist/studio/run-store-ui-client.js.map +1 -1
  100. package/dist/studio/run-store-ui-http.d.ts +11 -0
  101. package/dist/studio/run-store-ui-http.js +52 -0
  102. package/dist/studio/run-store-ui-http.js.map +1 -1
  103. package/dist/studio/run-store-ui-state.d.ts +1 -1
  104. package/dist/studio/run-store-ui-state.js +10 -28
  105. package/dist/studio/run-store-ui-state.js.map +1 -1
  106. package/dist/studio/run-store-ui.d.ts +5 -11
  107. package/dist/studio/run-store-ui.js +5 -203
  108. package/dist/studio/run-store-ui.js.map +1 -1
  109. package/dist/testing/testing.d.ts +18 -2
  110. package/dist/testing/testing.js +35 -2
  111. package/dist/testing/testing.js.map +1 -1
  112. package/dist/tracing/artifact-metadata.d.ts +28 -0
  113. package/dist/tracing/artifact-metadata.js +105 -0
  114. package/dist/tracing/artifact-metadata.js.map +1 -0
  115. package/dist/tracing/tracing-codec.d.ts +1 -1
  116. package/dist/tracing/tracing-codec.js +1 -1
  117. package/dist/tracing/tracing-codec.js.map +1 -1
  118. package/dist/tracing/tracing-constants.d.ts +1 -1
  119. package/dist/tracing/tracing-constants.js +1 -1
  120. package/dist/tracing/tracing-constants.js.map +1 -1
  121. package/dist/tracing/tracing-contracts.d.ts +3 -1
  122. package/dist/tracing/tracing-contracts.js.map +1 -1
  123. package/dist/tracing/tracing-internal.d.ts +2 -0
  124. package/dist/tracing/tracing-internal.js +36 -13
  125. package/dist/tracing/tracing-internal.js.map +1 -1
  126. package/dist/tracing/tracing-schema.d.ts +330 -49
  127. package/dist/tracing/tracing-schema.js +102 -10
  128. package/dist/tracing/tracing-schema.js.map +1 -1
  129. package/dist/workbench/workbench-command-execution.d.ts +6 -0
  130. package/dist/workbench/workbench-command-execution.js +48 -0
  131. package/dist/workbench/workbench-command-execution.js.map +1 -0
  132. package/dist/workbench/workbench-history.js +11 -18
  133. package/dist/workbench/workbench-history.js.map +1 -1
  134. package/dist/workbench/workbench-launch-session.d.ts +2 -2
  135. package/dist/workbench/workbench-launch-session.js.map +1 -1
  136. package/dist/workbench/workbench-run.d.ts +0 -4
  137. package/dist/workbench/workbench-run.js +3 -47
  138. package/dist/workbench/workbench-run.js.map +1 -1
  139. package/dist/workbench/workbench-studio-launcher.d.ts +27 -0
  140. package/dist/workbench/workbench-studio-launcher.js +95 -0
  141. package/dist/workbench/workbench-studio-launcher.js.map +1 -0
  142. package/dist/workbench/workbench-ui.js +10 -83
  143. package/dist/workbench/workbench-ui.js.map +1 -1
  144. package/docs/README.md +13 -7
  145. package/docs/agent-guide.md +69 -6
  146. package/docs/airflow.md +187 -0
  147. package/docs/api-reference.md +87 -76
  148. package/docs/api-report.json +17 -6
  149. package/docs/artifacts.md +173 -0
  150. package/docs/child-pipeline-composition.md +65 -2
  151. package/docs/comparison.md +20 -0
  152. package/docs/concepts.md +70 -2
  153. package/docs/dagster.md +161 -0
  154. package/docs/inngest.md +163 -0
  155. package/docs/llms.txt +30 -1
  156. package/docs/recipes.md +82 -33
  157. package/docs/remote-step-composition.md +6 -0
  158. package/docs/step-functions.md +190 -0
  159. package/docs/studio.md +31 -12
  160. package/docs/temporal.md +183 -0
  161. package/examples/airflow/contract.ts +46 -0
  162. package/examples/airflow/hosted.ts +70 -0
  163. package/examples/airflow/remote.ts +175 -0
  164. package/examples/airflow/tubeless_example.py +49 -0
  165. package/examples/airflow/worker.ts +24 -0
  166. package/examples/artifact-lineage.ts +70 -0
  167. package/examples/dagster/definitions.py +59 -0
  168. package/examples/dagster/hosted.ts +78 -0
  169. package/examples/dagster/pipeline.ts +62 -0
  170. package/examples/dagster/test_definitions.py +47 -0
  171. package/examples/dagster/tsconfig.build.json +10 -0
  172. package/examples/dagster/worker.ts +22 -0
  173. package/examples/inngest/client.ts +4 -0
  174. package/examples/inngest/functions.ts +65 -0
  175. package/examples/inngest/pipeline.ts +41 -0
  176. package/examples/inngest/send.ts +11 -0
  177. package/examples/inngest/server.ts +17 -0
  178. package/examples/inngest/tsconfig.build.json +10 -0
  179. package/examples/iteration.ts +52 -0
  180. package/examples/parameterized-steps.ts +96 -0
  181. package/examples/project/tubeless.project.ts +46 -0
  182. package/examples/step-functions/handler.ts +110 -0
  183. package/examples/step-functions/input.json +1 -0
  184. package/examples/step-functions/pipeline.ts +41 -0
  185. package/examples/step-functions/state-machine.asl.json +41 -0
  186. package/examples/step-functions/template.json +42 -0
  187. package/examples/step-output-overrides.ts +41 -0
  188. package/examples/temporal/activities.ts +94 -0
  189. package/examples/temporal/client.ts +19 -0
  190. package/examples/temporal/pipeline.ts +41 -0
  191. package/examples/temporal/tsconfig.build.json +10 -0
  192. package/examples/temporal/worker.ts +21 -0
  193. package/examples/temporal/workflows.ts +16 -0
  194. package/package.json +13 -4
  195. package/skills/tubeless/SKILL.md +30 -3
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline-run-state.js","sourceRoot":"","sources":["../../src/core/pipeline-run-state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAiCtD,MAAM,UAAU,kBAAkB,CAAC,MAAgC;IACjE,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC;AAClF,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAgC;IACzD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,WAAW,CAAC;IAC5C,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC7D,CAAC;AAED,SAAS,oBAAoB,CAC3B,KAAqE;IAErE,MAAM,IAAI,GAAG;QACX,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,YAAY,EAAE,KAAK,CAAC,YAAY;KACjC,CAAC;IACF,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;QACrB,KAAK,WAAW;YACd,OAAO;gBACL,GAAG,IAAI;gBACP,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,MAAM,EAAE,WAAW;aACpB,CAAC;QACJ,KAAK,QAAQ;YACX,OAAO;gBACL,GAAG,IAAI;gBACP,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,MAAM,EAAE,QAAQ;aACjB,CAAC;QACJ,KAAK,WAAW,EAAE,CAAC;Y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server } from \"./lifecycle.js\";\nimport { RUN_MODEL_VERSION } from \"./pipeline-ids.js\";\nimport type {\n PipelineError,\n PipelinePlan,\n PipelinePlanStep,\n PipelineRun,\n PipelineRunStatus,\n PipelineStepCancelledReport,\n PipelineStepCompleteReport,\n PipelineStepFailedReport,\n PipelineStepProgress,\n PipelineStepReport,\n PipelineStepSkipReason,\n PipelineStepSkippedReport,\n PipelineStepStatus,\n} from \"./pipeline-types.js\";\n\nexport interface PipelineStepAttempt {\n attemptId: string;\n startedAtMs: number;\n}\n\ntype RunPhase = \"created\" | \"finalizing\" | \"finished\" | \"running\";\n\ntype StepTransitionEffects = {\n error?: { record: boolean; value: PipelineError };\n output?: { value: unknown };\n};\n\ntype PipelineFinalization<TResult> =\n | { finalized: false; value: undefined }\n | { finalized: true; value: TResult };\n\nexport function isCancellationOnly(errors: readonly PipelineError[]): boolean {\n return errors.length > 0 && errors.every(({ kind }) => kind === \"cancellation\");\n}\n\nfunction terminalRunStatus(errors: readonly PipelineError[]): PipelineRunStatus {\n if (errors.length === 0) return \"completed\";\n return isCancellationOnly(errors) ? \"cancelled\" : \"failed\";\n}\n\nfunction stepReportFromStatus(\n event: Exclude<PipelineStepStatus, { status: \"planned\" | \"running\" }>\n): PipelineStepReport {\n const base = {\n id: event.id,\n name: event.name,\n description: event.description,\n finishedAtMs: event.finishedAtMs,\n };\n switch (event.status) {\n case \"completed\":\n return {\n ...base,\n attemptId: event.attemptId,\n startedAtMs: event.startedAtMs,\n status: \"completed\",\n };\n case \"failed\":\n return {\n ...base,\n attemptId: event.attemptId,\n error: event.error,\n startedAtMs: event.startedAtMs,\n status: \"failed\",\n };\n case \"cancelled\": {\n const report: PipelineStepCancelledReport = {\n ...base,\n error: event.error,\n status: \"cancelled\",\n };\n if (event.attemptId) report.attemptId = event.attemptId;\n if (event.startedAtMs !== undefined) report.startedAtMs = event.startedAtMs;\n return report;\n }\n case \"skipped\": {\n const report: PipelineStepSkippedReport = {\n ...base,\n reason: event.reason,\n status: \"skipped\",\n };\n if (event.attemptId) report.attemptId = event.attemptId;\n if (event.startedAtMs !== undefined) report.startedAtMs = event.startedAtMs;\n if (event.dependencyId) report.dependencyId = event.dependencyId;\n if (event.message) report.message = event.message;\n return report;\n }\n }\n}\n\nexport class PipelineRunState<TResult> {\n readonly #currentStepStatuses = new Map<string, PipelineStepStatus[\"status\"]>();\n readonly #errors: PipelineError[] = [];\n readonly #runErrors = new Set<PipelineError>();\n readonly #outputs = new Map<string, unknown>();\n readonly #stepOrder = new Map<string, number>();\n readonly #reportsByStepId = new Map<string, PipelineStepReport>();\n #definitionIdentity: PipelineRun[\"definitionIdentity\"];\n #finalizationAttempted = false;\n #finalization: PipelineFinalization<TResult> = { finalized: false, value: undefined };\n #nextAttemptSequence = 0;\n #phase: RunPhase = \"created\";\n\n constructor(\n readonly pipelineId: string,\n readonly dryRun: boolean,\n readonly startedAtMs: number,\n readonly identity: { correlationId?: string; parentRunId?: string; runId: string },\n readonly now: () => number,\n readonly lifecycle: PipelineLifecycleObserver\n ) {}\n\n get errors(): readonly PipelineError[] {\n return this.#errors;\n }\n\n get outputs(): ReadonlyMap<string, unknown> {\n return this.#outputs;\n }\n\n get reportsByStepId(): ReadonlyMap<string, PipelineStepReport> {\n return this.#reportsByStepId;\n }\n\n start(plan: PipelinePlan, targetIds: readonly string[]): void {\n this.#expectPhase(\"created\");\n this.#phase = \"running\";\n this.#definitionIdentity = plan.definition?.identity;\n plan.steps.forEach((step, index) => this.#stepOrder.set(step.id, index));\n this.lifecycle.pipelineStart(plan, targetIds);\n }\n\n planStep(step: PipelinePlanStep): void {\n this.#applyStepStatus({ pipelineId: this.pipelineId, status: \"planned\", step });\n }\n\n beginAttempt(step: PipelinePlanStep, startedAtMs = this.now()): PipelineStepAttempt {\n const attempt = {\n attemptId: `${this.identity.runId}:attempt:${(this.#nextAttemptSequence += 1).toString(36)}`,\n startedAtMs,\n };\n this.#applyStepStatus({\n attemptId: attempt.attemptId,\n pipelineId: this.pipelineId,\n status: \"running\",\n step,\n });\n return attempt;\n }\n\n reportProgress(\n step: PipelinePlanStep,\n attempt: PipelineStepAttempt,\n progress: PipelineStepProgress\n ): void {\n this.#applyStepStatus({\n attemptId: attempt.attemptId,\n pipelineId: this.pipelineId,\n progress,\n status: \"running\",\n step,\n });\n }\n\n completeStep(step: PipelinePlanStep, attempt: PipelineStepAttempt, value: unknown): void {\n const report: PipelineStepCompleteReport = {\n attemptId: attempt.attemptId,\n id: step.id,\n name: step.name,\n description: step.description,\n finishedAtMs: this.now(),\n startedAtMs: attempt.startedAtMs,\n status: \"completed\",\n };\n this.#applyStepStatus({ ...report, pipelineId: this.pipelineId, step }, { output: { value } });\n }\n\n skipStep(\n step: PipelinePlanStep,\n input: {\n attempt?: PipelineStepAttempt;\n dependencyId?: string;\n message?: string;\n output?: { value: unknown };\n reason: PipelineStepSkipReason;\n }\n ): void {\n const report: PipelineStepSkippedReport = {\n id: step.id,\n name: step.name,\n description: step.description,\n finishedAtMs: this.now(),\n reason: input.reason,\n status: \"skipped\",\n };\n if (input.attempt) {\n report.attemptId = input.attempt.attemptId;\n report.startedAtMs = input.attempt.startedAtMs;\n }\n if (input.dependencyId) report.dependencyId = input.dependencyId;\n if (input.message) report.message = input.message;\n this.#applyStepStatus(\n { ...report, pipelineId: this.pipelineId, step },\n input.output ? { output: input.output } : undefined\n );\n }\n\n failStep(step: PipelinePlanStep, attempt: PipelineStepAttempt, error: PipelineError): void {\n if (error.kind === \"cancellation\") {\n this.cancelStep(step, error, true, attempt);\n return;\n }\n const report: PipelineStepFailedReport = {\n attemptId: attempt.attemptId,\n id: step.id,\n name: step.name,\n description: step.description,\n error,\n finishedAtMs: this.now(),\n startedAtMs: attempt.startedAtMs,\n status: \"failed\",\n };\n this.#applyStepStatus(\n { ...report, pipelineId: this.pipelineId, step },\n { error: { record: true, value: error } }\n );\n }\n\n cancelStep(\n step: PipelinePlanStep,\n error: PipelineError,\n recordError: boolean,\n attempt?: PipelineStepAttempt\n ): void {\n const report: PipelineStepCancelledReport = {\n id: step.id,\n name: step.name,\n description: step.description,\n error,\n finishedAtMs: this.now(),\n status: \"cancelled\",\n };\n if (attempt) {\n report.attemptId = attempt.attemptId;\n report.startedAtMs = attempt.startedAtMs;\n }\n this.#applyStepStatus(\n { ...report, pipelineId: this.pipelineId, step },\n { error: { record: recordError, value: error } }\n );\n }\n\n recordRunErrors(errors: readonly PipelineError[]): void {\n this.#expectPhase(\"running\");\n for (const error of errors) this.#runErrors.add(error);\n this.#errors.push(...errors);\n }\n\n beginFinalization(): void {\n this.#expectPhase(\"running\");\n this.#expectAllStepsTerminal();\n if (this.#finalizationAttempted) throw new Error(\"Pipeline finalization already attempted\");\n this.#finalizationAttempted = true;\n this.#phase = \"finalizing\";\n this.lifecycle.finalizeStart();\n }\n\n completeFinalization(value: TResult, durationMs: number): void {\n this.#expectPhase(\"finalizing\");\n this.#finalization = { finalized: true, value };\n this.#phase = \"running\";\n this.lifecycle.finalizeComplete(durationMs, value);\n }\n\n failFinalization(error: PipelineError, durationMs: number): void {\n this.#expectPhase(\"finalizing\");\n this.#errors.push(error);\n this.#phase = \"running\";\n this.lifecycle.finalizeError(error, durationMs);\n }\n\n async finish(): Promise<PipelineRun<TResult>> {\n this.#expectPhase(\"running\");\n this.#expectAllStepsTerminal();\n this.#phase = \"finished\";\n const errorOrder = (error: PipelineError): number => {\n // A run-level diagnostic may identify a step without becoming a step failure.\n if (this.#runErrors.has(error)) return -1;\n if (error.phase === \"finalization\") return this.#stepOrder.size;\n return error.stepId === undefined ? -1 : (this.#stepOrder.get(error.stepId) ?? -1);\n };\n // Live observations retain event order; only the finished record is ordered by plan.\n const errors = [...this.#errors].sort((left, right) => errorOrder(left) - errorOrder(right));\n const steps = [...this.#reportsByStepId.values()].sort(\n (left, right) => this.#stepOrder.get(left.id)! - this.#stepOrder.get(right.id)!\n );\n const result: PipelineRun<TResult> = {\n pipelineId: this.pipelineId,\n dryRun: this.dryRun,\n errors,\n finishedAtMs: this.now(),\n runId: this.identity.runId,\n startedAtMs: this.startedAtMs,\n status: terminalRunStatus(this.#errors),\n steps,\n version: RUN_MODEL_VERSION,\n ...this.#finalization,\n };\n if (this.#definitionIdentity) result.definitionIdentity = this.#definitionIdentity;\n if (this.identity.correlationId !== undefined) {\n result.correlationId = this.identity.correlationId;\n }\n if (this.identity.parentRunId) result.parentRunId = this.identity.parentRunId;\n this.lifecycle.pipelineComplete(result);\n await this.lifecycle.flush();\n return result;\n }\n\n #applyStepStatus(event: PipelineStepStatus, effects: StepTransitionEffects = {}): void {\n this.#expectPhase(\"running\");\n const previous = this.#currentStepStatuses.get(event.step.id);\n const valid =\n (previous === undefined && event.status === \"planned\") ||\n (previous === \"planned\" &&\n (event.status === \"running\" ||\n event.status === \"skipped\" ||\n event.status === \"cancelled\")) ||\n (previous === \"running\" &&\n (event.status === \"running\" ||\n event.status === \"completed\" ||\n event.status === \"skipped\" ||\n event.status === \"cancelled\" ||\n event.status === \"failed\"));\n if (!valid) {\n throw new Error(\n `Invalid step status transition for ${event.step.id}: ${previous ?? \"unobserved\"} -> ${event.status}`\n );\n }\n\n this.#currentStepStatuses.set(event.step.id, event.status);\n if (event.status !== \"planned\" && event.status !== \"running\") {\n const report = stepReportFromStatus(event);\n this.#reportsByStepId.set(event.step.id, report);\n }\n if (effects.output) this.#outputs.set(event.step.id, effects.output.value);\n if (effects.error?.record) this.#errors.push(effects.error.value);\n this.lifecycle.stepStatus(event);\n }\n\n #expectPhase(expected: RunPhase): void {\n if (this.#phase !== expected) {\n throw new Error(\n `Invalid pipeline run transition: expected ${expected}, found ${this.#phase}`\n );\n }\n }\n\n #expectAllStepsTerminal(): void {\n for (const [stepId, status] of this.#currentStepStatuses) {\n if (status === \"planned\" || status === \"running\") {\n throw new Error(`Cannot finish pipeline run while step ${stepId} is ${status}`);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"pipeline-run-state.js","sourceRoot":"","sources":["../../src/core/pipeline-run-state.ts"],"names":[],"mappings":"AAAA,O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SAAS,EAAE,CAAC;YAC7D,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;YAC3C,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QACnD,CAAC;QACD,IAAI,OAAO,CAAC,MAAM;YAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3E,IAAI,OAAO,CAAC,KAAK,EAAE,MAAM;YAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,YAAY,CAAC,QAAkB;QAC7B,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CACb,6CAA6C,QAAQ,WAAW,IAAI,CAAC,MAAM,EAAE,CAC9E,CAAC;QACJ,CAAC;IACH,CAAC;IAED,uBAAuB;QACrB,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YACzD,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACjD,MAAM,IAAI,KAAK,CAAC,yCAAyC,MAAM,OAAO,MAAM,EAAE,CAAC,CAAC;YAClF,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { isCancellationOnly } from \"./pipeline-execution-error.js\";\nimport type { PipelineLifecycleObserver } from \"./lifecycle.js\";\nimport { RUN_MODEL_VERSION } from \"./pipeline-ids.js\";\nimport type {\n PipelineError,\n PipelinePlan,\n PipelinePlanStep,\n PipelineRun,\n PipelineRunStatus,\n PipelineStepCancelledReport,\n PipelineStepCompleteReport,\n PipelineStepFailedReport,\n PipelineStepProgress,\n PipelineStepReport,\n PipelineStepSkipReason,\n PipelineStepSkippedReport,\n PipelineStepStatus,\n} from \"./pipeline-types.js\";\n\nexport interface PipelineStepAttempt {\n outputSource?: \"override\";\n attemptId: string;\n startedAtMs: number;\n}\n\ntype RunPhase = \"created\" | \"finalizing\" | \"finished\" | \"running\";\n\ntype StepTransitionEffects = {\n error?: { record: boolean; value: PipelineError };\n output?: { value: unknown };\n};\n\ntype PipelineFinalization<TResult> =\n | { finalized: false; value: undefined }\n | { finalized: true; value: TResult };\n\nfunction terminalRunStatus(errors: readonly PipelineError[]): PipelineRunStatus {\n if (errors.length === 0) return \"completed\";\n return isCancellationOnly(errors) ? \"cancelled\" : \"failed\";\n}\n\nfunction stepReportFromStatus(\n event: Exclude<PipelineStepStatus, { status: \"planned\" | \"running\" }>\n): PipelineStepReport {\n const base = {\n id: event.id,\n name: event.name,\n description: event.description,\n finishedAtMs: event.finishedAtMs,\n ...(event.outputSource ? { outputSource: event.outputSource } : {}),\n };\n switch (event.status) {\n case \"completed\":\n return {\n ...base,\n attemptId: event.attemptId,\n startedAtMs: event.startedAtMs,\n status: \"completed\",\n };\n case \"failed\":\n return {\n ...base,\n attemptId: event.attemptId,\n error: event.error,\n startedAtMs: event.startedAtMs,\n status: \"failed\",\n };\n case \"cancelled\": {\n const report: PipelineStepCancelledReport = {\n ...base,\n error: event.error,\n status: \"cancelled\",\n };\n if (event.attemptId) report.attemptId = event.attemptId;\n if (event.startedAtMs !== undefined) report.startedAtMs = event.startedAtMs;\n return report;\n }\n case \"skipped\": {\n const report: PipelineStepSkippedReport = {\n ...base,\n reason: event.reason,\n status: \"skipped\",\n };\n if (event.attemptId) report.attemptId = event.attemptId;\n if (event.startedAtMs !== undefined) report.startedAtMs = event.startedAtMs;\n if (event.dependencyId) report.dependencyId = event.dependencyId;\n if (event.message) report.message = event.message;\n return report;\n }\n }\n}\n\nexport class PipelineRunState<TResult> {\n readonly #currentStepStatuses = new Map<string, PipelineStepStatus[\"status\"]>();\n readonly #errors: PipelineError[] = [];\n readonly #runErrors = new Set<PipelineError>();\n readonly #outputs = new Map<string, unknown>();\n readonly #stepOrder = new Map<string, number>();\n readonly #reportsByStepId = new Map<string, PipelineStepReport>();\n #definitionIdentity: PipelineRun[\"definitionIdentity\"];\n #finalizationAttempted = false;\n #finalization: PipelineFinalization<TResult> = { finalized: false, value: undefined };\n #nextAttemptSequence = 0;\n #phase: RunPhase = \"created\";\n\n constructor(\n readonly pipelineId: string,\n readonly dryRun: boolean,\n readonly startedAtMs: number,\n readonly identity: { correlationId?: string; parentRunId?: string; runId: string },\n readonly now: () => number,\n readonly lifecycle: Pick<\n PipelineLifecycleObserver,\n | \"pipelineStart\"\n | \"stepStatus\"\n | \"finalizeStart\"\n | \"finalizeComplete\"\n | \"finalizeError\"\n | \"pipelineComplete\"\n | \"flush\"\n >\n ) {}\n\n get errors(): readonly PipelineError[] {\n return this.#errors;\n }\n\n get outputs(): ReadonlyMap<string, unknown> {\n return this.#outputs;\n }\n\n get reportsByStepId(): ReadonlyMap<string, PipelineStepReport> {\n return this.#reportsByStepId;\n }\n\n start(plan: PipelinePlan, targetIds: readonly string[]): void {\n this.#expectPhase(\"created\");\n this.#phase = \"running\";\n this.#definitionIdentity = plan.definition?.identity;\n plan.steps.forEach((step, index) => this.#stepOrder.set(step.id, index));\n this.lifecycle.pipelineStart(plan, targetIds);\n }\n\n planStep(step: PipelinePlanStep): void {\n this.#applyStepStatus({ pipelineId: this.pipelineId, status: \"planned\", step });\n }\n\n beginAttempt(\n step: PipelinePlanStep,\n startedAtMs = this.now(),\n outputSource?: \"override\"\n ): PipelineStepAttempt {\n const attempt = {\n attemptId: `${this.identity.runId}:attempt:${(this.#nextAttemptSequence += 1).toString(36)}`,\n startedAtMs,\n ...(outputSource ? { outputSource } : {}),\n };\n this.#applyStepStatus({\n attemptId: attempt.attemptId,\n ...(attempt.outputSource ? { outputSource: attempt.outputSource } : {}),\n pipelineId: this.pipelineId,\n status: \"running\",\n step,\n });\n return attempt;\n }\n\n reportProgress(\n step: PipelinePlanStep,\n attempt: PipelineStepAttempt,\n progress: PipelineStepProgress\n ): void {\n this.#applyStepStatus({\n attemptId: attempt.attemptId,\n ...(attempt.outputSource ? { outputSource: attempt.outputSource } : {}),\n pipelineId: this.pipelineId,\n progress,\n status: \"running\",\n step,\n });\n }\n\n completeStep(step: PipelinePlanStep, attempt: PipelineStepAttempt, value: unknown): void {\n const report: PipelineStepCompleteReport = {\n ...attempt,\n id: step.id,\n name: step.name,\n description: step.description,\n finishedAtMs: this.now(),\n status: \"completed\",\n };\n this.#applyStepStatus({ ...report, pipelineId: this.pipelineId, step }, { output: { value } });\n }\n\n skipStep(\n step: PipelinePlanStep,\n input: {\n attempt?: PipelineStepAttempt;\n dependencyId?: string;\n message?: string;\n output?: { value: unknown };\n reason: PipelineStepSkipReason;\n }\n ): void {\n const report: PipelineStepSkippedReport = {\n ...input.attempt,\n id: step.id,\n name: step.name,\n description: step.description,\n finishedAtMs: this.now(),\n reason: input.reason,\n status: \"skipped\",\n };\n if (input.dependencyId) report.dependencyId = input.dependencyId;\n if (input.message) report.message = input.message;\n this.#applyStepStatus(\n { ...report, pipelineId: this.pipelineId, step },\n input.output ? { output: input.output } : undefined\n );\n }\n\n failStep(step: PipelinePlanStep, attempt: PipelineStepAttempt, error: PipelineError): void {\n if (error.kind === \"cancellation\") {\n this.cancelStep(step, error, true, attempt);\n return;\n }\n const report: PipelineStepFailedReport = {\n ...attempt,\n id: step.id,\n name: step.name,\n description: step.description,\n error,\n finishedAtMs: this.now(),\n status: \"failed\",\n };\n this.#applyStepStatus(\n { ...report, pipelineId: this.pipelineId, step },\n { error: { record: true, value: error } }\n );\n }\n\n cancelStep(\n step: PipelinePlanStep,\n error: PipelineError,\n recordError: boolean,\n attempt?: PipelineStepAttempt\n ): void {\n const report: PipelineStepCancelledReport = {\n ...attempt,\n id: step.id,\n name: step.name,\n description: step.description,\n error,\n finishedAtMs: this.now(),\n status: \"cancelled\",\n };\n this.#applyStepStatus(\n { ...report, pipelineId: this.pipelineId, step },\n { error: { record: recordError, value: error } }\n );\n }\n\n recordRunErrors(errors: readonly PipelineError[]): void {\n this.#expectPhase(\"running\");\n for (const error of errors) this.#runErrors.add(error);\n this.#errors.push(...errors);\n }\n\n beginFinalization(): void {\n this.#expectPhase(\"running\");\n this.#expectAllStepsTerminal();\n if (this.#finalizationAttempted) throw new Error(\"Pipeline finalization already attempted\");\n this.#finalizationAttempted = true;\n this.#phase = \"finalizing\";\n this.lifecycle.finalizeStart();\n }\n\n completeFinalization(value: TResult, durationMs: number): void {\n this.#expectPhase(\"finalizing\");\n this.#finalization = { finalized: true, value };\n this.#phase = \"running\";\n this.lifecycle.finalizeComplete(durationMs, value);\n }\n\n failFinalization(error: PipelineError, durationMs: number): void {\n this.#expectPhase(\"finalizing\");\n this.#errors.push(error);\n this.#phase = \"running\";\n this.lifecycle.finalizeError(error, durationMs);\n }\n\n async finish(): Promise<PipelineRun<TResult>> {\n this.#expectPhase(\"running\");\n this.#expectAllStepsTerminal();\n this.#phase = \"finished\";\n const errorOrder = (error: PipelineError): number => {\n // A run-level diagnostic may identify a step without becoming a step failure.\n if (this.#runErrors.has(error)) return -1;\n if (error.phase === \"finalization\") return this.#stepOrder.size;\n return error.stepId === undefined ? -1 : (this.#stepOrder.get(error.stepId) ?? -1);\n };\n // Live observations retain event order; only the finished record is ordered by plan.\n const errors = [...this.#errors].sort((left, right) => errorOrder(left) - errorOrder(right));\n const steps = [...this.#reportsByStepId.values()].sort(\n (left, right) => this.#stepOrder.get(left.id)! - this.#stepOrder.get(right.id)!\n );\n const result: PipelineRun<TResult> = {\n pipelineId: this.pipelineId,\n dryRun: this.dryRun,\n errors,\n finishedAtMs: this.now(),\n runId: this.identity.runId,\n startedAtMs: this.startedAtMs,\n status: terminalRunStatus(this.#errors),\n steps,\n version: RUN_MODEL_VERSION,\n ...this.#finalization,\n };\n if (this.#definitionIdentity) result.definitionIdentity = this.#definitionIdentity;\n if (this.identity.correlationId !== undefined) {\n result.correlationId = this.identity.correlationId;\n }\n if (this.identity.parentRunId) result.parentRunId = this.identity.parentRunId;\n this.lifecycle.pipelineComplete(result);\n await this.lifecycle.flush();\n return result;\n }\n\n #applyStepStatus(event: PipelineStepStatus, effects: StepTransitionEffects = {}): void {\n this.#expectPhase(\"running\");\n const previous = this.#currentStepStatuses.get(event.step.id);\n const valid =\n (previous === undefined && event.status === \"planned\") ||\n (previous === \"planned\" &&\n (event.status === \"running\" ||\n event.status === \"skipped\" ||\n event.status === \"cancelled\")) ||\n (previous === \"running\" &&\n (event.status === \"running\" ||\n event.status === \"completed\" ||\n event.status === \"skipped\" ||\n event.status === \"cancelled\" ||\n event.status === \"failed\"));\n if (!valid) {\n throw new Error(\n `Invalid step status transition for ${event.step.id}: ${previous ?? \"unobserved\"} -> ${event.status}`\n );\n }\n\n this.#currentStepStatuses.set(event.step.id, event.status);\n if (event.status !== \"planned\" && event.status !== \"running\") {\n const report = stepReportFromStatus(event);\n this.#reportsByStepId.set(event.step.id, report);\n }\n if (effects.output) this.#outputs.set(event.step.id, effects.output.value);\n if (effects.error?.record) this.#errors.push(effects.error.value);\n this.lifecycle.stepStatus(event);\n }\n\n #expectPhase(expected: RunPhase): void {\n if (this.#phase !== expected) {\n throw new Error(\n `Invalid pipeline run transition: expected ${expected}, found ${this.#phase}`\n );\n }\n }\n\n #expectAllStepsTerminal(): void {\n for (const [stepId, status] of this.#currentStepStatuses) {\n if (status === \"planned\" || status === \"running\") {\n throw new Error(`Cannot finish pipeline run while step ${stepId} is ${status}`);\n }\n }\n }\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { type ArtifactRecord } from "../tracing/artifact-metadata.js";
1
2
  import type { AnyStep } from "./pipeline-steps.js";
2
3
  import type { PipelineExecutionContext, PipelineLogger, PipelineStepProgress } from "./pipeline-types.js";
3
4
  import type { PipelineTraceAttributes } from "../tracing/tracing-contracts.js";
@@ -13,6 +14,7 @@ export declare function executeStepAttempt<TOptions extends object>(input: {
13
14
  dryRun: boolean;
14
15
  inputs: Record<string, unknown>;
15
16
  log: PipelineLogger;
17
+ onArtifact?(record: ArtifactRecord, preview: boolean): void;
16
18
  onProgress(progress: PipelineStepProgress): void;
17
19
  onReportAttempt(attempt: number, attributes?: PipelineTraceAttributes): void;
18
20
  outputBoundary: string;
@@ -1,3 +1,4 @@
1
+ import { artifactRecordSchema } from "../tracing/artifact-metadata.js";
1
2
  import { validateStandardSchema } from "./pipeline-validation.js";
2
3
  function normalizeStepSkipDecision(decision) {
3
4
  if (decision == null || decision === false)
@@ -26,14 +27,21 @@ export async function validateStepOutput(step, value, boundary) {
26
27
  }
27
28
  export async function executeStepAttempt(input) {
28
29
  const { step } = input;
29
- let acceptsProgress = true;
30
+ let acceptsReports = true;
30
31
  const stepContext = {
31
32
  ...input.context,
33
+ recordArtifact: (record) => {
34
+ if (!acceptsReports)
35
+ return;
36
+ const snapshot = artifactRecordSchema.decode(record, "artifact record");
37
+ const preview = input.dryRun && (typeof step.dryRun === "function" || snapshot.operation === "write");
38
+ input.onArtifact?.(snapshot, preview);
39
+ },
32
40
  attemptId: input.attemptId,
33
41
  log: input.log,
34
42
  reportAttempt: input.onReportAttempt,
35
43
  reportProgress: (progress) => {
36
- if (acceptsProgress)
44
+ if (acceptsReports)
37
45
  input.onProgress(progress);
38
46
  },
39
47
  };
@@ -45,7 +53,7 @@ export async function executeStepAttempt(input) {
45
53
  : await step.run(input.inputs, stepContext);
46
54
  }
47
55
  finally {
48
- acceptsProgress = false;
56
+ acceptsReports = false;
49
57
  }
50
58
  return validateStepOutput(step, output, input.outputBoundary);
51
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline-step-executor.js","sourceRoot":"","sources":["../../src/core/pipeline-step-executor.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAOlE,SAAS,yBAAyB,CAAC,QAA0B;IAC3D,IA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AE,IAAI,EAAE,GAAG,KAAK,CAAC;IACvB,IAAI,eAAe,GAAG,IAAI,CAAC;IAC3B,MAAM,WAAW,GAAG;QAClB,GAAG,KAAK,CAAC,OAAO;QAChB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,aAAa,EAAE,KAAK,CAAC,eAAe;QACpC,cAAc,EAAE,CAAC,QAA8B,EAAE,EAAE;YACjD,IAAI,eAAe;gBAAE,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAClD,CAAC;KACF,CAAC;IACF,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM;YACJ,KAAK,CAAC,MAAM,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,UAAU;gBAC/C,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC;gBAC9C,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAClD,CAAC;YAAS,CAAC;QACT,eAAe,GAAG,KAAK,CAAC;IAC1B,CAAC;IACD,OAAO,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import type { AnyStep } from \"./pipeline-steps.js\";\nimport type {\n PipelineExecutionContext,\n PipelineLogger,\n PipelineStepProgress,\n StepSkipDecision,\n} from \"./pipeline-types.js\";\nimport type { PipelineTraceAttributes } from \"../tracing/tracing-contracts.js\";\nimport { validateStandardSchema } from \"./pipeline-validation.js\";\n\nexport interface NormalizedStepSkipDecision {\n reason: string;\n value?: unknown;\n}\n\nfunction normalizeStepSkipDecision(decision: StepSkipDecision): NormalizedStepSkipDecision | null {\n if (decision == null || decision === false) return null;\n if (typeof decision === \"string\") {\n const reason = decision.trim();\n return reason.length > 0 ? { reason } : null;\n }\n if (typeof decision === \"object\" && typeof decision.reason === \"string\") {\n const reason = decision.reason.trim();\n if (reason.length === 0) return null;\n return { reason, value: decision.value };\n }\n return null;\n}\n\nexport async function evaluateStepSkip<TOptions extends object>(\n step: AnyStep<TOptions>,\n inputs: Record<string, unknown>,\n context: PipelineExecutionContext<TOptions>\n): Promise<NormalizedStepSkipDecision | null> {\n if (typeof step.skip !== \"function\") return null;\n return normalizeStepSkipDecision(await step.skip(inputs, context));\n}\n\nexport async function validateStepOutput<TOptions extends object>(\n step: AnyStep<TOptions>,\n value: unknown,\n boundary: string\n): Promise<unknown> {\n return step.outputSchema\n ? validateStandardSchema(step.outputSchema, value, boundary)\n : Promise.resolve(value);\n}\n\nexport async function executeStepAttempt<TOptions extends object>(input: {\n attemptId: string;\n context: PipelineExecutionContext<TOptions>;\n dryRun: boolean;\n inputs: Record<string, unknown>;\n log: PipelineLogger;\n onProgress(progress: PipelineStepProgress): void;\n onReportAttempt(attempt: number, attributes?: PipelineTraceAttributes): void;\n outputBoundary: string;\n step: AnyStep<TOptions>;\n}): Promise<unknown> {\n const { step } = input;\n let acceptsProgress = true;\n const stepContext = {\n ...input.context,\n attemptId: input.attemptId,\n log: input.log,\n reportAttempt: input.onReportAttempt,\n reportProgress: (progress: PipelineStepProgress) => {\n if (acceptsProgress) input.onProgress(progress);\n },\n };\n let output: unknown;\n try {\n output =\n input.dryRun && typeof step.dryRun === \"function\"\n ? await step.dryRun(input.inputs, stepContext)\n : await step.run(input.inputs, stepContext);\n } finally {\n acceptsProgress = false;\n }\n return validateStepOutput(step, output, input.outputBoundary);\n}\n"]}
1
+ {"version":3,"file":"pipeline-step-executor.js","sourceRoot":"","sources":["../../src/core/pipeline-step-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAuB,MAAM,iCAAiC,CAAC;AAS5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAOlE,SAAS,yBAAyB,CAAC,QAA0B;IAC3D,IAAI,QAAQ,IAAI,IAA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act-metadata.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport type {\n PipelineExecutionContext,\n PipelineLogger,\n PipelineStepProgress,\n StepSkipDecision,\n} from \"./pipeline-types.js\";\nimport type { PipelineTraceAttributes } from \"../tracing/tracing-contracts.js\";\nimport { validateStandardSchema } from \"./pipeline-validation.js\";\n\nexport interface NormalizedStepSkipDecision {\n reason: string;\n value?: unknown;\n}\n\nfunction normalizeStepSkipDecision(decision: StepSkipDecision): NormalizedStepSkipDecision | null {\n if (decision == null || decision === false) return null;\n if (typeof decision === \"string\") {\n const reason = decision.trim();\n return reason.length > 0 ? { reason } : null;\n }\n if (typeof decision === \"object\" && typeof decision.reason === \"string\") {\n const reason = decision.reason.trim();\n if (reason.length === 0) return null;\n return { reason, value: decision.value };\n }\n return null;\n}\n\nexport async function evaluateStepSkip<TOptions extends object>(\n step: AnyStep<TOptions>,\n inputs: Record<string, unknown>,\n context: PipelineExecutionContext<TOptions>\n): Promise<NormalizedStepSkipDecision | null> {\n if (typeof step.skip !== \"function\") return null;\n return normalizeStepSkipDecision(await step.skip(inputs, context));\n}\n\nexport async function validateStepOutput<TOptions extends object>(\n step: AnyStep<TOptions>,\n value: unknown,\n boundary: string\n): Promise<unknown> {\n return step.outputSchema\n ? validateStandardSchema(step.outputSchema, value, boundary)\n : Promise.resolve(value);\n}\n\nexport async function executeStepAttempt<TOptions extends object>(input: {\n attemptId: string;\n context: PipelineExecutionContext<TOptions>;\n dryRun: boolean;\n inputs: Record<string, unknown>;\n log: PipelineLogger;\n onArtifact?(record: ArtifactRecord, preview: boolean): void;\n onProgress(progress: PipelineStepProgress): void;\n onReportAttempt(attempt: number, attributes?: PipelineTraceAttributes): void;\n outputBoundary: string;\n step: AnyStep<TOptions>;\n}): Promise<unknown> {\n const { step } = input;\n let acceptsReports = true;\n const stepContext = {\n ...input.context,\n recordArtifact: (record: ArtifactRecord) => {\n if (!acceptsReports) return;\n const snapshot = artifactRecordSchema.decode(record, \"artifact record\");\n const preview =\n input.dryRun && (typeof step.dryRun === \"function\" || snapshot.operation === \"write\");\n input.onArtifact?.(snapshot, preview);\n },\n attemptId: input.attemptId,\n log: input.log,\n reportAttempt: input.onReportAttempt,\n reportProgress: (progress: PipelineStepProgress) => {\n if (acceptsReports) input.onProgress(progress);\n },\n };\n let output: unknown;\n try {\n output =\n input.dryRun && typeof step.dryRun === \"function\"\n ? await step.dryRun(input.inputs, stepContext)\n : await step.run(input.inputs, stepContext);\n } finally {\n acceptsReports = false;\n }\n return validateStepOutput(step, output, input.outputBoundary);\n}\n"]}
@@ -1,3 +1,5 @@
1
+ import { type ArtifactLoader, type ArtifactSaver, type ArtifactResult } from "./pipeline-artifacts.js";
2
+ import { type IterationDecision, type IterationState } from "./iteration.js";
1
3
  import type { ToMappedChildStepProgressOptions } from "./mapped-child-progress.js";
2
4
  import { STEP_NESTED_PIPELINE, STEP_OPTIONS_SCHEMA, STEP_REMOTE } from "./pipeline-step-metadata.js";
3
5
  import type { InferSchemaInput, InferSchemaOutput, Pipeline, PipelineExecutionContext, PipelinePlanStep, PipelineRun, PipelineRunControls, PipelineStepContext, RemoteStepAdapter, StandardSchemaV1, StepSkipDecision } from "./pipeline-types.js";
@@ -168,6 +170,12 @@ declare function createStepFactory<TOptions extends object, TInputOptions extend
168
170
  skip?: never;
169
171
  }): TOptionsSchema extends StandardSchemaV1<unknown, unknown> ? Step<TId, TOut, TOptions, TInputOptions, TOut, TOptionsSchema> : Step<TId, TOut, TOptions, TInputOptions, TOut, StandardSchemaV1<unknown, unknown> | undefined>;
170
172
  };
173
+ loadArtifact: <TId extends string, const TDeps extends readonly AnyStep<TOptions>[] = [], const TOptionalDeps extends readonly AnyStep<TOptions>[] = [], TValue = unknown>(id: TId, definition: Omit<PlainStepFields<TOptions, TDeps, TOptionalDeps, ArtifactResult<TValue>>, "run"> & {
174
+ load: ArtifactLoader<RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>, TValue, TOptions>;
175
+ }) => TOptionsSchema extends StandardSchemaV1<unknown, unknown> ? Step<TId, TValue, TOptions, TInputOptions, TValue, TOptionsSchema> : Step<TId, TValue, TOptions, TInputOptions, TValue, StandardSchemaV1<unknown, unknown> | undefined>;
176
+ saveArtifact: <TId extends string, const TDeps extends readonly AnyStep<TOptions>[] = [], const TOptionalDeps extends readonly AnyStep<TOptions>[] = [], TValue = unknown>(id: TId, definition: Omit<PlainStepFields<TOptions, TDeps, TOptionalDeps, ArtifactResult<TValue>>, "run"> & {
177
+ save: ArtifactSaver<RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>, TValue, TOptions>;
178
+ }) => TOptionsSchema extends StandardSchemaV1<unknown, unknown> ? Step<TId, TValue, TOptions, TInputOptions, TValue, TOptionsSchema> : Step<TId, TValue, TOptions, TInputOptions, TValue, StandardSchemaV1<unknown, unknown> | undefined>;
171
179
  fromPipeline: {
172
180
  <TId extends string, TChildPipeline extends Pipeline<object, unknown>, const TDeps extends readonly AnyStep<TOptions>[] = [], const TOptionalDeps extends readonly AnyStep<TOptions>[] = []>(id: TId, definition: ChildPipelineStepDefinition<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {
173
181
  skip?: never;
@@ -212,5 +220,17 @@ declare function createStepFactory<TOptions extends object, TInputOptions extend
212
220
  mapResult(value: PipelineResultOf<TChildPipeline>, result: PipelineRun<PipelineResultOf<TChildPipeline>>, item: TItem, index: number, context: PipelineStepContext<TOptions>): TOut;
213
221
  }): TOptionsSchema extends StandardSchemaV1<unknown, unknown> ? Step<TId, PolicySkippedOutput<readonly TOut[], TDecision>, TOptions, TInputOptions, PolicySkippedOutput<readonly TOut[], TDecision>, TOptionsSchema> : Step<TId, PolicySkippedOutput<readonly TOut[], TDecision>, TOptions, TInputOptions, PolicySkippedOutput<readonly TOut[], TDecision>, StandardSchemaV1<unknown, unknown> | undefined>;
214
222
  };
223
+ iteratePipeline: <const TId extends string, TChild extends Pipeline<object, unknown>, TState, TResult, const TDeps extends readonly AnyStep<TOptions>[] = []>(id: TId, definition: {
224
+ pipeline: TChild;
225
+ name?: string;
226
+ description?: string;
227
+ dependsOn?: TDeps;
228
+ maxIterations: number;
229
+ dryRun?: "skip";
230
+ controls?: PipelineRunControlsOf<TChild>;
231
+ initialState(inputs: RequiredInputs<TDeps>, context: PipelineExecutionContext<TOptions>): TState;
232
+ mapOptions(state: IterationState<NoInfer<TState>>, inputs: RequiredInputs<TDeps>, context: PipelineExecutionContext<TOptions>): PipelineOptionsOf<TChild>;
233
+ transition(result: PipelineResultOf<TChild>, state: IterationState<NoInfer<TState>>, context: PipelineExecutionContext<TOptions>): IterationDecision<NoInfer<TState>, TResult> | Promise<IterationDecision<NoInfer<TState>, TResult>>;
234
+ }) => TOptionsSchema extends StandardSchemaV1<unknown, unknown> ? Step<TId, Awaited<TResult>, TOptions, TInputOptions, Awaited<TResult>, TOptionsSchema> : Step<TId, Awaited<TResult>, TOptions, TInputOptions, Awaited<TResult>, StandardSchemaV1<unknown, unknown> | undefined>;
215
235
  };
216
236
  export {};
@@ -1,4 +1,6 @@
1
+ import {} from "./pipeline-artifacts.js";
1
2
  import { createMappedChildRunner, createSingleChildRunner } from "./child-execution.js";
3
+ import { createIterationRunner } from "./iteration.js";
2
4
  import { STEP_NESTED_PIPELINE, STEP_OPTIONS_SCHEMA, STEP_REMOTE, } from "./pipeline-step-metadata.js";
3
5
  export function createSteps(optionsSchema) {
4
6
  return createStepFactory(optionsSchema);
@@ -14,6 +16,34 @@ function createStepFactory(optionsSchema) {
14
16
  function step(id, definition) {
15
17
  return buildStep(id, definition);
16
18
  }
19
+ /** Read an artifact as an ordinary step, publishing only its typed value. */
20
+ function loadArtifact(id, definition) {
21
+ const { load, dryRun, ...fields } = definition;
22
+ const wrap = (handler) => async (inputs, context) => {
23
+ const loaded = await handler(inputs, context);
24
+ context.recordArtifact({ operation: "read", artifact: loaded.artifact });
25
+ return loaded.value;
26
+ };
27
+ return step(id, {
28
+ ...fields,
29
+ run: wrap(load),
30
+ dryRun: typeof dryRun === "function" ? wrap(dryRun) : dryRun,
31
+ });
32
+ }
33
+ /** Write an artifact as an ordinary step. Dry runs skip unless a preview is supplied. */
34
+ function saveArtifact(id, definition) {
35
+ const { save, dryRun, ...fields } = definition;
36
+ const wrap = (handler) => async (inputs, context) => {
37
+ const saved = await handler(inputs, context);
38
+ context.recordArtifact({ operation: "write", artifact: saved.artifact });
39
+ return saved.value;
40
+ };
41
+ return step(id, {
42
+ ...fields,
43
+ run: wrap(save),
44
+ dryRun: typeof dryRun === "function" ? wrap(dryRun) : "skip",
45
+ });
46
+ }
17
47
  const buildPipelineStep = (id, config) => {
18
48
  const definition = {
19
49
  [STEP_NESTED_PIPELINE]: {
@@ -89,11 +119,43 @@ function createStepFactory(optionsSchema) {
89
119
  function forEachPipeline(id, definition) {
90
120
  return buildMappedPipelineStep(id, definition);
91
121
  }
122
+ function iteratePipeline(id, definition) {
123
+ if (!Number.isSafeInteger(definition.maxIterations) || definition.maxIterations < 1) {
124
+ throw new RangeError("iteratePipeline maxIterations must be a positive safe integer");
125
+ }
126
+ const controls = definition.controls ? structuredClone(definition.controls) : undefined;
127
+ if (controls) {
128
+ if (controls.targets)
129
+ Object.freeze(controls.targets);
130
+ if (controls.stepIds)
131
+ Object.freeze(controls.stepIds);
132
+ Object.freeze(controls);
133
+ }
134
+ const config = { ...definition, stepId: id, controls };
135
+ return buildStep(id, {
136
+ [STEP_NESTED_PIPELINE]: {
137
+ mode: "iterate",
138
+ maxIterations: config.maxIterations,
139
+ controls: config.controls,
140
+ pipelineId: config.pipeline.id,
141
+ identity: config.pipeline.definition?.identity,
142
+ stepIds: config.pipeline.stepIds,
143
+ },
144
+ name: config.name,
145
+ description: config.description,
146
+ dependsOn: config.dependsOn,
147
+ dryRun: config.dryRun,
148
+ run: createIterationRunner(config),
149
+ });
150
+ }
92
151
  const factory = {
93
152
  step,
153
+ loadArtifact,
154
+ saveArtifact,
94
155
  fromPipeline,
95
156
  fromRemote,
96
157
  forEachPipeline,
158
+ iteratePipeline,
97
159
  };
98
160
  return factory;
99
161
  }
@@ -1 +1 @@
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,SAAS,iBAAiB,CAIxB,aAA8B;IAY9B,MAAM,SAAS,GAAG,CAAC,EAAU,EAAE,UAAwC,EAAqB,EAAE;QAC5F,MAAM,KAAK,GAAsB,EAAE,EAAE,EAAE,GAAG,UAAU,EAAE,CAAC;QACvD,IAAI,aAAa,EAAE,CAAC;YAClB,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,mBAAmB,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;QAC9E,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAsDF,SAAS,IAAI,CAAC,EAAU,EAAE,UAAwC;QAChE,OAAO,SAAS,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;IACnC,CAAC;IAED,MAAM,iBAAiB,GAAG,CACxB,EAAU,EACV,MAiBC,EACD,EAAE;QACF,MAAM,UAAU,GAAiC;YAC/C,CAAC,oBAAoB,CAAC,EAAE;gBACtB,IAAI,EAAE,QAAiB;gBACvB,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE;gBAC9B,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ;gBAC9C,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO;aACjC;YACD,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;YAC3C,kBAAkB,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AAU,CAAC,IAAI,GAAG,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} & ([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"]}
1
+ {"version":3,"file":"pipeline-steps.js","sourceRoot":"","sources":["../../src/core/pipeline-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE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,CAAC,QAAQ,CAAC,EAAE;gBAC9B,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ;gBAC9C,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO;aACjC;YACD,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,GAAG,EAAE,qBAAqB,CAAC,MAAM,CAAC;SACnC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,OAAO,GAAG;QACd,IAAI;QACJ,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,UAAU;QACV,eAAe;QACf,eAAe;KAChB,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import {\n type ArtifactLoader,\n type ArtifactSaver,\n type ArtifactResult,\n} from \"./pipeline-artifacts.js\";\nimport { createMappedChildRunner, createSingleChildRunner } from \"./child-execution.js\";\nimport { createIterationRunner, type IterationDecision, type IterationState } from \"./iteration.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 /** Read an artifact as an ordinary step, publishing only its typed value. */\n function loadArtifact<\n TId extends string,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TValue = unknown,\n >(\n id: TId,\n definition: Omit<\n PlainStepFields<TOptions, TDeps, TOptionalDeps, ArtifactResult<TValue>>,\n \"run\"\n > & {\n load: ArtifactLoader<RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>, TValue, TOptions>;\n }\n ): BuiltStep<TId, TValue, TOptions, TInputOptions> {\n const { load, dryRun, ...fields } = definition;\n const wrap =\n (handler: typeof load) =>\n async (\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineStepContext<TOptions>\n ) => {\n const loaded = await handler(inputs, context);\n context.recordArtifact({ operation: \"read\", artifact: loaded.artifact });\n return loaded.value;\n };\n return step(id, {\n ...fields,\n run: wrap(load),\n dryRun: typeof dryRun === \"function\" ? wrap(dryRun) : dryRun,\n });\n }\n\n /** Write an artifact as an ordinary step. Dry runs skip unless a preview is supplied. */\n function saveArtifact<\n TId extends string,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n const TOptionalDeps extends readonly AnyStep<TOptions>[] = [],\n TValue = unknown,\n >(\n id: TId,\n definition: Omit<\n PlainStepFields<TOptions, TDeps, TOptionalDeps, ArtifactResult<TValue>>,\n \"run\"\n > & {\n save: ArtifactSaver<RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>, TValue, TOptions>;\n }\n ): BuiltStep<TId, TValue, TOptions, TInputOptions> {\n const { save, dryRun, ...fields } = definition;\n const wrap =\n (handler: typeof save) =>\n async (\n inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>,\n context: PipelineStepContext<TOptions>\n ) => {\n const saved = await handler(inputs, context);\n context.recordArtifact({ operation: \"write\", artifact: saved.artifact });\n return saved.value;\n };\n return step(id, {\n ...fields,\n run: wrap(save),\n dryRun: typeof dryRun === \"function\" ? wrap(dryRun) : \"skip\",\n });\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 function iteratePipeline<\n const TId extends string,\n TChild extends Pipeline<object, unknown>,\n TState,\n TResult,\n const TDeps extends readonly AnyStep<TOptions>[] = [],\n >(\n id: TId,\n definition: {\n pipeline: TChild;\n name?: string;\n description?: string;\n dependsOn?: TDeps;\n maxIterations: number;\n dryRun?: \"skip\";\n controls?: PipelineRunControlsOf<TChild>;\n initialState(\n inputs: RequiredInputs<TDeps>,\n context: PipelineExecutionContext<TOptions>\n ): TState;\n mapOptions(\n state: IterationState<NoInfer<TState>>,\n inputs: RequiredInputs<TDeps>,\n context: PipelineExecutionContext<TOptions>\n ): PipelineOptionsOf<TChild>;\n transition(\n result: PipelineResultOf<TChild>,\n state: IterationState<NoInfer<TState>>,\n context: PipelineExecutionContext<TOptions>\n ):\n | IterationDecision<NoInfer<TState>, TResult>\n | Promise<IterationDecision<NoInfer<TState>, TResult>>;\n }\n ): BuiltStep<TId, Awaited<TResult>, TOptions, TInputOptions>;\n function iteratePipeline(\n id: string,\n definition: Omit<Parameters<typeof createIterationRunner<TOptions>>[0], \"stepId\"> & {\n name?: string;\n description?: string;\n dependsOn?: readonly AnyStep<TOptions>[];\n dryRun?: \"skip\";\n }\n ): AnyStep<TOptions> {\n if (!Number.isSafeInteger(definition.maxIterations) || definition.maxIterations < 1) {\n throw new RangeError(\"iteratePipeline maxIterations must be a positive safe integer\");\n }\n const controls = definition.controls ? structuredClone(definition.controls) : undefined;\n if (controls) {\n if (controls.targets) Object.freeze(controls.targets);\n if (controls.stepIds) Object.freeze(controls.stepIds);\n Object.freeze(controls);\n }\n const config = { ...definition, stepId: id, controls };\n return buildStep(id, {\n [STEP_NESTED_PIPELINE]: {\n mode: \"iterate\",\n maxIterations: config.maxIterations,\n controls: config.controls,\n pipelineId: config.pipeline.id,\n identity: config.pipeline.definition?.identity,\n stepIds: config.pipeline.stepIds,\n },\n name: config.name,\n description: config.description,\n dependsOn: config.dependsOn,\n dryRun: config.dryRun,\n run: createIterationRunner(config),\n });\n }\n\n const factory = {\n step,\n loadArtifact,\n saveArtifact,\n fromPipeline,\n fromRemote,\n forEachPipeline,\n iteratePipeline,\n };\n\n return factory;\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import type { ArtifactRecord } from "../tracing/artifact-metadata.js";
1
2
  import type { PipelineDefinitionIdentityContract, PipelineDefinitionSnapshotContract } from "../tracing/tracing-schema.js";
2
3
  /** Versioned graph identity, separate from the optional handler implementation version. */
3
4
  export type PipelineDefinitionIdentity = Readonly<PipelineDefinitionIdentityContract>;
@@ -79,6 +80,8 @@ export interface PipelineExecutionContext<TOptions extends object> extends Pipel
79
80
  export type PipelineStepProgressDetailStatus = "cancelled" | "completed" | "failed" | "pending" | "running" | "skipped";
80
81
  /** One optional nested row in a step progress snapshot. */
81
82
  export interface PipelineStepProgressDetail {
83
+ /** Provenance of a supplied test output, independent of the row status. */
84
+ outputSource?: "override";
82
85
  /** Stable identity for the row (item key, path, job id, …). */
83
86
  id: string;
84
87
  /** Optional display name; identity remains `id`. */
@@ -112,6 +115,8 @@ export interface PipelineStepProgress {
112
115
  export interface PipelineStepContext<TOptions extends object> extends PipelineExecutionContext<TOptions> {
113
116
  /** Stable identity for this execution of the current step. */
114
117
  attemptId: string;
118
+ /** Record completed I/O without changing the step output. Calls after the handler settles are ignored. */
119
+ recordArtifact(record: ArtifactRecord): void;
115
120
  /** Emit a retry/attempt trace event for this step when tracing is enabled. */
116
121
  reportAttempt(attempt: number, attributes?: PipelineTraceAttributes): void;
117
122
  /** Publish the latest progress snapshot for this step. */
@@ -226,6 +231,8 @@ export interface PipelineErrorCause {
226
231
  sourceCode?: string;
227
232
  }
228
233
  interface PipelineStepReportBase {
234
+ /** Present once a supplied test output enters validation, including failed/cancelled attempts. */
235
+ outputSource?: "override";
229
236
  /** Present when the step started an execution attempt. */
230
237
  attemptId?: string;
231
238
  id: string;
@@ -327,6 +334,8 @@ export type PipelineStepStatus = {
327
334
  } | {
328
335
  attemptId: string;
329
336
  pipelineId: string;
337
+ /** Supplied test output; the normal step handler is not executing. */
338
+ outputSource?: "override";
330
339
  progress?: PipelineStepProgress;
331
340
  status: "running";
332
341
  step: PipelinePlanStep;
@@ -441,8 +450,12 @@ export interface PipelinePlanStep {
441
450
  name?: string;
442
451
  /** Static child structure when this opaque step executes another pipeline. */
443
452
  nestedPipeline?: {
444
- /** One child execution or one child execution per runtime item. */
445
- mode: "single" | "for-each";
453
+ /** One child, runtime fan-out, or bounded sequential iteration. */
454
+ mode: "single" | "for-each" | "iterate";
455
+ /** Upper bound for a dynamically repeated child. */
456
+ maxIterations?: number;
457
+ /** Static child controls, recorded for iteration identity and inspection. */
458
+ controls?: PipelineRunControls;
446
459
  identity?: PipelineDefinitionIdentity;
447
460
  concurrency?: number | "dynamic";
448
461
  pipelineId: string;