@lotiai/composer 0.2.0 → 0.2.2

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 (189) hide show
  1. package/dist/build-config/index.d.ts +52 -0
  2. package/dist/build-config/index.d.ts.map +1 -0
  3. package/dist/build-config/index.js +66 -0
  4. package/dist/build-config/index.js.map +1 -0
  5. package/dist/build-config/loader.d.ts +80 -0
  6. package/dist/build-config/loader.d.ts.map +1 -0
  7. package/dist/build-config/loader.js +238 -0
  8. package/dist/build-config/loader.js.map +1 -0
  9. package/dist/build-config/schema.d.ts +101 -0
  10. package/dist/build-config/schema.d.ts.map +1 -0
  11. package/dist/build-config/schema.js +94 -0
  12. package/dist/build-config/schema.js.map +1 -0
  13. package/dist/cli/commands/dev-temporal.d.ts +15 -0
  14. package/dist/cli/commands/dev-temporal.d.ts.map +1 -0
  15. package/dist/cli/commands/dev-temporal.js +68 -0
  16. package/dist/cli/commands/dev-temporal.js.map +1 -0
  17. package/dist/cli/commands/dev.d.ts +21 -0
  18. package/dist/cli/commands/dev.d.ts.map +1 -0
  19. package/dist/cli/commands/dev.js +421 -0
  20. package/dist/cli/commands/dev.js.map +1 -0
  21. package/dist/cli/commands/profiles.d.ts +15 -0
  22. package/dist/cli/commands/profiles.d.ts.map +1 -0
  23. package/dist/cli/commands/profiles.js +69 -0
  24. package/dist/cli/commands/profiles.js.map +1 -0
  25. package/dist/cli/index.d.ts +21 -0
  26. package/dist/cli/index.d.ts.map +1 -0
  27. package/dist/cli/index.js +44 -0
  28. package/dist/cli/index.js.map +1 -0
  29. package/dist/index.d.ts +15 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +57 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/internal/async/build/workflow-factory.d.ts +212 -0
  34. package/dist/internal/async/build/workflow-factory.d.ts.map +1 -0
  35. package/dist/internal/async/build/workflow-factory.js +533 -0
  36. package/dist/internal/async/build/workflow-factory.js.map +1 -0
  37. package/dist/internal/async/build-scripts/utils/common.d.ts +28 -0
  38. package/dist/internal/async/build-scripts/utils/common.d.ts.map +1 -0
  39. package/dist/internal/async/build-scripts/utils/common.js +50 -0
  40. package/dist/internal/async/build-scripts/utils/common.js.map +1 -0
  41. package/dist/internal/async/build-scripts/utils/import-module.d.ts +19 -0
  42. package/dist/internal/async/build-scripts/utils/import-module.d.ts.map +1 -0
  43. package/dist/internal/async/build-scripts/utils/import-module.js +80 -0
  44. package/dist/internal/async/build-scripts/utils/import-module.js.map +1 -0
  45. package/dist/internal/async/build-scripts/utils/type-guards.d.ts +123 -0
  46. package/dist/internal/async/build-scripts/utils/type-guards.d.ts.map +1 -0
  47. package/dist/internal/async/build-scripts/utils/type-guards.js +145 -0
  48. package/dist/internal/async/build-scripts/utils/type-guards.js.map +1 -0
  49. package/dist/internal/async/config/cleanup-policy.d.ts +50 -0
  50. package/dist/internal/async/config/cleanup-policy.d.ts.map +1 -0
  51. package/dist/internal/async/config/cleanup-policy.js +20 -0
  52. package/dist/internal/async/config/cleanup-policy.js.map +1 -0
  53. package/dist/internal/async/config/worker-profiles.d.ts +172 -0
  54. package/dist/internal/async/config/worker-profiles.d.ts.map +1 -0
  55. package/dist/internal/async/config/worker-profiles.js +275 -0
  56. package/dist/internal/async/config/worker-profiles.js.map +1 -0
  57. package/dist/internal/async/execute/temporal-client.d.ts +182 -0
  58. package/dist/internal/async/execute/temporal-client.d.ts.map +1 -0
  59. package/dist/internal/async/execute/temporal-client.js +190 -0
  60. package/dist/internal/async/execute/temporal-client.js.map +1 -0
  61. package/dist/internal/async/execute/workflow-execution.d.ts +98 -0
  62. package/dist/internal/async/execute/workflow-execution.d.ts.map +1 -0
  63. package/dist/internal/async/execute/workflow-execution.js +191 -0
  64. package/dist/internal/async/execute/workflow-execution.js.map +1 -0
  65. package/dist/internal/async/metrics/task-queue-metrics.d.ts +74 -0
  66. package/dist/internal/async/metrics/task-queue-metrics.d.ts.map +1 -0
  67. package/dist/internal/async/metrics/task-queue-metrics.js +155 -0
  68. package/dist/internal/async/metrics/task-queue-metrics.js.map +1 -0
  69. package/dist/internal/async/register/activity-worker.d.ts +123 -0
  70. package/dist/internal/async/register/activity-worker.d.ts.map +1 -0
  71. package/dist/internal/async/register/activity-worker.js +355 -0
  72. package/dist/internal/async/register/activity-worker.js.map +1 -0
  73. package/dist/internal/async/register/generate-workflow-source.d.ts +43 -0
  74. package/dist/internal/async/register/generate-workflow-source.d.ts.map +1 -0
  75. package/dist/internal/async/register/generate-workflow-source.js +193 -0
  76. package/dist/internal/async/register/generate-workflow-source.js.map +1 -0
  77. package/dist/internal/async/register/workflow-worker.d.ts +125 -0
  78. package/dist/internal/async/register/workflow-worker.d.ts.map +1 -0
  79. package/dist/internal/async/register/workflow-worker.js +215 -0
  80. package/dist/internal/async/register/workflow-worker.js.map +1 -0
  81. package/dist/internal/async/register-scripts/start-activity-worker.d.ts +70 -0
  82. package/dist/internal/async/register-scripts/start-activity-worker.d.ts.map +1 -0
  83. package/dist/internal/async/register-scripts/start-activity-worker.js +75 -0
  84. package/dist/internal/async/register-scripts/start-activity-worker.js.map +1 -0
  85. package/dist/internal/async/register-scripts/start-all-workers.d.ts +81 -0
  86. package/dist/internal/async/register-scripts/start-all-workers.d.ts.map +1 -0
  87. package/dist/internal/async/register-scripts/start-all-workers.js +84 -0
  88. package/dist/internal/async/register-scripts/start-all-workers.js.map +1 -0
  89. package/dist/internal/async/register-scripts/start-workflow-worker.d.ts +69 -0
  90. package/dist/internal/async/register-scripts/start-workflow-worker.d.ts.map +1 -0
  91. package/dist/internal/async/register-scripts/start-workflow-worker.js +74 -0
  92. package/dist/internal/async/register-scripts/start-workflow-worker.js.map +1 -0
  93. package/dist/internal/async/register-scripts/sync-schedules-cli.d.ts +28 -0
  94. package/dist/internal/async/register-scripts/sync-schedules-cli.d.ts.map +1 -0
  95. package/dist/internal/async/register-scripts/sync-schedules-cli.js +124 -0
  96. package/dist/internal/async/register-scripts/sync-schedules-cli.js.map +1 -0
  97. package/dist/internal/async/register-scripts/sync-schedules-via-lambda.d.ts +55 -0
  98. package/dist/internal/async/register-scripts/sync-schedules-via-lambda.d.ts.map +1 -0
  99. package/dist/internal/async/register-scripts/sync-schedules-via-lambda.js +146 -0
  100. package/dist/internal/async/register-scripts/sync-schedules-via-lambda.js.map +1 -0
  101. package/dist/internal/async/register-scripts/sync-schedules.d.ts +68 -0
  102. package/dist/internal/async/register-scripts/sync-schedules.d.ts.map +1 -0
  103. package/dist/internal/async/register-scripts/sync-schedules.js +83 -0
  104. package/dist/internal/async/register-scripts/sync-schedules.js.map +1 -0
  105. package/dist/internal/async/schedule/constants.d.ts +10 -0
  106. package/dist/internal/async/schedule/constants.d.ts.map +1 -0
  107. package/dist/internal/async/schedule/constants.js +13 -0
  108. package/dist/internal/async/schedule/constants.js.map +1 -0
  109. package/dist/internal/async/schedule/define-schedule.d.ts +192 -0
  110. package/dist/internal/async/schedule/define-schedule.d.ts.map +1 -0
  111. package/dist/internal/async/schedule/define-schedule.js +79 -0
  112. package/dist/internal/async/schedule/define-schedule.js.map +1 -0
  113. package/dist/internal/async/schedule/index.d.ts +3 -0
  114. package/dist/internal/async/schedule/index.d.ts.map +1 -0
  115. package/dist/internal/async/schedule/index.js +9 -0
  116. package/dist/internal/async/schedule/index.js.map +1 -0
  117. package/dist/internal/async/schedule/schedule-definition-schema.d.ts +64 -0
  118. package/dist/internal/async/schedule/schedule-definition-schema.d.ts.map +1 -0
  119. package/dist/internal/async/schedule/schedule-definition-schema.js +77 -0
  120. package/dist/internal/async/schedule/schedule-definition-schema.js.map +1 -0
  121. package/dist/internal/async/schedule/sync-schedules.d.ts +71 -0
  122. package/dist/internal/async/schedule/sync-schedules.d.ts.map +1 -0
  123. package/dist/internal/async/schedule/sync-schedules.js +231 -0
  124. package/dist/internal/async/schedule/sync-schedules.js.map +1 -0
  125. package/dist/internal/async/utils/ensure-namespace.d.ts +16 -0
  126. package/dist/internal/async/utils/ensure-namespace.d.ts.map +1 -0
  127. package/dist/internal/async/utils/ensure-namespace.js +64 -0
  128. package/dist/internal/async/utils/ensure-namespace.js.map +1 -0
  129. package/dist/internal/async/utils/find-package-root.d.ts +9 -0
  130. package/dist/internal/async/utils/find-package-root.d.ts.map +1 -0
  131. package/dist/internal/async/utils/find-package-root.js +28 -0
  132. package/dist/internal/async/utils/find-package-root.js.map +1 -0
  133. package/dist/internal/async/utils/is-composer-error.d.ts +14 -0
  134. package/dist/internal/async/utils/is-composer-error.d.ts.map +1 -0
  135. package/dist/internal/async/utils/is-composer-error.js +17 -0
  136. package/dist/internal/async/utils/is-composer-error.js.map +1 -0
  137. package/dist/internal/context-provider.d.ts +316 -0
  138. package/dist/internal/context-provider.d.ts.map +1 -0
  139. package/dist/internal/context-provider.js +12 -0
  140. package/dist/internal/context-provider.js.map +1 -0
  141. package/dist/internal/create-composer.d.ts +57 -0
  142. package/dist/internal/create-composer.d.ts.map +1 -0
  143. package/dist/internal/create-composer.js +125 -0
  144. package/dist/internal/create-composer.js.map +1 -0
  145. package/dist/internal/dag-sync-fanout.d.ts +79 -0
  146. package/dist/internal/dag-sync-fanout.d.ts.map +1 -0
  147. package/dist/internal/dag-sync-fanout.js +59 -0
  148. package/dist/internal/dag-sync-fanout.js.map +1 -0
  149. package/dist/internal/dag-sync-step.d.ts +230 -0
  150. package/dist/internal/dag-sync-step.d.ts.map +1 -0
  151. package/dist/internal/dag-sync-step.js +159 -0
  152. package/dist/internal/dag-sync-step.js.map +1 -0
  153. package/dist/internal/dag-sync-workflow.d.ts +535 -0
  154. package/dist/internal/dag-sync-workflow.d.ts.map +1 -0
  155. package/dist/internal/dag-sync-workflow.js +843 -0
  156. package/dist/internal/dag-sync-workflow.js.map +1 -0
  157. package/dist/internal/defaults.d.ts +24 -0
  158. package/dist/internal/defaults.d.ts.map +1 -0
  159. package/dist/internal/defaults.js +102 -0
  160. package/dist/internal/defaults.js.map +1 -0
  161. package/dist/internal/errors.d.ts +109 -0
  162. package/dist/internal/errors.d.ts.map +1 -0
  163. package/dist/internal/errors.js +212 -0
  164. package/dist/internal/errors.js.map +1 -0
  165. package/dist/internal/index.d.ts +9 -0
  166. package/dist/internal/index.d.ts.map +1 -0
  167. package/dist/internal/index.js +22 -0
  168. package/dist/internal/index.js.map +1 -0
  169. package/dist/internal/observability.d.ts +63 -0
  170. package/dist/internal/observability.d.ts.map +1 -0
  171. package/dist/internal/observability.js +323 -0
  172. package/dist/internal/observability.js.map +1 -0
  173. package/dist/internal/types.d.ts +80 -0
  174. package/dist/internal/types.d.ts.map +1 -0
  175. package/dist/internal/types.js +9 -0
  176. package/dist/internal/types.js.map +1 -0
  177. package/dist/internal/workflow-planning.d.ts +107 -0
  178. package/dist/internal/workflow-planning.d.ts.map +1 -0
  179. package/dist/internal/workflow-planning.js +216 -0
  180. package/dist/internal/workflow-planning.js.map +1 -0
  181. package/dist/schedule-sync.d.ts +17 -0
  182. package/dist/schedule-sync.d.ts.map +1 -0
  183. package/dist/schedule-sync.js +22 -0
  184. package/dist/schedule-sync.js.map +1 -0
  185. package/dist/temporal-naming.d.ts +27 -0
  186. package/dist/temporal-naming.d.ts.map +1 -0
  187. package/dist/temporal-naming.js +33 -0
  188. package/dist/temporal-naming.js.map +1 -0
  189. package/package.json +29 -17
@@ -0,0 +1,535 @@
1
+ /**
2
+ * DAG-based Workflow Engine with Compile-time Validation
3
+ *
4
+ * This module implements a directed acyclic graph (DAG) workflow system that:
5
+ * - Validates step dependencies at compile-time using TypeScript
6
+ * - Executes steps in parallel when dependencies allow
7
+ * - Uses topological sorting with batching for optimal performance
8
+ * - Supports workflow composition for modularity and reusability
9
+ *
10
+ * ## Core Concepts
11
+ *
12
+ * **Step**: A unit of work with declared inputs (needs) and outputs (provides)
13
+ * **Workflow**: A collection of steps with automatic dependency resolution
14
+ * **Bag**: The data container that flows through the workflow
15
+ *
16
+ * ## Execution Model
17
+ *
18
+ * The engine uses **batch-based parallel execution**:
19
+ * 1. **Dependency Analysis**: Builds a dependency graph using topological sorting
20
+ * 2. **Batch Formation**: Groups steps that can run simultaneously
21
+ * 3. **Parallel Execution**: Runs each batch with Promise.all()
22
+ * 4. **Dependency Tracking**: Uses indegree counters to trigger next batch
23
+ *
24
+ * ## Example Execution Flow
25
+ *
26
+ * Given workflow: [stepA, stepB, stepC, stepD]
27
+ * - stepA: needs [] → provides ["x"]
28
+ * - stepB: needs ["x"] → provides ["y"]
29
+ * - stepC: needs ["x"] → provides ["z"]
30
+ * - stepD: needs ["y", "z"] → provides ["result"]
31
+ *
32
+ * Execution batches:
33
+ * - Batch 1: [stepA] (sequential)
34
+ * - Batch 2: [stepB, stepC] (parallel - both need "x")
35
+ * - Batch 3: [stepD] (sequential - needs both "y" and "z")
36
+ *
37
+ * ## Workflow Composition
38
+ *
39
+ * Workflows can be composed using the `use()` helper to create modular, reusable components:
40
+ *
41
+ * ```typescript
42
+ * // Define a reusable child workflow
43
+ * const authWorkflow = createWorkflow<Bag>("authentication")
44
+ * .requires("userId")
45
+ * .build([validateUser, checkPermissions]);
46
+ *
47
+ * // Compose into parent workflow
48
+ * const mainWorkflow = createWorkflow<Bag>("main")
49
+ * .requires("userId")
50
+ * .build([
51
+ * fetchUserData, // Provides userId
52
+ * use(authWorkflow), // Reuses authentication logic
53
+ * processRequest, // Uses auth results
54
+ * ]);
55
+ * ```
56
+ *
57
+ * **Key Composition Features:**
58
+ * - **Step Flattening**: Child workflow steps are merged into parent's dependency graph
59
+ * - **Maximum Parallelization**: Steps from different workflows can execute in the same batch
60
+ * - **Automatic Namespacing**: Child steps are prefixed as "childName.stepName" to prevent conflicts
61
+ * - **Dependency Propagation**: Child initial requirements become regular dependencies in parent
62
+ * - **Nested Composition**: Workflows can compose other composed workflows to any depth
63
+ * - **Observability Preservation**: SubWorkflow spans maintain logical boundaries in traces
64
+ *
65
+ * **Composition Benefits:**
66
+ * - Code reusability across different workflows
67
+ * - Easier testing of workflow components in isolation
68
+ * - Better organization of complex business logic
69
+ * - Maintains compile-time type safety across composition boundaries
70
+ *
71
+ * ## Compile-time Safety
72
+ *
73
+ * The type system validates:
74
+ * - All step dependencies are satisfied by previous steps or initial data
75
+ * - Required initial fields are provided at runtime
76
+ * - Clear error messages for missing dependencies
77
+ *
78
+ * ## Data Protection & Overwrite Prevention
79
+ *
80
+ * The engine enforces strict data integrity rules:
81
+ * - **Step-to-Step Protection**: Each field can have only one producer step (duplicate producers are rejected)
82
+ * - **Initial Data Protection**: Steps cannot overwrite fields provided in initial data
83
+ * - **Immutable Outputs**: Once a step produces a field, it cannot be modified by other steps
84
+ * - **Early Detection**: All conflicts are caught at workflow execution time, not during step execution
85
+ *
86
+ * ## Performance Characteristics
87
+ *
88
+ * - **Automatic Parallelization**: Steps run concurrently when safe
89
+ * - **Batch Synchronization**: All steps in a batch complete before next batch starts
90
+ * - **Zero Polling**: Event-driven execution using dependency counters
91
+ * - **Optimal Scheduling**: Steps execute as soon as dependencies are satisfied
92
+ */
93
+ import type { StepContextProvider } from "./context-provider";
94
+ import type { Step } from "./dag-sync-step";
95
+ import { WorkflowBatchError, WorkflowErrorHandlerFailure, WorkflowStepError } from "./errors";
96
+ import type { ComposerLogger } from "./types";
97
+ /**
98
+ * Default timeout for checkpoints in milliseconds.
99
+ *
100
+ * Checkpoints are designed for fast early returns within HTTP timeout windows.
101
+ * The default of 30 seconds provides a reasonable window for initial step(s)
102
+ * to complete while leaving headroom before typical HTTP timeouts (60s).
103
+ */
104
+ export declare const DEFAULT_CHECKPOINT_TIMEOUT_MS = 30000;
105
+ /**
106
+ * Checkpoint definition for async workflows.
107
+ *
108
+ * Checkpoints allow async (Temporal) workflows to return partial bag results early
109
+ * while continuing execution in the background. This enables patterns like:
110
+ *
111
+ * ```
112
+ * HTTP Request --> Start Workflow --> Checkpoint "created" --> HTTP Response (fast)
113
+ * |
114
+ * v
115
+ * Continue: content acquisition, etc. (slow)
116
+ * ```
117
+ *
118
+ * ## Scope and Limitations
119
+ *
120
+ * Checkpoints are designed for **fast early returns within HTTP timeout windows**.
121
+ * They use Temporal's Update API which holds a connection open until the checkpoint
122
+ * is reached. This works for checkpoints reached in seconds, not minutes.
123
+ *
124
+ * For long-running workflows, use the callback pattern instead: fire-and-forget
125
+ * the workflow and have the final step send a webhook/callback when complete.
126
+ *
127
+ * ## Behavior
128
+ *
129
+ * - In **async (Temporal) mode**: Checkpoints work as designed - caller can await
130
+ * a checkpoint and receive partial bag state while workflow continues.
131
+ * - In **sync mode**: Checkpoints are ignored - workflow always runs to completion.
132
+ */
133
+ export interface Checkpoint {
134
+ /** Unique name for this checkpoint (used when awaiting) */
135
+ name: string;
136
+ /**
137
+ * Step name that triggers this checkpoint.
138
+ *
139
+ * The checkpoint fires after the **entire batch** containing this step completes.
140
+ * This ensures all parallel steps in the batch have finished before the checkpoint.
141
+ *
142
+ * Supports both namespaced (`workflow.stepName`) and unnamespaced (`stepName`)
143
+ * names - unnamespaced names are auto-resolved.
144
+ */
145
+ afterStep: string;
146
+ /**
147
+ * Optional timeout in milliseconds for this checkpoint.
148
+ * If not specified, uses DEFAULT_CHECKPOINT_TIMEOUT_MS (30 seconds).
149
+ */
150
+ timeout?: number;
151
+ }
152
+ /**
153
+ * Options for defining a checkpoint on a workflow.
154
+ *
155
+ * @template S - The Step type (constrained by WorkflowBuilder.checkpoint())
156
+ */
157
+ export interface CheckpointOptions<S extends Step<any, any, any, any, any>> {
158
+ /**
159
+ * Step reference that triggers this checkpoint.
160
+ *
161
+ * Pass the actual step object, not a string name. This enables compile-time
162
+ * validation that the step exists in the workflow.
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * .checkpoint("persisted", { afterStep: persistPromptStep })
167
+ * ```
168
+ */
169
+ afterStep: S;
170
+ /**
171
+ * Optional timeout in milliseconds.
172
+ * Defaults to DEFAULT_CHECKPOINT_TIMEOUT_MS if not specified.
173
+ */
174
+ timeout?: number;
175
+ }
176
+ /**
177
+ * Error handler function type for workflows.
178
+ *
179
+ * The error handler is invoked when a workflow step or batch fails. It controls
180
+ * what ends up in `result.error` via its return value:
181
+ *
182
+ * - Return `undefined` → `result.error` is `undefined` (error fully handled)
183
+ * - Return an `Error` → `result.error` is that error (propagate or transform)
184
+ * - Throw → `result.error` is `WorkflowErrorHandlerFailure` (handler crashed)
185
+ *
186
+ * The handler can update the bag to provide result data for the caller.
187
+ *
188
+ * Use `extractIfPresent` to check error types through workflow wrappers:
189
+ *
190
+ * ```typescript
191
+ * .onError(async (ctx, bag, error) => {
192
+ * const match = MyExpectedError.extractIfPresent(error);
193
+ * if (match) {
194
+ * // Update bag with fallback data
195
+ * bag.result = getFallbackResult();
196
+ * return undefined; // Handled - no error to propagate
197
+ * }
198
+ * return error; // Unknown error - propagate as-is
199
+ * })
200
+ * ```
201
+ *
202
+ * @param ctx - The workflow execution context
203
+ * @param bag - The current bag state (includes successful outputs from the failing batch)
204
+ * @param error - The workflow error (WorkflowStepError or WorkflowBatchError)
205
+ * @returns `undefined` if handled, or an `Error` to propagate
206
+ */
207
+ export type ErrorHandler<Bag extends Record<string, any>, TContext> = (ctx: TContext, bag: Bag, error: WorkflowStepError<Bag> | WorkflowBatchError<Bag>) => Error | undefined | Promise<Error | undefined>;
208
+ /**
209
+ * Result type for workflow execution.
210
+ *
211
+ * Workflows never throw - all errors are captured in the `error` property.
212
+ * This enables cleaner caller code without try/catch.
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * const result = await runWorkflow(myWorkflow, data);
217
+ *
218
+ * if (result.error) {
219
+ * // Handle error case
220
+ * return reply.code(500).send({ error: "Something went wrong" });
221
+ * }
222
+ *
223
+ * // Success - use result.bag
224
+ * return reply.code(200).send(result.bag.output);
225
+ * ```
226
+ */
227
+ export type WorkflowResult<Bag> = {
228
+ /** The workflow bag containing all step outputs and initial data */
229
+ bag: Bag;
230
+ /**
231
+ * Error if workflow failed, undefined if successful.
232
+ * - `WorkflowBatchError`: One or more steps in a batch failed
233
+ * - `WorkflowStepError`: Legacy single-step error (less common with allSettled)
234
+ * - `WorkflowErrorHandlerFailure`: The error handler itself threw unexpectedly
235
+ * - Other `Error`: Unexpected error during workflow execution
236
+ */
237
+ error?: WorkflowBatchError<Bag> | WorkflowStepError<Bag> | WorkflowErrorHandlerFailure | Error;
238
+ };
239
+ /**
240
+ * A Workflow represents a collection of steps with their execution metadata.
241
+ *
242
+ * Generic Parameters:
243
+ * - Bag: The complete data type that flows through the workflow
244
+ * - RequiredInitial: Fields that must be provided when running the workflow
245
+ * - ConfiguredValues: Fields that are pre-configured with default values
246
+ * - Steps: The exact array of steps (used for precise return type inference)
247
+ * - CheckpointNames: Union of checkpoint names (for compile-time validation of awaitCheckpoint)
248
+ *
249
+ * The workflow doesn't validate dependencies at creation time - this happens
250
+ * at runtime in runSyncWorkflow() to account for initial fields that may satisfy dependencies.
251
+ */
252
+ export type Workflow<Bag extends Record<string, any>, RequiredInitial extends keyof Bag = never, ConfiguredValues extends Partial<Bag> = Partial<Bag>, Steps extends readonly Step<Bag, any, any, any, any>[] = readonly Step<Bag, any, any, any, any>[], CheckpointNames extends string = never> = {
253
+ name: string;
254
+ steps: Steps;
255
+ requiredInitial?: RequiredInitial[];
256
+ configuredValues?: ConfiguredValues;
257
+ errorHandler?: ErrorHandler<Bag, unknown>;
258
+ /**
259
+ * Checkpoints for async (Temporal) workflows.
260
+ * In sync mode, checkpoints are ignored.
261
+ */
262
+ checkpoints?: Checkpoint[];
263
+ /**
264
+ * @internal Type-level tracking of checkpoint names for compile-time validation.
265
+ * This field is never set at runtime - it's purely for TypeScript's type system.
266
+ */
267
+ _checkpointNames?: CheckpointNames;
268
+ };
269
+ /**
270
+ * A WorkflowBuilder wraps a Workflow and provides the `.checkpoint()` and `.onError()` methods.
271
+ *
272
+ * This builder pattern allows workflows to be used directly (they satisfy the Workflow type)
273
+ * while also allowing checkpoints and error handlers to be attached via method chaining.
274
+ *
275
+ * @example
276
+ * ```typescript
277
+ * const workflow = createWorkflow<Bag>("my-workflow")
278
+ * .requires("textInput")
279
+ * .build([persistStep, processStep, finalizeStep])
280
+ * .checkpoint("persisted", { afterStep: persistStep })
281
+ * .checkpoint("processed", { afterStep: processStep, timeout: 60000 })
282
+ * .onError(async (ctx, bag, error) => { ... });
283
+ * ```
284
+ */
285
+ export type WorkflowBuilder<Bag extends Record<string, any>, RequiredInitial extends keyof Bag = never, ConfiguredValues extends Partial<Bag> = Partial<Bag>, Steps extends readonly Step<Bag, any, any, any, any>[] = readonly Step<Bag, any, any, any, any>[], CheckpointNames extends string = never> = Workflow<Bag, RequiredInitial, ConfiguredValues, Steps, CheckpointNames> & {
286
+ /**
287
+ * Define a checkpoint for async (Temporal) workflows.
288
+ *
289
+ * Checkpoints allow async workflows to return partial bag results early while
290
+ * continuing execution in the background. Checkpoints are ignored in sync mode.
291
+ *
292
+ * @param name - Unique name for this checkpoint (used when awaiting)
293
+ * @param options - Checkpoint options including afterStep (Step reference) and optional timeout
294
+ * @returns WorkflowBuilder for continued chaining
295
+ *
296
+ * @example
297
+ * ```typescript
298
+ * .checkpoint("created", { afterStep: persistPromptStep })
299
+ * .checkpoint("enriched", { afterStep: acquireContentStep, timeout: 60000 })
300
+ * ```
301
+ */
302
+ checkpoint<S extends Steps[number], Name extends string>(name: Name extends CheckpointNames ? `ERROR: Duplicate checkpoint name '${Name}'` : Name, options: CheckpointOptions<S>): WorkflowBuilder<Bag, RequiredInitial, ConfiguredValues, Steps, CheckpointNames | Name>;
303
+ /**
304
+ * Attach an error handler to the workflow.
305
+ *
306
+ * The handler is invoked when any step fails. Use `extractIfPresent` to check
307
+ * error types through workflow wrappers and transform errors as needed.
308
+ *
309
+ * @param handler - Function to handle workflow errors
310
+ * @returns The workflow with the error handler attached
311
+ */
312
+ onError<TContext = unknown>(handler: ErrorHandler<Bag, TContext>): Workflow<Bag, RequiredInitial, ConfiguredValues, Steps, CheckpointNames>;
313
+ };
314
+ /**
315
+ * Marker type for composed workflows.
316
+ * Used by the `use()` helper to enable workflow composition.
317
+ * This marker is detected during workflow building and the child workflow's steps are flattened.
318
+ */
319
+ export type ComposedWorkflow<Bag extends Record<string, any>, RequiredInitial extends keyof Bag = never, ConfiguredValues extends Partial<Bag> = Partial<Bag>, Steps extends readonly Step<Bag, any, any, any, any>[] = readonly Step<Bag, any, any, any, any>[]> = {
320
+ __composedWorkflow: true;
321
+ workflow: Workflow<Bag, RequiredInitial, ConfiguredValues, Steps>;
322
+ };
323
+ /**
324
+ * Composes a child workflow into a parent workflow.
325
+ *
326
+ * When building a workflow, use `use(childWorkflow)` to include all steps from the child.
327
+ * The steps will be:
328
+ * - Flattened into the parent's dependency graph for maximum parallelization
329
+ * - Automatically namespaced as "childWorkflowName.stepName" to prevent conflicts
330
+ * - Tracked with workflow provenance metadata for proper observability
331
+ *
332
+ * Any initial requirements from the child workflow become regular dependencies that
333
+ * must be satisfied by the parent's steps or initial data.
334
+ *
335
+ * Example:
336
+ * ```typescript
337
+ * const childWf = createWorkflow<Bag>("child").build([stepA, stepB]);
338
+ * const parentWf = createWorkflow<Bag>("parent").build([
339
+ * stepX,
340
+ * use(childWf), // Includes stepA and stepB with proper namespacing
341
+ * stepY,
342
+ * ]);
343
+ *
344
+ * ## Observability
345
+ *
346
+ * Composed workflows create SubWorkflow spans in traces, making it easy to see logical
347
+ * boundaries even though execution is flattened:
348
+ * ```
349
+ * Workflow: main
350
+ * └─ Batch 1
351
+ * └─ SubWorkflow: authentication
352
+ * └─ Step: authentication.validateUser
353
+ * ```
354
+ */
355
+ export declare function use<Bag extends Record<string, any>, RequiredInitial extends keyof Bag = never, ConfiguredValues extends Partial<Bag> = Partial<Bag>, Steps extends readonly Step<Bag, any, any, any, any>[] = readonly Step<Bag, any, any, any, any>[]>(workflow: Workflow<Bag, RequiredInitial, ConfiguredValues, Steps>): ComposedWorkflow<Bag, RequiredInitial, ConfiguredValues, Steps>;
356
+ /**
357
+ * Creates a workflow builder with compile-time dependency validation.
358
+ *
359
+ * This builder provides three modes:
360
+ * 1. build() - for workflows that don't require initial data
361
+ * 2. requires(fields).build() - for workflows that need the caller to provide specific fields
362
+ * 3. configure(configuration).requires(fields).build() - for workflows that need the bag
363
+ * configured with specific values, as well as initial values provided at runtime
364
+ *
365
+ * The compile-time validation works by:
366
+ * - Analyzing the step dependencies using recursive conditional types
367
+ * - If validation fails, injecting an error property that causes a compile error
368
+ * - If validation passes, allowing the workflow to be created normally
369
+ *
370
+ * Usage:
371
+ * // No initial data required
372
+ * const wf1 = createWorkflow<Bag>("my-workflow").build([stepA, stepB]);
373
+ *
374
+ * // Requires 'promptText' to be provided at runtime
375
+ * const wf2 = createWorkflow<Bag>("prompt-workflow").requires("promptText").build([stepA, stepB]);
376
+ *
377
+ * // Sets lotiContentType to "prompt_media" and requires 'promptText' to be
378
+ * provided at runtime.
379
+ * const wf3 = createWorkflow<Bag>("configured-prompt-workflow")
380
+ * .configure({ lotiContentType: "prompt_media" })
381
+ * .requires("promptText")
382
+ * .build([stepA, stepB]);
383
+ */
384
+ export declare function createWorkflow<Bag extends Record<string, any>>(name: string): {
385
+ build<const Steps extends readonly (Step<Bag, any, any, any, any> | ComposedWorkflow<Bag, any, any>)[]>(steps: Steps & (ValidateWorkflowDeps<Bag, Steps> extends string ? {
386
+ __WORKFLOW_ERROR__: ValidateWorkflowDeps<Bag, Steps>;
387
+ } : unknown)): WorkflowBuilder<Bag, never, never, FlattenStepsType<Bag, Steps>, never>;
388
+ requires<Initial extends keyof Bag>(...fields: Initial[]): {
389
+ build<const Steps extends readonly (Step<Bag, any, any, any, any> | ComposedWorkflow<Bag, any, any>)[]>(steps: Steps & (ValidateWorkflowDepsWithInitial<Bag, Steps, Initial> extends string ? {
390
+ __WORKFLOW_ERROR__: ValidateWorkflowDepsWithInitial<Bag, Steps, Initial>;
391
+ } : unknown)): WorkflowBuilder<Bag, Initial, never, FlattenStepsType<Bag, Steps>, never>;
392
+ };
393
+ configure<Configuration extends Partial<Bag>>(configuration: Configuration): {
394
+ build<const Steps extends readonly (Step<Bag, any, any, any, any> | ComposedWorkflow<Bag, any, any>)[]>(steps: Steps & (ValidateWorkflowDepsWithInitial<Bag, Steps, Extract<keyof Configuration, keyof Bag>> extends string ? {
395
+ __WORKFLOW_ERROR__: ValidateWorkflowDepsWithInitial<Bag, Steps, Extract<keyof Configuration, keyof Bag>>;
396
+ } : unknown)): WorkflowBuilder<Bag, never, Configuration, FlattenStepsType<Bag, Steps>, never>;
397
+ requires<Initial extends Exclude<keyof Bag, Extract<keyof Configuration, keyof Bag>>>(...fields: Initial[]): {
398
+ build<const Steps extends readonly (Step<Bag, any, any, any, any> | ComposedWorkflow<Bag, any, any>)[]>(steps: Steps & (ValidateWorkflowDepsWithInitial<Bag, Steps, Extract<keyof Configuration, keyof Bag> | Initial> extends string ? {
399
+ __WORKFLOW_ERROR__: ValidateWorkflowDepsWithInitial<Bag, Steps, Extract<keyof Configuration, keyof Bag> | Initial>;
400
+ } : unknown)): WorkflowBuilder<Bag, Initial, Configuration, FlattenStepsType<Bag, Steps>, never>;
401
+ };
402
+ };
403
+ };
404
+ /**
405
+ * Recursively flattens a steps array that may contain ComposedWorkflow markers.
406
+ * This mirrors the runtime flattenSteps() function but at the type level.
407
+ */
408
+ type FlattenStepsType<Bag extends Record<string, any>, Items extends readonly (Step<Bag, any, any, any, any> | ComposedWorkflow<Bag, any, any>)[]> = Items extends readonly [infer Head, ...infer Tail] ? Head extends ComposedWorkflow<Bag, any, any, infer ChildSteps> ? Tail extends readonly (Step<Bag, any, any, any, any> | ComposedWorkflow<Bag, any, any>)[] ? [...ChildSteps, ...FlattenStepsType<Bag, Tail>] : ChildSteps : Head extends Step<Bag, any, any, any, any> ? Tail extends readonly (Step<Bag, any, any, any, any> | ComposedWorkflow<Bag, any, any>)[] ? [Head, ...FlattenStepsType<Bag, Tail>] : [Head] : [] : [];
409
+ /**
410
+ * Compile-time dependency validation for workflows with initial fields.
411
+ *
412
+ * This delegates to ValidateStepsInOrder with the initial fields marked as both:
413
+ * - Available: Can be used to satisfy step dependencies
414
+ * - Initial: Protected from being overwritten by steps
415
+ *
416
+ * Composed workflows are flattened, and their initial requirements must be satisfied
417
+ * by either the parent workflow's initial data or preceding steps.
418
+ */
419
+ type ValidateWorkflowDepsWithInitial<Bag extends Record<string, any>, Steps extends readonly (Step<Bag, any, any, any, any> | ComposedWorkflow<Bag, any, any>)[], Initial extends keyof Bag> = ValidateStepsInOrder<Bag, FlattenStepsType<Bag, Steps>, Initial, Initial>;
420
+ /**
421
+ * Main compile-time dependency validation for workflows without initial fields.
422
+ *
423
+ * Special case handling:
424
+ * - Single step workflows: Check if the step has dependencies (if so, error)
425
+ * - Multi-step workflows: Use recursive ValidateStepsInOrder starting with no available fields
426
+ *
427
+ * This ensures clear error messages for the common case of single-step workflows.
428
+ * Composed workflows are flattened, and their initial requirements must be satisfied
429
+ * by preceding steps (since there are no initial fields in this workflow).
430
+ */
431
+ type ValidateWorkflowDeps<Bag extends Record<string, any>, Steps extends readonly (Step<Bag, any, any, any, any> | ComposedWorkflow<Bag, any, any>)[]> = FlattenStepsType<Bag, Steps> extends readonly [infer Head] ? Head extends Step<Bag, infer Needs, any, any> ? Needs[number] extends never ? Steps : WorkflowValidationResult<Needs[number] extends string ? Needs[number] : "unknown", "none"> : Steps : ValidateStepsInOrder<Bag, FlattenStepsType<Bag, Steps>, never, never>;
432
+ /**
433
+ * Template literal type that creates detailed, human-readable error messages
434
+ * for dependency validation failures.
435
+ *
436
+ * Example output:
437
+ * "❌ WORKFLOW ERROR: A step needs identities but it is not available. Available fields: [promptText]
438
+ * → FIX: Add a step that provides identities before the step that needs it"
439
+ */
440
+ type WorkflowValidationResult<MissingField extends string, AvailableFields extends string> = `❌ WORKFLOW ERROR: A step needs ${MissingField} but it is not available. Available fields: [${AvailableFields extends "none" ? "none" : AvailableFields}] → FIX: Add a step that provides ${MissingField} before the step that needs it`;
441
+ type InitialOverwriteError<FieldName extends string> = `❌ WORKFLOW ERROR: A step cannot overwrite initial field ${FieldName}. Initial data is protected from modification. → FIX: Remove ${FieldName} from the step's provides array or from initial data`;
442
+ /**
443
+ * Helper types for precise return type inference.
444
+ *
445
+ * These types work together to determine exactly which fields will be present
446
+ * in the workflow result, enabling compile-time checking when accessing results.
447
+ */
448
+ /**
449
+ * Recursively extracts all 'provides' fields from an array of steps.
450
+ * This creates a union type of all fields that will be produced by the workflow.
451
+ *
452
+ * Example:
453
+ * - Step1 provides: ["a", "b"]
454
+ * - Step2 provides: ["c"]
455
+ * - Result: "a" | "b" | "c"
456
+ */
457
+ type ExtractStepProvides<T> = T extends Step<any, any, infer Provides, any> ? Provides[number] : never;
458
+ type ExtractAllProvides<Steps extends readonly any[]> = Steps extends readonly [
459
+ infer Head,
460
+ ...infer Tail
461
+ ] ? ExtractStepProvides<Head> | ExtractAllProvides<Tail> : never;
462
+ /**
463
+ * Infers the precise return type of a workflow execution.
464
+ *
465
+ * The result includes:
466
+ * - All fields provided by workflow steps (ExtractAllProvides<Steps>)
467
+ * - All initial fields passed to the workflow (Initial)
468
+ *
469
+ * This allows TypeScript to know exactly which properties exist on the result,
470
+ * enabling compile-time checking when accessing workflow results.
471
+ *
472
+ * Note: Steps parameter should already be flattened when this type is used.
473
+ */
474
+ export type InferWorkflowResult<Bag extends Record<string, any>, Steps extends readonly Step<Bag, any, any, any, any>[], Initial extends keyof Bag = never, Configured extends keyof Bag = never> = Pick<Bag, ExtractAllProvides<Steps> | Initial | Configured>;
475
+ /**
476
+ * Safely extracts configured keys from a Config type parameter.
477
+ *
478
+ * This handles the edge case where Config is `never` (no configured values).
479
+ * When Config is `never`, `keyof never` returns `string | number | symbol`,
480
+ * which would incorrectly include all keys. This type returns `never` in that case.
481
+ */
482
+ export type SafeConfiguredKeys<Config, Bag extends Record<string, any>> = [Config] extends [never] ? never : Extract<keyof Config, keyof Bag>;
483
+ /**
484
+ * Extracts the ConfiguredValues type from a Workflow type.
485
+ * Returns never if the workflow has no configured values.
486
+ */
487
+ export type ExtractWorkflowConfig<W> = W extends Workflow<any, any, infer C, any, any> ? C : never;
488
+ /**
489
+ * Extracts the Bag type from a Workflow type.
490
+ */
491
+ export type ExtractWorkflowBag<W> = W extends Workflow<infer B, any, any, any, any> ? B : never;
492
+ /**
493
+ * Extracts the Steps type from a Workflow type.
494
+ */
495
+ export type ExtractWorkflowSteps<W> = W extends Workflow<any, any, any, infer S, any> ? S : never;
496
+ /**
497
+ * Extracts the RequiredInitial type from a Workflow type.
498
+ */
499
+ export type ExtractWorkflowRequiredInitial<W> = W extends Workflow<any, infer R, any, any, any> ? R : never;
500
+ /**
501
+ * Extracts the CheckpointNames type from a Workflow type.
502
+ * Returns `never` if no checkpoints are defined.
503
+ *
504
+ * Note: We use property access via _checkpointNames rather than type parameter
505
+ * inference because TypeScript's `infer` can return the constraint (`string`)
506
+ * instead of the actual value (`never`) in some cases.
507
+ */
508
+ export type ExtractWorkflowCheckpointNames<W> = W extends {
509
+ _checkpointNames?: infer C;
510
+ } ? C extends string ? C : never : never;
511
+ /**
512
+ * Recursive type that validates step dependencies in order.
513
+ *
514
+ * This is the core validation logic that:
515
+ * 1. Processes steps one by one from left to right
516
+ * 2. Checks if each step's 'needs' are satisfied by available fields
517
+ * 3. Adds each step's 'provides' to the available fields for subsequent steps
518
+ * 4. Prevents steps from overwriting initial fields
519
+ * 5. Accumulates provided fields for subsequent steps
520
+ *
521
+ * Parameters:
522
+ * - Bag: The complete data type
523
+ * - Steps: Remaining steps to validate
524
+ * - Available: Fields currently available (from previous steps + initial)
525
+ * - Initial: Fields provided initially (protected from overwriting)
526
+ *
527
+ * Returns:
528
+ * - Steps (unchanged) if validation passes
529
+ * - Error message string if validation fails
530
+ */
531
+ type ValidateStepsInOrder<Bag extends Record<string, any>, Steps extends readonly Step<Bag, any, any, any, any>[], Available extends keyof Bag, Initial extends keyof Bag = never> = Steps extends readonly [infer Head, ...infer Tail] ? Head extends Step<Bag, infer Needs, infer Provides, any> ? Tail extends readonly Step<Bag, any, any, any, any>[] ? Extract<Provides[number], Initial> extends never ? Needs[number] extends Available ? ValidateStepsInOrder<Bag, Tail, Available | Provides[number], Initial> : WorkflowValidationResult<Exclude<Needs[number], Available> extends string ? Exclude<Needs[number], Available> : "unknown", Available extends never ? "none" : Available extends string ? Available : "unknown"> : InitialOverwriteError<Extract<Provides[number], Initial> extends string ? Extract<Provides[number], Initial> : "unknown"> : Steps : Steps : Steps;
532
+ export declare function runSyncWorkflow<Bag extends Record<string, any>, Config extends Partial<Bag>, Steps extends readonly Step<Bag, any, any, any, any>[]>(wf: Workflow<Bag, never, Config, Steps>, initialData?: Partial<Bag>, contextProvider?: StepContextProvider<unknown>, logger?: ComposerLogger, enableDeepFreeze?: boolean): Promise<WorkflowResult<InferWorkflowResult<Bag, Steps, never, Extract<keyof Config, keyof Bag>> & Partial<Bag>>>;
533
+ export declare function runSyncWorkflow<Bag extends Record<string, any>, RequiredInitial extends keyof Bag, Config extends Partial<Bag>, Steps extends readonly Step<Bag, any, any, any, any>[]>(wf: Workflow<Bag, RequiredInitial, Config, Steps>, initialData: Partial<Bag> & Pick<Bag, RequiredInitial>, contextProvider?: StepContextProvider<unknown>, logger?: ComposerLogger, enableDeepFreeze?: boolean): Promise<WorkflowResult<InferWorkflowResult<Bag, Steps, RequiredInitial, Extract<keyof Config, keyof Bag>>>>;
534
+ export {};
535
+ //# sourceMappingURL=dag-sync-workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dag-sync-workflow.d.ts","sourceRoot":"","sources":["../../src/internal/dag-sync-workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAG9D,OAAO,KAAK,EAAoB,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAU9F,OAAO,KAAK,EAAE,cAAc,EAAU,MAAM,SAAS,CAAC;A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