tubeless 0.2.11 → 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 (196) hide show
  1. package/dist/core/child-execution.d.ts +1 -24
  2. package/dist/core/child-execution.js +11 -13
  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 +24 -1
  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 +28 -3
  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 +22 -4
  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 +75 -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 +87 -8
  151. package/docs/comparison.md +20 -0
  152. package/docs/concepts.md +79 -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 -32
  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/inherited-inputs.ts +28 -0
  174. package/examples/inngest/client.ts +4 -0
  175. package/examples/inngest/functions.ts +65 -0
  176. package/examples/inngest/pipeline.ts +41 -0
  177. package/examples/inngest/send.ts +11 -0
  178. package/examples/inngest/server.ts +17 -0
  179. package/examples/inngest/tsconfig.build.json +10 -0
  180. package/examples/iteration.ts +52 -0
  181. package/examples/parameterized-steps.ts +96 -0
  182. package/examples/project/tubeless.project.ts +50 -0
  183. package/examples/step-functions/handler.ts +110 -0
  184. package/examples/step-functions/input.json +1 -0
  185. package/examples/step-functions/pipeline.ts +41 -0
  186. package/examples/step-functions/state-machine.asl.json +41 -0
  187. package/examples/step-functions/template.json +42 -0
  188. package/examples/step-output-overrides.ts +41 -0
  189. package/examples/temporal/activities.ts +94 -0
  190. package/examples/temporal/client.ts +19 -0
  191. package/examples/temporal/pipeline.ts +41 -0
  192. package/examples/temporal/tsconfig.build.json +10 -0
  193. package/examples/temporal/worker.ts +21 -0
  194. package/examples/temporal/workflows.ts +16 -0
  195. package/package.json +13 -4
  196. package/skills/tubeless/SKILL.md +37 -4
@@ -1,4 +1,9 @@
1
- import { createPipelineTraceEmitter, } from "../tracing/tracing-internal.js";
1
+ import { createPipelineTraceEmitter } from "../tracing/tracing-internal.js";
2
+ const PIPELINE_LOGGER_BASE = Symbol("pipelineLoggerBase");
3
+ function basePipelineLogger(log) {
4
+ // SAFETY: the optional symbol exists only on loggers created by this module.
5
+ return log[PIPELINE_LOGGER_BASE] ?? log;
6
+ }
2
7
  function emitHook(runtime, emit) {
3
8
  if (!runtime.hooks)
4
9
  return;
@@ -20,8 +25,32 @@ function snapshotRun(result) {
20
25
  const { value, ...metadata } = result;
21
26
  return { ...structuredClone(metadata), value };
22
27
  }
23
- export function createPipelineLifecycleObserver(pipelineId, runtime, trace) {
28
+ export function createPipelineLifecycleObserver(pipelineId, runtime, identity) {
29
+ const base = basePipelineLogger(runtime.log);
30
+ const trace = createPipelineTraceEmitter(pipelineId, runtime.tracing, base, identity, runtime.now);
24
31
  return {
32
+ traceContext: trace?.context,
33
+ logger(stepId, attemptId) {
34
+ if (!trace)
35
+ return runtime.log;
36
+ // A child run inherits its parent's logger, but owns its own trace events.
37
+ const log = {
38
+ error: (message, ...params) => {
39
+ trace.log("error", message, params, stepId, attemptId);
40
+ base.error(message, ...params);
41
+ },
42
+ log: (message, ...params) => {
43
+ trace.log("log", message, params, stepId, attemptId);
44
+ base.log(message, ...params);
45
+ },
46
+ warn: (message, ...params) => {
47
+ trace.log("warn", message, params, stepId, attemptId);
48
+ base.warn(message, ...params);
49
+ },
50
+ };
51
+ log[PIPELINE_LOGGER_BASE] = base;
52
+ return log;
53
+ },
25
54
  pipelineStart(plan, targetIds) {
26
55
  emitHook(runtime, (hooks) => hooks.onPipelineStart?.(structuredClone(plan)));
27
56
  trace?.pipelineStart(plan, targetIds);
@@ -40,6 +69,7 @@ export function createPipelineLifecycleObserver(pipelineId, runtime, trace) {
40
69
  else {
41
70
  emitHook(runtime, (hooks) => hooks.onStepStart?.({
42
71
  attemptId: event.attemptId,
72
+ ...(event.outputSource ? { outputSource: event.outputSource } : {}),
43
73
  pipelineId: event.pipelineId,
44
74
  status: "running",
45
75
  step: structuredClone(event.step),
@@ -62,8 +92,8 @@ export function createPipelineLifecycleObserver(pipelineId, runtime, trace) {
62
92
  if (traceStatus)
63
93
  trace?.stepStatus(event);
64
94
  },
95
+ recordArtifact: (stepId, attemptId, record, preview) => trace?.artifact(stepId, attemptId, record, preview),
65
96
  reportAttempt: (stepId, attempt, attributes, attemptId) => trace?.reportAttempt(stepId, attempt, attributes, attemptId),
66
- log: (level, message, params, stepId, attemptId) => trace?.log(level, message, params, stepId, attemptId),
67
97
  finalizeStart() {
68
98
  emitHook(runtime, (hooks) => hooks.onFinalizeStart?.({ pipelineId }));
69
99
  trace?.finalizeStart();
@@ -92,7 +122,9 @@ export async function emitRejectedPlanLifecycle(pipelineId, targetIds, plan, run
92
122
  identity.parentRunId = result.parentRunId;
93
123
  if (runtime.tracing?.itemKey)
94
124
  identity.itemKey = runtime.tracing.itemKey;
95
- const lifecycle = createPipelineLifecycleObserver(pipelineId, runtime, createPipelineTraceEmitter(pipelineId, runtime.tracing, runtime.log, identity, runtime.now));
125
+ if (runtime.tracing?.iteration)
126
+ identity.iteration = runtime.tracing.iteration;
127
+ const lifecycle = createPipelineLifecycleObserver(pipelineId, runtime, identity);
96
128
  lifecycle.pipelineStart(plan, targetIds);
97
129
  lifecycle.pipelineComplete(result);
98
130
  await lifecycle.flush();
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/core/lifecycle.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,0BAA0B,GAE3B,MAAM,gCAAgC,CAAC;AA8BxC,SAAS,QAAQ,CAAC,OAAwB,EAAE,IAAoC;IAC9E,IAAI,CAAC,OAAO,CAAC,KAAK;QAAE,OAAO;IAC3B,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,C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,IAAI,EAAE,SAAS,CAAC,CAAC;IACzC,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;AAC1B,CAAC","sourcesContent":["import type {\n PipelineError,\n PipelineHooks,\n PipelinePlan,\n PipelineRun,\n PipelineRuntime,\n PipelineStepStatus,\n} from \"./pipeline-types.js\";\nimport {\n createPipelineTraceEmitter,\n type PipelineTraceEmitter,\n} from \"../tracing/tracing-internal.js\";\nimport type {\n PipelineTraceAttributes,\n PipelineTraceContext,\n} from \"../tracing/tracing-contracts.js\";\n\n/** Internal canonical lifecycle stream. Hooks and tracing are projections of it. */\nexport interface PipelineLifecycleObserver {\n finalizeComplete(durationMs: number, value: unknown): void;\n finalizeError(error: PipelineError, durationMs: number): void;\n finalizeStart(): void;\n flush(): Promise<void>;\n log(\n level: \"error\" | \"log\" | \"warn\",\n message: unknown,\n params?: readonly unknown[],\n stepId?: string,\n attemptId?: string\n ): void;\n pipelineComplete(result: PipelineRun<unknown>): void;\n pipelineStart(plan: PipelinePlan, targetIds: readonly string[]): void;\n reportAttempt(\n stepId: string,\n attempt: number,\n attributes?: PipelineTraceAttributes,\n attemptId?: string\n ): void;\n stepStatus(event: PipelineStepStatus, trace?: boolean): void;\n}\n\nfunction emitHook(runtime: PipelineRuntime, emit: (hooks: PipelineHooks) => void): void {\n if (!runtime.hooks) return;\n const hookSets = Array.isArray(runtime.hooks) ? runtime.hooks : [runtime.hooks];\n for (const hooks of hookSets) {\n try {\n emit(hooks);\n } catch (error) {\n runtime.log.warn(\n `Pipeline hook failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n}\n\nfunction snapshotRun(result: PipelineRun<unknown>): PipelineRun<unknown> {\n if (!result.finalized) return structuredClone(result);\n // Domain results may contain functions or class instances. Only lifecycle\n // metadata belongs to Tubeless; preserve the domain value's identity.\n const { value, ...metadata } = result;\n return { ...structuredClone(metadata), value };\n}\n\nexport function createPipelineLifecycleObserver(\n pipelineId: string,\n runtime: PipelineRuntime,\n trace: PipelineTraceEmitter | undefined\n): PipelineLifecycleObserver {\n return {\n pipelineStart(plan, targetIds) {\n emitHook(runtime, (hooks) => hooks.onPipelineStart?.(structuredClone(plan)));\n trace?.pipelineStart(plan, targetIds);\n },\n stepStatus(event, traceStatus = true) {\n emitHook(runtime, (hooks) => hooks.onStepStatus?.(structuredClone(event)));\n switch (event.status) {\n case \"planned\":\n emitHook(runtime, (hooks) => hooks.onStepPlan?.(structuredClone(event)));\n break;\n case \"running\":\n if (event.progress) {\n const progress = event.progress;\n emitHook(runtime, (hooks) =>\n hooks.onStepProgress?.(structuredClone({ ...event, progress }))\n );\n } else {\n emitHook(runtime, (hooks) =>\n hooks.onStepStart?.({\n attemptId: event.attemptId,\n pipelineId: event.pipelineId,\n status: \"running\",\n step: structuredClone(event.step),\n })\n );\n }\n break;\n case \"cancelled\":\n emitHook(runtime, (hooks) => hooks.onStepCancel?.(structuredClone(event)));\n break;\n case \"failed\":\n emitHook(runtime, (hooks) => hooks.onStepFail?.(structuredClone(event)));\n break;\n case \"skipped\":\n emitHook(runtime, (hooks) => hooks.onStepSkip?.(structuredClone(event)));\n break;\n case \"completed\":\n emitHook(runtime, (hooks) => hooks.onStepComplete?.(structuredClone(event)));\n break;\n }\n if (traceStatus) trace?.stepStatus(event);\n },\n reportAttempt: (stepId, attempt, attributes, attemptId) =>\n trace?.reportAttempt(stepId, attempt, attributes, attemptId),\n log: (level, message, params, stepId, attemptId) =>\n trace?.log(level, message, params, stepId, attemptId),\n finalizeStart() {\n emitHook(runtime, (hooks) => hooks.onFinalizeStart?.({ pipelineId }));\n trace?.finalizeStart();\n },\n finalizeComplete(durationMs, value) {\n emitHook(runtime, (hooks) => hooks.onFinalizeComplete?.({ durationMs, pipelineId, value }));\n trace?.finalizeComplete(durationMs);\n },\n finalizeError(error, durationMs) {\n emitHook(runtime, (hooks) =>\n hooks.onFinalizeError?.({ durationMs, error: structuredClone(error), pipelineId })\n );\n trace?.finalizeError(error, durationMs);\n },\n pipelineComplete(result) {\n emitHook(runtime, (hooks) => hooks.onPipelineComplete?.(snapshotRun(result)));\n trace?.pipelineComplete(result);\n },\n flush: () => trace?.flush() ?? Promise.resolve(),\n };\n}\n\n/** Same start/complete projection executePlannedRun uses for an invalid plan. */\nexport async function emitRejectedPlanLifecycle(\n pipelineId: string,\n targetIds: readonly string[],\n plan: PipelinePlan,\n runtime: PipelineRuntime,\n result: PipelineRun<unknown>\n): Promise<void> {\n const identity: PipelineTraceContext = { runId: result.runId };\n if (result.correlationId !== undefined) identity.correlationId = result.correlationId;\n if (result.parentRunId) identity.parentRunId = result.parentRunId;\n if (runtime.tracing?.itemKey) identity.itemKey = runtime.tracing.itemKey;\n const lifecycle = createPipelineLifecycleObserver(\n pipelineId,\n runtime,\n createPipelineTraceEmitter(pipelineId, runtime.tracing, runtime.log, identity, runtime.now)\n );\n lifecycle.pipelineStart(plan, targetIds);\n lifecycle.pipelineComplete(result);\n await lifecycle.flush();\n}\n"]}
1
+ {"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/core/lifecycle.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AA0B5E,MAAM,oBAAoB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAI1D,SAAS,kBAAkB,CAAC,GAAmB;IAC7C,6EAA6E;IAC7E,OAAQ,GAA4B,CAAC,oBAAoB,CAAC,IAAI,GAAG,CAAC;AACpE,CAAC;AAED,SAAS,QAAQ,CAAC,OAAwB,EAAE,IAAoC;IAC9E,IAAI,CAAC,OAAO,CAAC,KAAK;QAAE,OAAO;IAC3B,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAChF,KAAK,MAAM,KAAK,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AAM,CAAC,CAAC;IACnC,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;AAC1B,CAAC","sourcesContent":["import type { ArtifactRecord } from \"../tracing/artifact-metadata.js\";\nimport type {\n PipelineError,\n PipelineHooks,\n PipelineLogger,\n PipelinePlan,\n PipelineRun,\n PipelineRuntime,\n PipelineStepStatus,\n} from \"./pipeline-types.js\";\nimport { createPipelineTraceEmitter } from \"../tracing/tracing-internal.js\";\nimport type {\n PipelineTraceAttributes,\n PipelineTraceContext,\n} from \"../tracing/tracing-contracts.js\";\n\n/** Internal canonical lifecycle stream. Hooks and tracing are projections of it. */\nexport interface PipelineLifecycleObserver {\n readonly traceContext: PipelineTraceContext | undefined;\n finalizeComplete(durationMs: number, value: unknown): void;\n finalizeError(error: PipelineError, durationMs: number): void;\n finalizeStart(): void;\n flush(): Promise<void>;\n logger(stepId?: string, attemptId?: string): PipelineLogger;\n pipelineComplete(result: PipelineRun<unknown>): void;\n pipelineStart(plan: PipelinePlan, targetIds: readonly string[]): void;\n recordArtifact(stepId: string, attemptId: string, record: ArtifactRecord, preview: boolean): void;\n reportAttempt(\n stepId: string,\n attempt: number,\n attributes?: PipelineTraceAttributes,\n attemptId?: string\n ): void;\n stepStatus(event: PipelineStepStatus, trace?: boolean): void;\n}\n\nconst PIPELINE_LOGGER_BASE = Symbol(\"pipelineLoggerBase\");\n\ntype TracedPipelineLogger = PipelineLogger & { [PIPELINE_LOGGER_BASE]?: PipelineLogger };\n\nfunction basePipelineLogger(log: PipelineLogger): PipelineLogger {\n // SAFETY: the optional symbol exists only on loggers created by this module.\n return (log as TracedPipelineLogger)[PIPELINE_LOGGER_BASE] ?? log;\n}\n\nfunction emitHook(runtime: PipelineRuntime, emit: (hooks: PipelineHooks) => void): void {\n if (!runtime.hooks) return;\n const hookSets = Array.isArray(runtime.hooks) ? runtime.hooks : [runtime.hooks];\n for (const hooks of hookSets) {\n try {\n emit(hooks);\n } catch (error) {\n runtime.log.warn(\n `Pipeline hook failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n}\n\nfunction snapshotRun(result: PipelineRun<unknown>): PipelineRun<unknown> {\n if (!result.finalized) return structuredClone(result);\n // Domain results may contain functions or class instances. Only lifecycle\n // metadata belongs to Tubeless; preserve the domain value's identity.\n const { value, ...metadata } = result;\n return { ...structuredClone(metadata), value };\n}\n\nexport function createPipelineLifecycleObserver(\n pipelineId: string,\n runtime: PipelineRuntime,\n identity: PipelineTraceContext\n): PipelineLifecycleObserver {\n const base = basePipelineLogger(runtime.log);\n const trace = createPipelineTraceEmitter(\n pipelineId,\n runtime.tracing,\n base,\n identity,\n runtime.now\n );\n return {\n traceContext: trace?.context,\n logger(stepId, attemptId) {\n if (!trace) return runtime.log;\n // A child run inherits its parent's logger, but owns its own trace events.\n const log: TracedPipelineLogger = {\n error: (message, ...params) => {\n trace.log(\"error\", message, params, stepId, attemptId);\n base.error(message, ...params);\n },\n log: (message, ...params) => {\n trace.log(\"log\", message, params, stepId, attemptId);\n base.log(message, ...params);\n },\n warn: (message, ...params) => {\n trace.log(\"warn\", message, params, stepId, attemptId);\n base.warn(message, ...params);\n },\n };\n log[PIPELINE_LOGGER_BASE] = base;\n return log;\n },\n pipelineStart(plan, targetIds) {\n emitHook(runtime, (hooks) => hooks.onPipelineStart?.(structuredClone(plan)));\n trace?.pipelineStart(plan, targetIds);\n },\n stepStatus(event, traceStatus = true) {\n emitHook(runtime, (hooks) => hooks.onStepStatus?.(structuredClone(event)));\n switch (event.status) {\n case \"planned\":\n emitHook(runtime, (hooks) => hooks.onStepPlan?.(structuredClone(event)));\n break;\n case \"running\":\n if (event.progress) {\n const progress = event.progress;\n emitHook(runtime, (hooks) =>\n hooks.onStepProgress?.(structuredClone({ ...event, progress }))\n );\n } else {\n emitHook(runtime, (hooks) =>\n hooks.onStepStart?.({\n attemptId: event.attemptId,\n ...(event.outputSource ? { outputSource: event.outputSource } : {}),\n pipelineId: event.pipelineId,\n status: \"running\",\n step: structuredClone(event.step),\n })\n );\n }\n break;\n case \"cancelled\":\n emitHook(runtime, (hooks) => hooks.onStepCancel?.(structuredClone(event)));\n break;\n case \"failed\":\n emitHook(runtime, (hooks) => hooks.onStepFail?.(structuredClone(event)));\n break;\n case \"skipped\":\n emitHook(runtime, (hooks) => hooks.onStepSkip?.(structuredClone(event)));\n break;\n case \"completed\":\n emitHook(runtime, (hooks) => hooks.onStepComplete?.(structuredClone(event)));\n break;\n }\n if (traceStatus) trace?.stepStatus(event);\n },\n recordArtifact: (stepId, attemptId, record, preview) =>\n trace?.artifact(stepId, attemptId, record, preview),\n reportAttempt: (stepId, attempt, attributes, attemptId) =>\n trace?.reportAttempt(stepId, attempt, attributes, attemptId),\n finalizeStart() {\n emitHook(runtime, (hooks) => hooks.onFinalizeStart?.({ pipelineId }));\n trace?.finalizeStart();\n },\n finalizeComplete(durationMs, value) {\n emitHook(runtime, (hooks) => hooks.onFinalizeComplete?.({ durationMs, pipelineId, value }));\n trace?.finalizeComplete(durationMs);\n },\n finalizeError(error, durationMs) {\n emitHook(runtime, (hooks) =>\n hooks.onFinalizeError?.({ durationMs, error: structuredClone(error), pipelineId })\n );\n trace?.finalizeError(error, durationMs);\n },\n pipelineComplete(result) {\n emitHook(runtime, (hooks) => hooks.onPipelineComplete?.(snapshotRun(result)));\n trace?.pipelineComplete(result);\n },\n flush: () => trace?.flush() ?? Promise.resolve(),\n };\n}\n\n/** Same start/complete projection executePlannedRun uses for an invalid plan. */\nexport async function emitRejectedPlanLifecycle(\n pipelineId: string,\n targetIds: readonly string[],\n plan: PipelinePlan,\n runtime: PipelineRuntime,\n result: PipelineRun<unknown>\n): Promise<void> {\n const identity: PipelineTraceContext = { runId: result.runId };\n if (result.correlationId !== undefined) identity.correlationId = result.correlationId;\n if (result.parentRunId) identity.parentRunId = result.parentRunId;\n if (runtime.tracing?.itemKey) identity.itemKey = runtime.tracing.itemKey;\n if (runtime.tracing?.iteration) identity.iteration = runtime.tracing.iteration;\n const lifecycle = createPipelineLifecycleObserver(pipelineId, runtime, identity);\n lifecycle.pipelineStart(plan, targetIds);\n lifecycle.pipelineComplete(result);\n await lifecycle.flush();\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import type { ArtifactMetadata } from "../tracing/artifact-metadata.js";
2
+ import type { PipelineStepContext } from "./pipeline-types.js";
3
+ /** Adapter result: the value flows to dependents; only artifact metadata is recorded. */
4
+ export interface ArtifactResult<TValue> {
5
+ readonly value: TValue;
6
+ readonly artifact: ArtifactMetadata;
7
+ }
8
+ /** Application-owned read boundary. Forward context.signal to cancellable I/O. */
9
+ export type ArtifactLoader<TInput, TValue, TOptions extends object = {}> = (input: TInput, context: PipelineStepContext<TOptions>) => ArtifactResult<TValue> | Promise<ArtifactResult<TValue>>;
10
+ /** Application-owned write boundary returning a typed receipt and separate trace metadata. */
11
+ export type ArtifactSaver<TInput, TValue, TOptions extends object = {}> = (input: TInput, context: PipelineStepContext<TOptions>) => ArtifactResult<TValue> | Promise<ArtifactResult<TValue>>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=pipeline-artifacts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline-artifacts.js","sourceRoot":"","sources":["../../src/core/pipeline-artifacts.ts"],"names":[],"mappings":"","sourcesContent":["import type { ArtifactMetadata } from \"../tracing/artifact-metadata.js\";\nimport type { PipelineStepContext } from \"./pipeline-types.js\";\n\n/** Adapter result: the value flows to dependents; only artifact metadata is recorded. */\nexport interface ArtifactResult<TValue> {\n readonly value: TValue;\n readonly artifact: ArtifactMetadata;\n}\n\n/** Application-owned read boundary. Forward context.signal to cancellable I/O. */\nexport type ArtifactLoader<TInput, TValue, TOptions extends object = {}> = (\n input: TInput,\n context: PipelineStepContext<TOptions>\n) => ArtifactResult<TValue> | Promise<ArtifactResult<TValue>>;\n\n/** Application-owned write boundary returning a typed receipt and separate trace metadata. */\nexport type ArtifactSaver<TInput, TValue, TOptions extends object = {}> = (\n input: TInput,\n context: PipelineStepContext<TOptions>\n) => ArtifactResult<TValue> | Promise<ArtifactResult<TValue>>;\n"]}
@@ -9,6 +9,7 @@ export interface CompiledPipeline<TSteps extends readonly AnyStep[] = readonly A
9
9
  readonly id: string;
10
10
  readonly optionsSchema: StandardSchemaV1 | undefined;
11
11
  readonly orderedSteps: readonly AnyStep<StepsOptions<TSteps>>[];
12
+ readonly compiledByAuthorStep: ReadonlyMap<AnyStep, AnyStep>;
12
13
  readonly requiredFinalizerSteps: readonly AnyStep<StepsOptions<TSteps>>[] | undefined;
13
14
  readonly stepGraph: ReadonlyMap<AnyStep, CompiledStepGraph>;
14
15
  readonly resultSchema: TResultSchema | undefined;
@@ -49,6 +49,7 @@ export function compilePipeline(definition) {
49
49
  ? undefined
50
50
  : compiledByAuthorStep.get(definition.steps[0])?.[STEP_OPTIONS_SCHEMA],
51
51
  orderedSteps: Object.freeze([...orderedSteps]),
52
+ compiledByAuthorStep,
52
53
  stepGraph,
53
54
  requiredFinalizerSteps: compiledRequiredFinalizerSteps
54
55
  ? Object.freeze(compiledRequiredFinalizerSteps)
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline-compiler.js","sourceRoot":"","sources":["../../src/core/pipeline-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAA0B,MAAM,qBAAqB,CAAC;AAEnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAyBlE,MAAM,UAAU,eAAe,CAM7B,UAAwE;IAExE,MAAM,MAAM,GAAG,0BAA0B,CAAC,UAAU,CAAC,CAAC;IACtD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,I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C,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,EAAE,CAAC,CAAC;QAC1F,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KACjE,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { compileDefinitionSnapshot } from \"./pipeline-definition-identity.js\";\nimport type { PipelineDefinition, StepsOptions } from \"./pipeline-definition.js\";\nimport { validatePipelineDefinition } from \"./pipeline-definition-validation.js\";\nimport { PipelineDefinitionError } from \"./pipeline-errors.js\";\nimport { requiredFinalizerMetadata } from \"./pipeline-finalizer.js\";\nimport { compilePipelineGraph, type CompiledStepGraph } from \"./pipeline-graph.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport { STEP_OPTIONS_SCHEMA } from \"./pipeline-step-metadata.js\";\nimport type { PipelineDefinitionSnapshot, StandardSchemaV1 } from \"./pipeline-types.js\";\n\nexport interface CompiledPipeline<\n TSteps extends readonly AnyStep[] = readonly AnyStep[],\n TResult = unknown,\n TTargets extends readonly TSteps[number][] = readonly [],\n TResultSchema extends StandardSchemaV1 | undefined = undefined,\n> {\n readonly definition: PipelineDefinitionSnapshot;\n readonly declaredTargets: readonly AnyStep<StepsOptions<TSteps>>[];\n readonly finalize: Extract<\n NonNullable<PipelineDefinition<TSteps, TResult, TTargets, TResultSchema>[\"finalize\"]>,\n (...args: never[]) => unknown\n >;\n readonly id: string;\n readonly optionsSchema: StandardSchemaV1 | undefined;\n readonly orderedSteps: readonly AnyStep<StepsOptions<TSteps>>[];\n readonly requiredFinalizerSteps: readonly AnyStep<StepsOptions<TSteps>>[] | undefined;\n readonly stepGraph: ReadonlyMap<AnyStep, CompiledStepGraph>;\n readonly resultSchema: TResultSchema | undefined;\n readonly stepIds: readonly string[];\n readonly targetIds: readonly string[];\n}\n\nexport function compilePipeline<\n TSteps extends readonly AnyStep[],\n TResult,\n TTargets extends readonly TSteps[number][],\n TResultSchema extends StandardSchemaV1 | undefined,\n>(\n definition: PipelineDefinition<TSteps, TResult, TTargets, TResultSchema>\n): CompiledPipeline<TSteps, TResult, TTargets, TResultSchema> {\n const errors = validatePipelineDefinition(definition);\n if (errors.length > 0) {\n throw new PipelineDefinitionError(definition.id, errors);\n }\n type TOptions = StepsOptions<TSteps>;\n // SAFETY: `steps` is `TSteps extends readonly AnyStep[]`; the cast restores\n // the `TOptions` generic that the tuple erased, without changing the values.\n const { compiledByAuthorStep, orderedSteps, stepGraph } = compilePipelineGraph(\n definition.steps as readonly AnyStep<TOptions>[]\n );\n const finalizerMetadata = requiredFinalizerMetadata<TOptions>(definition.finalize);\n const requiredFinalizerSteps = finalizerMetadata?.steps;\n const compiledTargets = definition.targets\n ? definition.targets.map((target) => compiledByAuthorStep.get(target)!)\n : orderedSteps.slice(-1);\n const compiledRequiredFinalizerSteps = requiredFinalizerSteps?.map((step) =>\n compiledByAuthorStep.get(step)!\n );\n const lastStepId = orderedSteps.at(-1)?.id;\n const authoredFinalize = definition.finalize;\n type Finalizer = CompiledPipeline<TSteps, TResult, TTargets, TResultSchema>[\"finalize\"];\n const compiledFinalize = finalizerMetadata\n ? finalizerMetadata.compile(compiledRequiredFinalizerSteps!.map((step) => step.id))\n : typeof authoredFinalize === \"function\"\n ? (outputs: Parameters<Finalizer>[0], context: Parameters<Finalizer>[1]) =>\n authoredFinalize.call(definition, outputs, context)\n : (outputs: Record<string, unknown>) =>\n lastStepId !== undefined && Object.hasOwn(outputs, lastStepId)\n ? outputs[lastStepId]\n : undefined;\n const snapshot = compileDefinitionSnapshot({\n orderedSteps,\n stepGraph,\n targetIds: compiledTargets.map((step) => step.id),\n requiredFinalizerSteps: compiledRequiredFinalizerSteps,\n resultValidated: definition.resultSchema !== undefined,\n implementationVersion: definition.implementationVersion,\n });\n return Object.freeze({\n definition: snapshot,\n declaredTargets: Object.freeze(compiledTargets),\n // Invoke ordinary finalizers on the author's definition so method-style\n // implementations keep `this`. Required finalizers compile the same input\n // and context contract with stable required ids.\n // SAFETY: supplied finalizers preserve their signature; definePipeline checks\n // that an omitted finalizer can use the last step's output as its result.\n finalize: compiledFinalize as Finalizer,\n id: definition.id,\n optionsSchema:\n definition.steps.length === 0\n ? undefined\n : compiledByAuthorStep.get(definition.steps[0]!)?.[STEP_OPTIONS_SCHEMA],\n orderedSteps: Object.freeze([...orderedSteps]),\n stepGraph,\n requiredFinalizerSteps: compiledRequiredFinalizerSteps\n ? Object.freeze(compiledRequiredFinalizerSteps)\n : undefined,\n resultSchema: definition.resultSchema,\n stepIds: Object.freeze(definition.steps.map((step) => compiledByAuthorStep.get(step)!.id)),\n targetIds: Object.freeze(compiledTargets.map((step) => step.id)),\n });\n}\n"]}
1
+ {"version":3,"file":"pipeline-compiler.js","sourceRoot":"","sources":["../../src/core/pipeline-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAA0B,MAAM,qBAAqB,CAAC;AAEnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AA0BlE,MAAM,UAAU,eAAe,CAM7B,UAAwE;IAExE,MAAM,MAAM,GAAG,0BAA0B,CAAC,UAAU,CAAC,CAAC;IACtD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,uBAAuB,CAAC,UAAU,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;IAED,4EAA4E;IAC5E,6EAA6E;IAC7E,MAAM,EAAE,oBAAoB,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,oBAAoB,CAC5E,UAAU,C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AAE,CAAC,CAAC;KACjE,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { compileDefinitionSnapshot } from \"./pipeline-definition-identity.js\";\nimport type { PipelineDefinition, StepsOptions } from \"./pipeline-definition.js\";\nimport { validatePipelineDefinition } from \"./pipeline-definition-validation.js\";\nimport { PipelineDefinitionError } from \"./pipeline-errors.js\";\nimport { requiredFinalizerMetadata } from \"./pipeline-finalizer.js\";\nimport { compilePipelineGraph, type CompiledStepGraph } from \"./pipeline-graph.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport { STEP_OPTIONS_SCHEMA } from \"./pipeline-step-metadata.js\";\nimport type { PipelineDefinitionSnapshot, StandardSchemaV1 } from \"./pipeline-types.js\";\n\nexport interface CompiledPipeline<\n TSteps extends readonly AnyStep[] = readonly AnyStep[],\n TResult = unknown,\n TTargets extends readonly TSteps[number][] = readonly [],\n TResultSchema extends StandardSchemaV1 | undefined = undefined,\n> {\n readonly definition: PipelineDefinitionSnapshot;\n readonly declaredTargets: readonly AnyStep<StepsOptions<TSteps>>[];\n readonly finalize: Extract<\n NonNullable<PipelineDefinition<TSteps, TResult, TTargets, TResultSchema>[\"finalize\"]>,\n (...args: never[]) => unknown\n >;\n readonly id: string;\n readonly optionsSchema: StandardSchemaV1 | undefined;\n readonly orderedSteps: readonly AnyStep<StepsOptions<TSteps>>[];\n readonly compiledByAuthorStep: ReadonlyMap<AnyStep, AnyStep>;\n readonly requiredFinalizerSteps: readonly AnyStep<StepsOptions<TSteps>>[] | undefined;\n readonly stepGraph: ReadonlyMap<AnyStep, CompiledStepGraph>;\n readonly resultSchema: TResultSchema | undefined;\n readonly stepIds: readonly string[];\n readonly targetIds: readonly string[];\n}\n\nexport function compilePipeline<\n TSteps extends readonly AnyStep[],\n TResult,\n TTargets extends readonly TSteps[number][],\n TResultSchema extends StandardSchemaV1 | undefined,\n>(\n definition: PipelineDefinition<TSteps, TResult, TTargets, TResultSchema>\n): CompiledPipeline<TSteps, TResult, TTargets, TResultSchema> {\n const errors = validatePipelineDefinition(definition);\n if (errors.length > 0) {\n throw new PipelineDefinitionError(definition.id, errors);\n }\n type TOptions = StepsOptions<TSteps>;\n // SAFETY: `steps` is `TSteps extends readonly AnyStep[]`; the cast restores\n // the `TOptions` generic that the tuple erased, without changing the values.\n const { compiledByAuthorStep, orderedSteps, stepGraph } = compilePipelineGraph(\n definition.steps as readonly AnyStep<TOptions>[]\n );\n const finalizerMetadata = requiredFinalizerMetadata<TOptions>(definition.finalize);\n const requiredFinalizerSteps = finalizerMetadata?.steps;\n const compiledTargets = definition.targets\n ? definition.targets.map((target) => compiledByAuthorStep.get(target)!)\n : orderedSteps.slice(-1);\n const compiledRequiredFinalizerSteps = requiredFinalizerSteps?.map((step) =>\n compiledByAuthorStep.get(step)!\n );\n const lastStepId = orderedSteps.at(-1)?.id;\n const authoredFinalize = definition.finalize;\n type Finalizer = CompiledPipeline<TSteps, TResult, TTargets, TResultSchema>[\"finalize\"];\n const compiledFinalize = finalizerMetadata\n ? finalizerMetadata.compile(compiledRequiredFinalizerSteps!.map((step) => step.id))\n : typeof authoredFinalize === \"function\"\n ? (outputs: Parameters<Finalizer>[0], context: Parameters<Finalizer>[1]) =>\n authoredFinalize.call(definition, outputs, context)\n : (outputs: Record<string, unknown>) =>\n lastStepId !== undefined && Object.hasOwn(outputs, lastStepId)\n ? outputs[lastStepId]\n : undefined;\n const snapshot = compileDefinitionSnapshot({\n orderedSteps,\n stepGraph,\n targetIds: compiledTargets.map((step) => step.id),\n requiredFinalizerSteps: compiledRequiredFinalizerSteps,\n resultValidated: definition.resultSchema !== undefined,\n implementationVersion: definition.implementationVersion,\n });\n return Object.freeze({\n definition: snapshot,\n declaredTargets: Object.freeze(compiledTargets),\n // Invoke ordinary finalizers on the author's definition so method-style\n // implementations keep `this`. Required finalizers compile the same input\n // and context contract with stable required ids.\n // SAFETY: supplied finalizers preserve their signature; definePipeline checks\n // that an omitted finalizer can use the last step's output as its result.\n finalize: compiledFinalize as Finalizer,\n id: definition.id,\n optionsSchema:\n definition.steps.length === 0\n ? undefined\n : compiledByAuthorStep.get(definition.steps[0]!)?.[STEP_OPTIONS_SCHEMA],\n orderedSteps: Object.freeze([...orderedSteps]),\n compiledByAuthorStep,\n stepGraph,\n requiredFinalizerSteps: compiledRequiredFinalizerSteps\n ? Object.freeze(compiledRequiredFinalizerSteps)\n : undefined,\n resultSchema: definition.resultSchema,\n stepIds: Object.freeze(definition.steps.map((step) => compiledByAuthorStep.get(step)!.id)),\n targetIds: Object.freeze(compiledTargets.map((step) => step.id)),\n });\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { CompiledStepGraph } from "./pipeline-graph.js";
2
2
  import type { AnyStep } from "./pipeline-steps.js";
3
3
  import type { PipelineDefinitionIdentity, PipelineDefinitionSnapshot } from "./pipeline-types.js";
4
- /** Canonical v1 semantics. Execution order matters; dependency and target sets do not. */
4
+ /** Canonical snapshot. Execution order matters; dependency and target sets do not. */
5
5
  export declare function compileDefinitionSnapshot(input: {
6
6
  orderedSteps: readonly AnyStep[];
7
7
  stepGraph: ReadonlyMap<AnyStep, CompiledStepGraph>;
@@ -10,5 +10,5 @@ export declare function compileDefinitionSnapshot(input: {
10
10
  resultValidated: boolean;
11
11
  implementationVersion: string | undefined;
12
12
  }): PipelineDefinitionSnapshot;
13
- /** Rebuild v1 hashes from explicit fields, independent of JSON object property order. */
13
+ /** Preserve v1 hashes; extended child semantics use v2, including their ancestors. */
14
14
  export declare function createDefinitionIdentity(input: Omit<PipelineDefinitionSnapshot, "identity">, implementationVersion: string | undefined): PipelineDefinitionIdentity;
@@ -11,7 +11,25 @@ function freezeSnapshot(value) {
11
11
  }
12
12
  return value;
13
13
  }
14
- /** Canonical v1 semantics. Execution order matters; dependency and target sets do not. */
14
+ function iterationFields(nested) {
15
+ if (nested.mode !== "iterate")
16
+ return {};
17
+ const controls = nested.controls;
18
+ const normalizedControls = {
19
+ ...(controls?.dryRun !== undefined ? { dryRun: controls.dryRun } : {}),
20
+ ...(controls?.continueOnError !== undefined
21
+ ? { continueOnError: controls.continueOnError }
22
+ : {}),
23
+ ...(controls?.maxConcurrency !== undefined ? { maxConcurrency: controls.maxConcurrency } : {}),
24
+ ...(controls?.targets !== undefined ? { targets: [...controls.targets].sort() } : {}),
25
+ ...(controls?.stepIds !== undefined ? { stepIds: [...controls.stepIds].sort() } : {}),
26
+ };
27
+ return {
28
+ maxIterations: nested.maxIterations,
29
+ ...(Object.keys(normalizedControls).length > 0 ? { controls: normalizedControls } : {}),
30
+ };
31
+ }
32
+ /** Canonical snapshot. Execution order matters; dependency and target sets do not. */
15
33
  export function compileDefinitionSnapshot(input) {
16
34
  const steps = input.orderedSteps.map((step) => {
17
35
  const graph = input.stepGraph.get(step);
@@ -34,6 +52,7 @@ export function compileDefinitionSnapshot(input) {
34
52
  nestedPipeline: {
35
53
  pipelineId: nested.pipelineId,
36
54
  mode: nested.mode,
55
+ ...iterationFields(nested),
37
56
  stepIds: [...nested.stepIds],
38
57
  ...(nested.identity ? { identity: { ...nested.identity } } : {}),
39
58
  ...(nested.concurrency !== undefined ? { concurrency: nested.concurrency } : {}),
@@ -64,11 +83,14 @@ export function compileDefinitionSnapshot(input) {
64
83
  ...semantics,
65
84
  });
66
85
  }
67
- /** Rebuild v1 hashes from explicit fields, independent of JSON object property order. */
86
+ /** Preserve v1 hashes; extended child semantics use v2, including their ancestors. */
68
87
  export function createDefinitionIdentity(input, implementationVersion) {
88
+ const version = input.steps.some((step) => step.nestedPipeline?.mode === "iterate" || step.nestedPipeline?.identity?.version === 2)
89
+ ? 2
90
+ : 1;
69
91
  // Child handler versions participate in the combined identity, never the graph fingerprint.
70
92
  const structuralFingerprint = fingerprint({
71
- version: 1,
93
+ version,
72
94
  steps: input.steps.map((step) => ({
73
95
  id: step.id,
74
96
  dependencies: [...step.dependencies].sort(),
@@ -82,6 +104,7 @@ export function createDefinitionIdentity(input, implementationVersion) {
82
104
  nestedPipeline: {
83
105
  pipelineId: step.nestedPipeline.pipelineId,
84
106
  mode: step.nestedPipeline.mode,
107
+ ...iterationFields(step.nestedPipeline),
85
108
  stepIds: [...step.nestedPipeline.stepIds],
86
109
  ...(step.nestedPipeline.identity
87
110
  ? {
@@ -114,11 +137,11 @@ export function createDefinitionIdentity(input, implementationVersion) {
114
137
  resultValidated: input.resultValidated,
115
138
  });
116
139
  return {
117
- version: 1,
140
+ version,
118
141
  structuralFingerprint,
119
142
  ...(implementationVersion !== undefined ? { implementationVersion } : {}),
120
143
  definitionId: fingerprint({
121
- version: 1,
144
+ version,
122
145
  structuralFingerprint,
123
146
  implementationVersion,
124
147
  children: input.steps.map((step) => {
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline-definition-identity.js","sourceRoot":"","sources":["../../src/core/pipeline-definition-identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,GACZ,MAAM,6BAA6B,CAAC;AAGrC,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,UAAU,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AACtF,CAAC;AAED,SAAS,cAAc,CAAI,KAAQ;IACjC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,cAAc,CAAC,KAAK,CAAC,CAAC;QAChE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,yBAAyB,CAAC,KAOzC;IACC,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI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C,qBAAqB,KAAK,SAAS;wBAC3C,CAAC,CAAC,EAAE,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,EAAE;wBACxD,CAAC,CAAC,EAAE,CAAC;oBACP,YAAY,EAAE,KAAK,CAAC,YAAY;iBACjC,CAAC;YACJ,CAAC,CAAC;SACH,CAAC;KACH,CAAC;AACJ,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport type { CompiledStepGraph } from \"./pipeline-graph.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport {\n STEP_NESTED_PIPELINE,\n STEP_OPTIONS_SCHEMA,\n STEP_REMOTE,\n} from \"./pipeline-step-metadata.js\";\nimport type { PipelineDefinitionIdentity, PipelineDefinitionSnapshot } from \"./pipeline-types.js\";\n\nfunction fingerprint(value: unknown): string {\n return `sha256:${createHash(\"sha256\").update(JSON.stringify(value)).digest(\"hex\")}`;\n}\n\nfunction freezeSnapshot<T>(value: T): T {\n if (value !== null && typeof value === \"object\") {\n for (const child of Object.values(value)) freezeSnapshot(child);\n Object.freeze(value);\n }\n return value;\n}\n\n/** Canonical v1 semantics. Execution order matters; dependency and target sets do not. */\nexport function compileDefinitionSnapshot(input: {\n orderedSteps: readonly AnyStep[];\n stepGraph: ReadonlyMap<AnyStep, CompiledStepGraph>;\n targetIds: readonly string[];\n requiredFinalizerSteps: readonly AnyStep[] | undefined;\n resultValidated: boolean;\n implementationVersion: string | undefined;\n}): PipelineDefinitionSnapshot {\n const steps = input.orderedSteps.map((step) => {\n const graph = input.stepGraph.get(step)!;\n const nested = step[STEP_NESTED_PIPELINE];\n const remote = step[STEP_REMOTE];\n return {\n id: step.id,\n dependencies: graph.dependsOn.map(({ id }) => id).sort(),\n optionalDependencies: graph.optionalDependsOn.map(({ id }) => id).sort(),\n skipAfterFailureOf: graph.skipAfterFailureOf.map(({ id }) => id).sort(),\n dryRun:\n step.dryRun === \"skip\"\n ? (\"skip\" as const)\n : step.dryRun\n ? (\"custom\" as const)\n : (\"run\" as const),\n runtimeSkipPossible: step.skip !== undefined,\n outputValidated: step.outputSchema !== undefined,\n ...(nested\n ? {\n nestedPipeline: {\n pipelineId: nested.pipelineId,\n mode: nested.mode,\n stepIds: [...nested.stepIds],\n ...(nested.identity ? { identity: { ...nested.identity } } : {}),\n ...(nested.concurrency !== undefined ? { concurrency: nested.concurrency } : {}),\n },\n }\n : {}),\n ...(remote\n ? {\n remote: {\n engine: remote.engine,\n ...(remote.target !== undefined ? { target: remote.target } : {}),\n },\n }\n : {}),\n };\n });\n const semantics = {\n steps,\n targetIds: [...input.targetIds].sort(),\n ...(input.requiredFinalizerSteps\n ? { requiredFinalizerStepIds: input.requiredFinalizerSteps.map(({ id }) => id).sort() }\n : {}),\n optionsValidated: input.orderedSteps[0]?.[STEP_OPTIONS_SCHEMA] !== undefined,\n resultValidated: input.resultValidated,\n };\n return freezeSnapshot({\n identity: createDefinitionIdentity(semantics, input.implementationVersion),\n ...semantics,\n });\n}\n\n/** Rebuild v1 hashes from explicit fields, independent of JSON object property order. */\nexport function createDefinitionIdentity(\n input: Omit<PipelineDefinitionSnapshot, \"identity\">,\n implementationVersion: string | undefined\n): PipelineDefinitionIdentity {\n // Child handler versions participate in the combined identity, never the graph fingerprint.\n const structuralFingerprint = fingerprint({\n version: 1,\n steps: input.steps.map((step) => ({\n id: step.id,\n dependencies: [...step.dependencies].sort(),\n optionalDependencies: [...step.optionalDependencies].sort(),\n skipAfterFailureOf: [...step.skipAfterFailureOf].sort(),\n dryRun: step.dryRun,\n runtimeSkipPossible: step.runtimeSkipPossible,\n outputValidated: step.outputValidated,\n ...(step.nestedPipeline\n ? {\n nestedPipeline: {\n pipelineId: step.nestedPipeline.pipelineId,\n mode: step.nestedPipeline.mode,\n stepIds: [...step.nestedPipeline.stepIds],\n ...(step.nestedPipeline.identity\n ? {\n identity: {\n version: step.nestedPipeline.identity.version,\n structuralFingerprint: step.nestedPipeline.identity.structuralFingerprint,\n },\n }\n : {}),\n ...(step.nestedPipeline.concurrency !== undefined\n ? { concurrency: step.nestedPipeline.concurrency }\n : {}),\n },\n }\n : {}),\n ...(step.remote\n ? {\n remote: {\n engine: step.remote.engine,\n ...(step.remote.target !== undefined ? { target: step.remote.target } : {}),\n },\n }\n : {}),\n })),\n targetIds: [...input.targetIds].sort(),\n ...(input.requiredFinalizerStepIds\n ? { requiredFinalizerStepIds: [...input.requiredFinalizerStepIds].sort() }\n : {}),\n optionsValidated: input.optionsValidated,\n resultValidated: input.resultValidated,\n });\n return {\n version: 1,\n structuralFingerprint,\n ...(implementationVersion !== undefined ? { implementationVersion } : {}),\n definitionId: fingerprint({\n version: 1,\n structuralFingerprint,\n implementationVersion,\n children: input.steps.map((step) => {\n const child = step.nestedPipeline?.identity;\n if (!child) return null;\n // Bind every recorded child identity field, not just its opaque definition ID.\n return {\n version: child.version,\n structuralFingerprint: child.structuralFingerprint,\n ...(child.implementationVersion !== undefined\n ? { implementationVersion: child.implementationVersion }\n : {}),\n definitionId: child.definitionId,\n };\n }),\n }),\n };\n}\n"]}
1
+ {"version":3,"file":"pipeline-definition-identity.js","sourceRoot":"","sources":["../../src/core/pipeline-definition-identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,GACZ,MAAM,6BAA6B,CAAC;AAGrC,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,UAAU,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AACtF,CAAC;AAED,SAAS,cAAc,CAAI,KAAQ;IACjC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,cAAc,CAAC,KAAK,CAA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,qBAAqB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,qBAAqB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzE,YAAY,EAAE,WAAW,CAAC;YACxB,OAAO;YACP,qBAAqB;YACrB,qBAAqB;YACrB,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBACjC,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC;gBAC5C,IAAI,CAAC,KAAK;oBAAE,OAAO,IAAI,CAAC;gBACxB,+EAA+E;gBAC/E,OAAO;oBACL,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,qBAAqB,EAAE,KAAK,CAAC,qBAAqB;oBAClD,GAAG,CAAC,KAAK,CAAC,qBAAqB,KAAK,SAAS;wBAC3C,CAAC,CAAC,EAAE,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,EAAE;wBACxD,CAAC,CAAC,EAAE,CAAC;oBACP,YAAY,EAAE,KAAK,CAAC,YAAY;iBACjC,CAAC;YACJ,CAAC,CAAC;SACH,CAAC;KACH,CAAC;AACJ,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport type { CompiledStepGraph } from \"./pipeline-graph.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport {\n STEP_NESTED_PIPELINE,\n STEP_OPTIONS_SCHEMA,\n STEP_REMOTE,\n} from \"./pipeline-step-metadata.js\";\nimport type { PipelineDefinitionIdentity, PipelineDefinitionSnapshot } from \"./pipeline-types.js\";\n\nfunction fingerprint(value: unknown): string {\n return `sha256:${createHash(\"sha256\").update(JSON.stringify(value)).digest(\"hex\")}`;\n}\n\nfunction freezeSnapshot<T>(value: T): T {\n if (value !== null && typeof value === \"object\") {\n for (const child of Object.values(value)) freezeSnapshot(child);\n Object.freeze(value);\n }\n return value;\n}\n\nfunction iterationFields(\n nested: NonNullable<PipelineDefinitionSnapshot[\"steps\"][number][\"nestedPipeline\"]>\n) {\n if (nested.mode !== \"iterate\") return {};\n const controls = nested.controls;\n const normalizedControls = {\n ...(controls?.dryRun !== undefined ? { dryRun: controls.dryRun } : {}),\n ...(controls?.continueOnError !== undefined\n ? { continueOnError: controls.continueOnError }\n : {}),\n ...(controls?.maxConcurrency !== undefined ? { maxConcurrency: controls.maxConcurrency } : {}),\n ...(controls?.targets !== undefined ? { targets: [...controls.targets].sort() } : {}),\n ...(controls?.stepIds !== undefined ? { stepIds: [...controls.stepIds].sort() } : {}),\n };\n return {\n maxIterations: nested.maxIterations,\n ...(Object.keys(normalizedControls).length > 0 ? { controls: normalizedControls } : {}),\n };\n}\n\n/** Canonical snapshot. Execution order matters; dependency and target sets do not. */\nexport function compileDefinitionSnapshot(input: {\n orderedSteps: readonly AnyStep[];\n stepGraph: ReadonlyMap<AnyStep, CompiledStepGraph>;\n targetIds: readonly string[];\n requiredFinalizerSteps: readonly AnyStep[] | undefined;\n resultValidated: boolean;\n implementationVersion: string | undefined;\n}): PipelineDefinitionSnapshot {\n const steps = input.orderedSteps.map((step) => {\n const graph = input.stepGraph.get(step)!;\n const nested = step[STEP_NESTED_PIPELINE];\n const remote = step[STEP_REMOTE];\n return {\n id: step.id,\n dependencies: graph.dependsOn.map(({ id }) => id).sort(),\n optionalDependencies: graph.optionalDependsOn.map(({ id }) => id).sort(),\n skipAfterFailureOf: graph.skipAfterFailureOf.map(({ id }) => id).sort(),\n dryRun:\n step.dryRun === \"skip\"\n ? (\"skip\" as const)\n : step.dryRun\n ? (\"custom\" as const)\n : (\"run\" as const),\n runtimeSkipPossible: step.skip !== undefined,\n outputValidated: step.outputSchema !== undefined,\n ...(nested\n ? {\n nestedPipeline: {\n pipelineId: nested.pipelineId,\n mode: nested.mode,\n ...iterationFields(nested),\n stepIds: [...nested.stepIds],\n ...(nested.identity ? { identity: { ...nested.identity } } : {}),\n ...(nested.concurrency !== undefined ? { concurrency: nested.concurrency } : {}),\n },\n }\n : {}),\n ...(remote\n ? {\n remote: {\n engine: remote.engine,\n ...(remote.target !== undefined ? { target: remote.target } : {}),\n },\n }\n : {}),\n };\n });\n const semantics = {\n steps,\n targetIds: [...input.targetIds].sort(),\n ...(input.requiredFinalizerSteps\n ? { requiredFinalizerStepIds: input.requiredFinalizerSteps.map(({ id }) => id).sort() }\n : {}),\n optionsValidated: input.orderedSteps[0]?.[STEP_OPTIONS_SCHEMA] !== undefined,\n resultValidated: input.resultValidated,\n };\n return freezeSnapshot({\n identity: createDefinitionIdentity(semantics, input.implementationVersion),\n ...semantics,\n });\n}\n\n/** Preserve v1 hashes; extended child semantics use v2, including their ancestors. */\nexport function createDefinitionIdentity(\n input: Omit<PipelineDefinitionSnapshot, \"identity\">,\n implementationVersion: string | undefined\n): PipelineDefinitionIdentity {\n const version = input.steps.some(\n (step) =>\n step.nestedPipeline?.mode === \"iterate\" || step.nestedPipeline?.identity?.version === 2\n )\n ? 2\n : 1;\n // Child handler versions participate in the combined identity, never the graph fingerprint.\n const structuralFingerprint = fingerprint({\n version,\n steps: input.steps.map((step) => ({\n id: step.id,\n dependencies: [...step.dependencies].sort(),\n optionalDependencies: [...step.optionalDependencies].sort(),\n skipAfterFailureOf: [...step.skipAfterFailureOf].sort(),\n dryRun: step.dryRun,\n runtimeSkipPossible: step.runtimeSkipPossible,\n outputValidated: step.outputValidated,\n ...(step.nestedPipeline\n ? {\n nestedPipeline: {\n pipelineId: step.nestedPipeline.pipelineId,\n mode: step.nestedPipeline.mode,\n ...iterationFields(step.nestedPipeline),\n stepIds: [...step.nestedPipeline.stepIds],\n ...(step.nestedPipeline.identity\n ? {\n identity: {\n version: step.nestedPipeline.identity.version,\n structuralFingerprint: step.nestedPipeline.identity.structuralFingerprint,\n },\n }\n : {}),\n ...(step.nestedPipeline.concurrency !== undefined\n ? { concurrency: step.nestedPipeline.concurrency }\n : {}),\n },\n }\n : {}),\n ...(step.remote\n ? {\n remote: {\n engine: step.remote.engine,\n ...(step.remote.target !== undefined ? { target: step.remote.target } : {}),\n },\n }\n : {}),\n })),\n targetIds: [...input.targetIds].sort(),\n ...(input.requiredFinalizerStepIds\n ? { requiredFinalizerStepIds: [...input.requiredFinalizerStepIds].sort() }\n : {}),\n optionsValidated: input.optionsValidated,\n resultValidated: input.resultValidated,\n });\n return {\n version,\n structuralFingerprint,\n ...(implementationVersion !== undefined ? { implementationVersion } : {}),\n definitionId: fingerprint({\n version,\n structuralFingerprint,\n implementationVersion,\n children: input.steps.map((step) => {\n const child = step.nestedPipeline?.identity;\n if (!child) return null;\n // Bind every recorded child identity field, not just its opaque definition ID.\n return {\n version: child.version,\n structuralFingerprint: child.structuralFingerprint,\n ...(child.implementationVersion !== undefined\n ? { implementationVersion: child.implementationVersion }\n : {}),\n definitionId: child.definitionId,\n };\n }),\n }),\n };\n}\n"]}
@@ -1,18 +1,13 @@
1
1
  import type { CompiledPipeline } from "./pipeline-compiler.js";
2
2
  import type { AnyStep } from "./pipeline-steps.js";
3
3
  import type { InferSchemaOutput, PipelineContext, PipelinePlan, PipelineRun, PipelineRunControls, PipelineRuntime, StandardSchemaV1 } from "./pipeline-types.js";
4
- /** Error thrown by `runOrThrow` when a pipeline run does not complete successfully. */
5
- export declare class PipelineExecutionError extends Error {
6
- readonly result: PipelineRun<unknown>;
7
- constructor(result: PipelineRun<unknown>, message?: string);
8
- }
9
- export declare function isPipelineCancellation(error: unknown, runtime: PipelineRuntime): boolean;
10
4
  export declare function executePlannedRun<TSteps extends readonly AnyStep[], TResult, TTargets extends readonly TSteps[number][], TResultSchema extends StandardSchemaV1 | undefined>(input: {
11
5
  compiled: CompiledPipeline<TSteps, TResult, TTargets, TResultSchema>;
12
6
  controls: PipelineRunControls;
13
7
  domainOptions: object;
14
8
  plan: PipelinePlan;
15
9
  runtime: PipelineRuntime;
10
+ overrides?: ReadonlyMap<AnyStep, unknown>;
16
11
  }): Promise<PipelineRun<TResultSchema extends StandardSchemaV1 ? InferSchemaOutput<TResultSchema> : TResult>>;
17
12
  export declare function defaultPipelineContext(): PipelineContext;
18
13
  export declare function resolvePipelineRuntime(context?: Partial<PipelineContext>): PipelineRuntime;