@orbytautomation/engine 0.3.0 → 0.4.1

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 (255) hide show
  1. package/dist/adapters/AdapterRegistry.d.ts.map +1 -1
  2. package/dist/adapters/AdapterRegistry.js +6 -0
  3. package/dist/adapters/AdapterRegistry.js.map +1 -1
  4. package/dist/automation/BackoffStrategy.d.ts +1 -19
  5. package/dist/automation/BackoffStrategy.d.ts.map +1 -1
  6. package/dist/automation/BackoffStrategy.js.map +1 -1
  7. package/dist/automation/FailureStrategy.d.ts +1 -34
  8. package/dist/automation/FailureStrategy.d.ts.map +1 -1
  9. package/dist/automation/FailureStrategy.js.map +1 -1
  10. package/dist/automation/RetryPolicy.d.ts +2 -22
  11. package/dist/automation/RetryPolicy.d.ts.map +1 -1
  12. package/dist/automation/RetryPolicy.js.map +1 -1
  13. package/dist/automation/TimeoutManager.d.ts +1 -26
  14. package/dist/automation/TimeoutManager.d.ts.map +1 -1
  15. package/dist/automation/TimeoutManager.js.map +1 -1
  16. package/dist/automation/runtime/FailureHandler.d.ts +2 -57
  17. package/dist/automation/runtime/FailureHandler.d.ts.map +1 -1
  18. package/dist/automation/runtime/FailureHandler.js.map +1 -1
  19. package/dist/context/ContextStore.d.ts +1 -36
  20. package/dist/context/ContextStore.d.ts.map +1 -1
  21. package/dist/context/ContextStore.js.map +1 -1
  22. package/dist/context/VariableResolver.d.ts +1 -44
  23. package/dist/context/VariableResolver.d.ts.map +1 -1
  24. package/dist/context/VariableResolver.js +7 -0
  25. package/dist/context/VariableResolver.js.map +1 -1
  26. package/dist/core/EngineConfig.d.ts +1 -138
  27. package/dist/core/EngineConfig.d.ts.map +1 -1
  28. package/dist/core/EngineConfig.js.map +1 -1
  29. package/dist/core/EngineContext.d.ts +1 -62
  30. package/dist/core/EngineContext.d.ts.map +1 -1
  31. package/dist/core/EngineContext.js.map +1 -1
  32. package/dist/core/OrbytEngine.d.ts +19 -6
  33. package/dist/core/OrbytEngine.d.ts.map +1 -1
  34. package/dist/core/OrbytEngine.js +81 -4
  35. package/dist/core/OrbytEngine.js.map +1 -1
  36. package/dist/core/index.d.ts +1 -1
  37. package/dist/core/index.d.ts.map +1 -1
  38. package/dist/core/index.js +1 -1
  39. package/dist/core/index.js.map +1 -1
  40. package/dist/errors/ErrorDebugger.d.ts.map +1 -1
  41. package/dist/errors/ErrorDebugger.js +7 -0
  42. package/dist/errors/ErrorDebugger.js.map +1 -1
  43. package/dist/errors/ErrorDetector.d.ts.map +1 -1
  44. package/dist/errors/ErrorDetector.js +12 -0
  45. package/dist/errors/ErrorDetector.js.map +1 -1
  46. package/dist/errors/ErrorFormatter.d.ts +1 -1
  47. package/dist/errors/ErrorFormatter.d.ts.map +1 -1
  48. package/dist/errors/OrbytError.d.ts +1 -20
  49. package/dist/errors/OrbytError.d.ts.map +1 -1
  50. package/dist/errors/OrbytError.js.map +1 -1
  51. package/dist/errors/SecurityErrors.d.ts +2 -38
  52. package/dist/errors/SecurityErrors.d.ts.map +1 -1
  53. package/dist/errors/SecurityErrors.js +0 -20
  54. package/dist/errors/SecurityErrors.js.map +1 -1
  55. package/dist/errors/WorkflowError.d.ts +2 -1
  56. package/dist/errors/WorkflowError.d.ts.map +1 -1
  57. package/dist/errors/WorkflowError.js.map +1 -1
  58. package/dist/events/EngineEvents.d.ts +1 -123
  59. package/dist/events/EngineEvents.d.ts.map +1 -1
  60. package/dist/events/EngineEvents.js +0 -35
  61. package/dist/events/EngineEvents.js.map +1 -1
  62. package/dist/events/EventBus.d.ts +1 -1
  63. package/dist/events/EventBus.d.ts.map +1 -1
  64. package/dist/events/EventBus.js.map +1 -1
  65. package/dist/execution/ExecutionEngine.d.ts +1 -68
  66. package/dist/execution/ExecutionEngine.d.ts.map +1 -1
  67. package/dist/execution/ExecutionEngine.js +43 -11
  68. package/dist/execution/ExecutionEngine.js.map +1 -1
  69. package/dist/execution/ExecutionLimits.d.ts +1 -47
  70. package/dist/execution/ExecutionLimits.d.ts.map +1 -1
  71. package/dist/execution/ExecutionLimits.js +1 -60
  72. package/dist/execution/ExecutionLimits.js.map +1 -1
  73. package/dist/execution/ExecutionNode.d.ts +1 -64
  74. package/dist/execution/ExecutionNode.d.ts.map +1 -1
  75. package/dist/execution/ExecutionNode.js.map +1 -1
  76. package/dist/execution/ExecutionPlan.d.ts +1 -31
  77. package/dist/execution/ExecutionPlan.d.ts.map +1 -1
  78. package/dist/execution/ExecutionPlan.js +21 -1
  79. package/dist/execution/ExecutionPlan.js.map +1 -1
  80. package/dist/execution/ExecutionStrategyResolver.d.ts +1 -54
  81. package/dist/execution/ExecutionStrategyResolver.d.ts.map +1 -1
  82. package/dist/execution/ExecutionStrategyResolver.js.map +1 -1
  83. package/dist/execution/IntentAnalyzer.d.ts +1 -37
  84. package/dist/execution/IntentAnalyzer.d.ts.map +1 -1
  85. package/dist/execution/IntentAnalyzer.js +20 -0
  86. package/dist/execution/IntentAnalyzer.js.map +1 -1
  87. package/dist/execution/InternalExecutionContext.d.ts +1 -196
  88. package/dist/execution/InternalExecutionContext.d.ts.map +1 -1
  89. package/dist/execution/InternalExecutionContext.js.map +1 -1
  90. package/dist/execution/StepExecutor.d.ts +1 -39
  91. package/dist/execution/StepExecutor.d.ts.map +1 -1
  92. package/dist/execution/StepExecutor.js +111 -30
  93. package/dist/execution/StepExecutor.js.map +1 -1
  94. package/dist/execution/WorkflowExecutor.d.ts +1 -48
  95. package/dist/execution/WorkflowExecutor.d.ts.map +1 -1
  96. package/dist/execution/WorkflowExecutor.js +33 -1
  97. package/dist/execution/WorkflowExecutor.js.map +1 -1
  98. package/dist/execution/drivers/AdapterDriver.d.ts +2 -1
  99. package/dist/execution/drivers/AdapterDriver.d.ts.map +1 -1
  100. package/dist/execution/drivers/AdapterDriver.js.map +1 -1
  101. package/dist/execution/drivers/DriverResolver.d.ts +1 -1
  102. package/dist/execution/drivers/DriverResolver.d.ts.map +1 -1
  103. package/dist/execution/drivers/DriverResolver.js.map +1 -1
  104. package/dist/execution/drivers/ExecutionDriver.d.ts +1 -94
  105. package/dist/execution/drivers/ExecutionDriver.d.ts.map +1 -1
  106. package/dist/execution/drivers/ExecutionDriver.js.map +1 -1
  107. package/dist/explanation/ExplanationGenerator.d.ts +104 -0
  108. package/dist/explanation/ExplanationGenerator.d.ts.map +1 -0
  109. package/dist/explanation/ExplanationGenerator.js +814 -0
  110. package/dist/explanation/ExplanationGenerator.js.map +1 -0
  111. package/dist/explanation/ExplanationLogger.d.ts +50 -0
  112. package/dist/explanation/ExplanationLogger.d.ts.map +1 -0
  113. package/dist/explanation/ExplanationLogger.js +284 -0
  114. package/dist/explanation/ExplanationLogger.js.map +1 -0
  115. package/dist/explanation/index.d.ts +11 -0
  116. package/dist/explanation/index.d.ts.map +1 -0
  117. package/dist/explanation/index.js +11 -0
  118. package/dist/explanation/index.js.map +1 -0
  119. package/dist/graph/CycleDetector.d.ts +1 -10
  120. package/dist/graph/CycleDetector.d.ts.map +1 -1
  121. package/dist/graph/CycleDetector.js +1 -12
  122. package/dist/graph/CycleDetector.js.map +1 -1
  123. package/dist/graph/DependencyGraph.d.ts +3 -3
  124. package/dist/graph/DependencyGraph.d.ts.map +1 -1
  125. package/dist/graph/DependencyGraph.js +1 -1
  126. package/dist/graph/DependencyGraph.js.map +1 -1
  127. package/dist/graph/DependencyResolver.d.ts +1 -23
  128. package/dist/graph/DependencyResolver.d.ts.map +1 -1
  129. package/dist/graph/DependencyResolver.js.map +1 -1
  130. package/dist/graph/TopologicalSorter.d.ts +1 -34
  131. package/dist/graph/TopologicalSorter.d.ts.map +1 -1
  132. package/dist/graph/TopologicalSorter.js.map +1 -1
  133. package/dist/guards/ResourceGuard.d.ts +1 -20
  134. package/dist/guards/ResourceGuard.d.ts.map +1 -1
  135. package/dist/guards/ResourceGuard.js.map +1 -1
  136. package/dist/guards/StepGuard.d.ts +1 -1
  137. package/dist/guards/StepGuard.d.ts.map +1 -1
  138. package/dist/guards/StepGuard.js.map +1 -1
  139. package/dist/guards/WorkflowGuard.d.ts +1 -1
  140. package/dist/guards/WorkflowGuard.d.ts.map +1 -1
  141. package/dist/guards/WorkflowGuard.js.map +1 -1
  142. package/dist/hooks/HookManager.d.ts.map +1 -1
  143. package/dist/hooks/HookManager.js +8 -0
  144. package/dist/hooks/HookManager.js.map +1 -1
  145. package/dist/index.d.ts +5 -0
  146. package/dist/index.d.ts.map +1 -1
  147. package/dist/index.js +6 -0
  148. package/dist/index.js.map +1 -1
  149. package/dist/lifecycle/ShutdownManager.d.ts.map +1 -1
  150. package/dist/lifecycle/ShutdownManager.js +22 -9
  151. package/dist/lifecycle/ShutdownManager.js.map +1 -1
  152. package/dist/lifecycle/StartupManager.d.ts.map +1 -1
  153. package/dist/lifecycle/StartupManager.js +16 -5
  154. package/dist/lifecycle/StartupManager.js.map +1 -1
  155. package/dist/loader/WorkflowLoader.d.ts +2 -25
  156. package/dist/loader/WorkflowLoader.d.ts.map +1 -1
  157. package/dist/loader/WorkflowLoader.js.map +1 -1
  158. package/dist/loader/index.d.ts +0 -8
  159. package/dist/loader/index.d.ts.map +1 -1
  160. package/dist/loader/index.js +0 -8
  161. package/dist/loader/index.js.map +1 -1
  162. package/dist/logging/EngineLogger.d.ts +492 -0
  163. package/dist/logging/EngineLogger.d.ts.map +1 -0
  164. package/dist/logging/EngineLogger.js +1170 -0
  165. package/dist/logging/EngineLogger.js.map +1 -0
  166. package/dist/logging/LoggerManager.d.ts +49 -0
  167. package/dist/logging/LoggerManager.d.ts.map +1 -0
  168. package/dist/logging/LoggerManager.js +94 -0
  169. package/dist/logging/LoggerManager.js.map +1 -0
  170. package/dist/logging/index.d.ts +2 -1
  171. package/dist/logging/index.d.ts.map +1 -1
  172. package/dist/logging/index.js +2 -3
  173. package/dist/logging/index.js.map +1 -1
  174. package/dist/parser/SchemaValidator.d.ts.map +1 -1
  175. package/dist/parser/SchemaValidator.js +6 -0
  176. package/dist/parser/SchemaValidator.js.map +1 -1
  177. package/dist/parser/StepParser.d.ts +1 -33
  178. package/dist/parser/StepParser.d.ts.map +1 -1
  179. package/dist/parser/StepParser.js +14 -1
  180. package/dist/parser/StepParser.js.map +1 -1
  181. package/dist/parser/WorkflowParser.d.ts +1 -68
  182. package/dist/parser/WorkflowParser.d.ts.map +1 -1
  183. package/dist/parser/WorkflowParser.js +53 -28
  184. package/dist/parser/WorkflowParser.js.map +1 -1
  185. package/dist/queue/InMemoryQueue.d.ts +1 -1
  186. package/dist/queue/InMemoryQueue.d.ts.map +1 -1
  187. package/dist/queue/InMemoryQueue.js.map +1 -1
  188. package/dist/queue/JobQueue.d.ts +1 -186
  189. package/dist/queue/JobQueue.d.ts.map +1 -1
  190. package/dist/queue/JobQueue.js +1 -10
  191. package/dist/queue/JobQueue.js.map +1 -1
  192. package/dist/scheduling/CronScheduler.d.ts +1 -31
  193. package/dist/scheduling/CronScheduler.d.ts.map +1 -1
  194. package/dist/scheduling/CronScheduler.js +1 -1
  195. package/dist/scheduling/CronScheduler.js.map +1 -1
  196. package/dist/scheduling/JobScheduler.d.ts +2 -3
  197. package/dist/scheduling/JobScheduler.d.ts.map +1 -1
  198. package/dist/scheduling/JobScheduler.js +2 -1
  199. package/dist/scheduling/JobScheduler.js.map +1 -1
  200. package/dist/scheduling/ScheduleParser.d.ts.map +1 -1
  201. package/dist/scheduling/ScheduleParser.js +7 -0
  202. package/dist/scheduling/ScheduleParser.js.map +1 -1
  203. package/dist/scheduling/ScheduleTypes.d.ts +1 -131
  204. package/dist/scheduling/ScheduleTypes.d.ts.map +1 -1
  205. package/dist/scheduling/ScheduleTypes.js.map +1 -1
  206. package/dist/scheduling/Scheduler.d.ts +2 -3
  207. package/dist/scheduling/Scheduler.d.ts.map +1 -1
  208. package/dist/scheduling/Scheduler.js +13 -0
  209. package/dist/scheduling/Scheduler.js.map +1 -1
  210. package/dist/security/PermissionPolicy.d.ts +1 -13
  211. package/dist/security/PermissionPolicy.d.ts.map +1 -1
  212. package/dist/security/PermissionPolicy.js +1 -14
  213. package/dist/security/PermissionPolicy.js.map +1 -1
  214. package/dist/security/ReservedFields.d.ts +0 -20
  215. package/dist/security/ReservedFields.d.ts.map +1 -1
  216. package/dist/security/ReservedFields.js +2 -71
  217. package/dist/security/ReservedFields.js.map +1 -1
  218. package/dist/security/SandboxManager.d.ts +1 -29
  219. package/dist/security/SandboxManager.d.ts.map +1 -1
  220. package/dist/security/SandboxManager.js.map +1 -1
  221. package/dist/state/ExecutionState.d.ts +1 -123
  222. package/dist/state/ExecutionState.d.ts.map +1 -1
  223. package/dist/state/ExecutionState.js +1 -51
  224. package/dist/state/ExecutionState.js.map +1 -1
  225. package/dist/state/StateMachine.d.ts +1 -25
  226. package/dist/state/StateMachine.d.ts.map +1 -1
  227. package/dist/state/StateMachine.js +1 -1
  228. package/dist/state/StateMachine.js.map +1 -1
  229. package/dist/testing/EngineTestHarness.d.ts +1 -1
  230. package/dist/testing/EngineTestHarness.d.ts.map +1 -1
  231. package/dist/types/core-types.d.ts +2306 -4
  232. package/dist/types/core-types.d.ts.map +1 -1
  233. package/dist/types/core-types.js +272 -1
  234. package/dist/types/core-types.js.map +1 -1
  235. package/dist/types/index.d.ts +3 -0
  236. package/dist/types/index.d.ts.map +1 -0
  237. package/dist/types/index.js +3 -0
  238. package/dist/types/index.js.map +1 -0
  239. package/dist/types/log-types.d.ts +105 -0
  240. package/dist/types/log-types.d.ts.map +1 -0
  241. package/dist/types/log-types.js +42 -0
  242. package/dist/types/log-types.js.map +1 -0
  243. package/package.json +2 -2
  244. package/dist/core/EngineLogger.d.ts +0 -182
  245. package/dist/core/EngineLogger.d.ts.map +0 -1
  246. package/dist/core/EngineLogger.js +0 -293
  247. package/dist/core/EngineLogger.js.map +0 -1
  248. package/dist/logging/LogLevel.d.ts +0 -2
  249. package/dist/logging/LogLevel.d.ts.map +0 -1
  250. package/dist/logging/LogLevel.js +0 -2
  251. package/dist/logging/LogLevel.js.map +0 -1
  252. package/dist/logging/Logger.d.ts +0 -2
  253. package/dist/logging/Logger.d.ts.map +0 -1
  254. package/dist/logging/Logger.js +0 -2
  255. package/dist/logging/Logger.js.map +0 -1
@@ -1,4 +1,16 @@
1
- import { OwnershipContext } from "../execution/InternalExecutionContext.js";
1
+ import { Adapter, AdapterResult, ExitCodes, TriggerType as TriggerEnums } from "@dev-ecosystem/core";
2
+ import { TimeoutError, TimeoutManager } from "../automation/TimeoutManager.js";
3
+ import { BackoffStrategy } from "../automation/BackoffStrategy.js";
4
+ import { RetryPolicy } from "../automation/RetryPolicy.js";
5
+ import { EngineLogger } from "../logging/EngineLogger.js";
6
+ import { LifecycleHook } from "../hooks/LifecycleHooks.js";
7
+ import { WorkflowExecutor } from "../execution/WorkflowExecutor.js";
8
+ import { StepExecutor } from "../execution/StepExecutor.js";
9
+ import { AdapterRegistry } from "../adapters/AdapterRegistry.js";
10
+ import { HookManager } from "../hooks/HookManager.js";
11
+ import { ExecutionEngine } from "../execution/ExecutionEngine.js";
12
+ import { EventBus } from "../events/EventBus.js";
13
+ import { ErrorSeverity, OrbytErrorCode } from "../errors/ErrorCodes.js";
2
14
  /**
3
15
  * Workflow run options
4
16
  * User-friendly options for running a workflow
@@ -41,19 +53,2309 @@ export interface WorkflowRunOptions {
41
53
  * INTERNAL USE: Not for user workflows
42
54
  */
43
55
  _ownershipContext?: Partial<OwnershipContext>;
56
+ /**
57
+ * Permission policy for this execution
58
+ */
59
+ _permissionPolicy?: PermissionPolicy;
44
60
  }
45
61
  /**
46
- * Workflow load options
47
- * Options for loading a workflow from file
62
+ * Workflow loading options
48
63
  */
49
64
  export interface WorkflowLoadOptions {
50
65
  /**
51
66
  * Base directory for resolving relative paths
67
+ * Defaults to dirname of the loaded file
52
68
  */
53
69
  baseDir?: string;
54
70
  /**
55
- * Variables to inject during parsing
71
+ * Variables to inject during loading
56
72
  */
57
73
  variables?: Record<string, any>;
74
+ /**
75
+ * Whether to validate the workflow after loading
76
+ * Default: true
77
+ */
78
+ validate?: boolean;
79
+ /**
80
+ * Optional EngineLogger for structured error logging
81
+ */
82
+ logger?: EngineLogger;
83
+ }
84
+ /**
85
+ * Execution Identity (Engine-Generated)
86
+ * Generated for each workflow execution
87
+ */
88
+ export interface ExecutionIdentity {
89
+ /** Unique execution ID (generated by engine) */
90
+ executionId: string;
91
+ /** Run ID for this workflow execution */
92
+ runId: string;
93
+ /** Trace ID for distributed tracing */
94
+ traceId: string;
95
+ /** Parent run ID if this is a nested workflow */
96
+ parentRunId?: string;
97
+ /** Execution start timestamp */
98
+ startedAt: Date;
99
+ /** Engine version that executed this workflow */
100
+ engineVersion: string;
101
+ /** Node ID for future distributed execution */
102
+ nodeId?: string;
103
+ }
104
+ /**
105
+ * Ownership Context (From Bridge/API)
106
+ * Passed from website/bridge to engine
107
+ */
108
+ export interface OwnershipContext {
109
+ /** User ID who triggered execution */
110
+ userId: string;
111
+ /** Workspace/organization ID */
112
+ workspaceId: string;
113
+ /** Subscription ID */
114
+ subscriptionId: string;
115
+ /** Subscription tier (free, pro, enterprise) */
116
+ subscriptionTier: string;
117
+ /** Geographic region */
118
+ region: string;
119
+ /** Pricing model (ecosystem | component) */
120
+ pricingModel: 'ecosystem' | 'component';
121
+ /** Billing mode */
122
+ billingMode: 'ecosystem' | 'component';
123
+ }
124
+ /**
125
+ * Billing Snapshot (Frozen at Execution Start)
126
+ * Prevents billing disputes when pricing changes
127
+ */
128
+ export interface BillingSnapshot {
129
+ /** Base cost per automation execution */
130
+ baseExecutionCost: number;
131
+ /** Base cost per step */
132
+ baseStepCost: number;
133
+ /** Pricing tier at execution time */
134
+ pricingTier: string;
135
+ /** Discount applied (%) */
136
+ discountApplied: number;
137
+ /** Promo code applied */
138
+ promoApplied?: string;
139
+ /** Effective rate after discounts */
140
+ effectiveRate: number;
141
+ /** Billing snapshot version (for audit) */
142
+ snapshotVersion: string;
143
+ /** Timestamp when snapshot was taken */
144
+ snapshotAt: Date;
145
+ }
146
+ /**
147
+ * Usage Counters (Engine-Calculated)
148
+ * Never user-editable
149
+ */
150
+ export interface UsageCounters {
151
+ /** Number of automations executed (always 1 per workflow) */
152
+ automationCount: number;
153
+ /** Total number of steps executed */
154
+ stepCount: number;
155
+ /** Weighted step count (sum of step weights) */
156
+ weightedStepCount: number;
157
+ /** Execution duration in seconds */
158
+ durationSeconds: number;
159
+ /** CPU usage (future) */
160
+ resourceUsageCpu?: number;
161
+ /** Memory usage (future) */
162
+ resourceUsageMemory?: number;
163
+ }
164
+ /**
165
+ * Derived Billing Context (Engine-Computed)
166
+ * Calculated based on ownership + snapshot
167
+ */
168
+ export interface DerivedBillingContext {
169
+ /** Is this execution billable */
170
+ isBillable: boolean;
171
+ /** Billing scope resolved */
172
+ billingScopeResolved: 'workflow' | 'step' | 'both';
173
+ /** Effective product billing to */
174
+ effectiveProduct: string;
175
+ /** Pricing tier resolved from subscription */
176
+ pricingTierResolved: string;
177
+ /** Final cost calculated */
178
+ totalCost: number;
179
+ }
180
+ /**
181
+ * Security Metadata (Engine-Controlled)
182
+ * Security boundaries and permissions
183
+ */
184
+ export interface SecurityMetadata {
185
+ /** Payment status (affects execution) */
186
+ paymentStatus: 'active' | 'past_due' | 'canceled' | 'trial';
187
+ /** Request source IP (optional) */
188
+ ipAddress?: string;
189
+ /** Security policy version */
190
+ securityPolicyVersion?: string;
191
+ /** Execution isolation level */
192
+ isolationLevel: 'process' | 'container' | 'vm';
193
+ /** Permissions granted for this execution */
194
+ permissionsGranted: string[];
195
+ }
196
+ /**
197
+ * Runtime State (Engine-Managed)
198
+ * Current execution state
199
+ */
200
+ export interface RuntimeState {
201
+ /** Current workflow state */
202
+ workflowState: 'pending' | 'running' | 'completed' | 'failed' | 'timeout' | 'cancelled';
203
+ /** Actual retry count (not user-defined max) */
204
+ retryCountActual: number;
205
+ /** Was timeout triggered? */
206
+ timeoutTriggered: boolean;
207
+ /** Execution graph (resolved dependencies) */
208
+ executionGraph?: Record<string, string[]>;
209
+ /** Steps state map */
210
+ stepsState: Record<string, 'pending' | 'running' | 'completed' | 'failed' | 'skipped'>;
211
+ }
212
+ /**
213
+ * Request Context (Origin Information)
214
+ * Where the execution request came from
215
+ */
216
+ export interface RequestContext {
217
+ /** Request origin */
218
+ origin: 'cli' | 'api' | 'sdk' | 'webhook' | 'scheduler';
219
+ /** Execution mode */
220
+ mode: 'local' | 'server' | 'embedded' | 'dry-run';
221
+ /** Who/what triggered this */
222
+ triggeredBy?: string;
223
+ }
224
+ /**
225
+ * Internal Execution Context (Complete)
226
+ * This is what engine maintains internally. NEVER exposed to workflow.
227
+ */
228
+ export interface InternalExecutionContext {
229
+ /** Execution identity */
230
+ _identity: ExecutionIdentity;
231
+ /** Ownership from bridge */
232
+ _ownership: OwnershipContext;
233
+ /** Billing snapshot (frozen) */
234
+ _billingSnapshot: BillingSnapshot;
235
+ /** Usage counters */
236
+ _usage: UsageCounters;
237
+ /** Derived billing context */
238
+ _billing: DerivedBillingContext;
239
+ /** Tier-based execution limits (ENFORCED by engine) */
240
+ _limits: TierLimits;
241
+ /** Security metadata */
242
+ _security: SecurityMetadata;
243
+ /** Runtime state */
244
+ _runtime: RuntimeState;
245
+ /** Request context */
246
+ _request: RequestContext;
247
+ /** Audit metadata */
248
+ _audit: {
249
+ engineVersion: string;
250
+ billingSnapshotVersion: string;
251
+ executionVersion: string;
252
+ };
253
+ }
254
+ /**
255
+ * Step-level Internal Context
256
+ * Injected into each step execution
257
+ */
258
+ export interface InternalStepContext {
259
+ /** Step usage (engine-calculated from user weight or default) */
260
+ usage: {
261
+ billable: boolean;
262
+ unit: string;
263
+ weight: number;
264
+ computedCost: number;
265
+ };
266
+ /** Step requirements (engine-validated) */
267
+ requires: {
268
+ capabilities: string[];
269
+ validated: boolean;
270
+ };
271
+ /** Execution hints (engine-optimized) */
272
+ hints: {
273
+ cacheable: boolean;
274
+ idempotent: boolean;
275
+ heavy: boolean;
276
+ cost: 'free' | 'low' | 'medium' | 'high';
277
+ };
278
+ }
279
+ /**
280
+ * Execution limits based on subscription tier
281
+ */
282
+ export interface TierLimits {
283
+ /** Maximum retry attempts per step */
284
+ maxRetryAttempts: number;
285
+ /** Maximum step timeout in milliseconds */
286
+ maxStepTimeout: number;
287
+ /** Maximum workflow timeout in milliseconds */
288
+ maxWorkflowTimeout: number;
289
+ /** Maximum concurrent steps */
290
+ maxConcurrency: number;
291
+ /** Maximum steps per workflow */
292
+ maxStepsPerWorkflow: number;
293
+ /** Maximum workflow depth (nested workflows) */
294
+ maxWorkflowDepth: number;
295
+ /** Maximum file size for FS operations (bytes) */
296
+ maxFileSize: number;
297
+ /** Maximum HTTP request timeout (ms) */
298
+ maxHttpTimeout: number;
299
+ /** Allowed execution modes */
300
+ allowedExecutionModes: Array<'local' | 'docker' | 'remote' | 'distributed'>;
301
+ /** Minimum sandbox level */
302
+ minSandboxLevel: 'none' | 'basic' | 'strict';
303
+ /** Can disable sandboxing */
304
+ canDisableSandbox: boolean;
305
+ /** Can set high priority */
306
+ canSetHighPriority: boolean;
307
+ /** Maximum CPU cores */
308
+ maxCpu: number;
309
+ /** Maximum memory (MB) */
310
+ maxMemoryMB: number;
311
+ /** Maximum disk space (MB) */
312
+ maxDiskMB: number;
313
+ }
314
+ /**
315
+ * Default limits for free tier (most restrictive)
316
+ */
317
+ export declare const FREE_TIER_LIMITS: TierLimits;
318
+ /**
319
+ * Pro tier limits
320
+ */
321
+ export declare const PRO_TIER_LIMITS: TierLimits;
322
+ /**
323
+ * Enterprise tier limits
324
+ */
325
+ export declare const ENTERPRISE_TIER_LIMITS: TierLimits;
326
+ /**
327
+ * Execution trigger type
328
+ */
329
+ export type TriggerType = TriggerEnums.Cron | TriggerEnums.Interval | TriggerEnums.Once | TriggerEnums.Manual | TriggerEnums.Event | TriggerEnums.Webhook;
330
+ /**
331
+ * Workflow execution job payload
332
+ */
333
+ export interface WorkflowExecutionPayload {
334
+ /** Workflow definition (YAML string or parsed object) */
335
+ workflow: string | ParsedWorkflow;
336
+ /** Execution options */
337
+ options?: ExecutionOptions;
338
+ /** Trigger information */
339
+ trigger: {
340
+ type: TriggerType;
341
+ source?: string;
342
+ metadata?: Record<string, any>;
343
+ };
344
+ }
345
+ /**
346
+ * Execution engine configuration
347
+ */
348
+ export interface EngineConfig {
349
+ /** Maximum concurrent workflow executions */
350
+ maxConcurrentExecutions?: number;
351
+ /** Default workflow timeout (ms) */
352
+ defaultTimeout?: number;
353
+ /** Enable scheduler */
354
+ enableScheduler?: boolean;
355
+ /** Custom job queue (default: InMemoryQueue) */
356
+ queue?: JobQueue;
357
+ /** Global retry policy for workflows */
358
+ retryPolicy?: RetryPolicy;
359
+ /** Timeout manager instance */
360
+ timeoutManager?: TimeoutManager;
361
+ }
362
+ /**
363
+ * Workflow execution status
364
+ */
365
+ export interface WorkflowExecutionStatus {
366
+ /** Execution ID */
367
+ executionId: string;
368
+ /** Workflow name */
369
+ workflowName: string;
370
+ /** Current status */
371
+ status: 'queued' | 'running' | 'completed' | 'failed' | 'timeout';
372
+ /** Trigger information */
373
+ trigger: {
374
+ type: TriggerType;
375
+ source?: string;
376
+ triggeredAt: Date;
377
+ };
378
+ /** Execution result (if completed) */
379
+ result?: WorkflowResult;
380
+ /** Error (if failed) */
381
+ error?: Error;
382
+ /** Progress information */
383
+ progress?: {
384
+ currentStep?: string;
385
+ completedSteps: number;
386
+ totalSteps: number;
387
+ };
388
+ }
389
+ /**
390
+ * Retry condition - determines if error is retryable
391
+ */
392
+ export type RetryCondition = (error: Error, attempt: number) => boolean;
393
+ /**
394
+ * Retry policy configuration
395
+ */
396
+ export interface RetryPolicyConfig {
397
+ /** Maximum retry attempts (0 = no retries) */
398
+ maxAttempts: number;
399
+ /** Backoff strategy for delays between retries */
400
+ backoffStrategy: BackoffStrategy;
401
+ /** Custom retry condition (default: retry all errors) */
402
+ retryCondition?: RetryCondition;
403
+ /** Specific error types to retry (if provided, only these are retried) */
404
+ retryableErrors?: Array<new (...args: any[]) => Error>;
405
+ /** Error messages to match for retry (regex patterns) */
406
+ retryableMessages?: RegExp[];
407
+ /** Abort retry on specific errors (overrides other conditions) */
408
+ abortOn?: Array<new (...args: any[]) => Error>;
409
+ }
410
+ /**
411
+ * Backoff strategy type
412
+ */
413
+ export type BackoffType = 'fixed' | 'linear' | 'exponential';
414
+ /**
415
+ * Backoff strategy configuration
416
+ */
417
+ export interface BackoffConfig {
418
+ /** Strategy type */
419
+ type: BackoffType;
420
+ /** Base delay in milliseconds */
421
+ baseDelayMs: number;
422
+ /** Maximum delay cap in milliseconds */
423
+ maxDelayMs?: number;
424
+ /** Multiplier for exponential backoff (default: 2) */
425
+ multiplier?: number;
426
+ /** Add random jitter (0-1, default: 0.1 = 10%) */
427
+ jitter?: number;
428
+ }
429
+ /**
430
+ * Timeout configuration
431
+ */
432
+ export interface TimeoutConfig {
433
+ /** Timeout duration in milliseconds */
434
+ timeoutMs: number;
435
+ /** Operation name for error messages */
436
+ operation?: string;
437
+ /** Cleanup function to run on timeout */
438
+ onTimeout?: () => Promise<void> | void;
439
+ /** Whether to run cleanup before throwing (default: true) */
440
+ cleanupBeforeThrow?: boolean;
441
+ }
442
+ /**
443
+ * Timeout result
444
+ */
445
+ export interface TimeoutResult<T> {
446
+ /** Operation result (undefined if timed out) */
447
+ result?: T;
448
+ /** Whether operation timed out */
449
+ timedOut: boolean;
450
+ /** Actual duration in milliseconds */
451
+ durationMs: number;
452
+ /** Timeout error if timed out */
453
+ error?: TimeoutError;
454
+ }
455
+ /**
456
+ * Job status
457
+ */
458
+ export type JobStatus = 'pending' | 'running' | 'completed' | 'failed' | 'retrying';
459
+ /**
460
+ * Job priority levels
461
+ */
462
+ export declare enum JobPriority {
463
+ LOW = 0,
464
+ NORMAL = 1,
465
+ HIGH = 2,
466
+ CRITICAL = 3
467
+ }
468
+ /**
469
+ * Job metadata
470
+ */
471
+ export interface JobMetadata {
472
+ /** When job was created */
473
+ createdAt: Date;
474
+ /** When job started executing */
475
+ startedAt?: Date;
476
+ /** When job completed */
477
+ completedAt?: Date;
478
+ /** Execution duration in ms */
479
+ durationMs?: number;
480
+ /** Job tags for filtering/grouping */
481
+ tags?: string[];
482
+ /** Custom metadata */
483
+ [key: string]: any;
484
+ }
485
+ /**
486
+ * Job for workflow/step execution
487
+ */
488
+ export interface Job<T = any> {
489
+ /** Unique job ID */
490
+ id: string;
491
+ /** Associated workflow ID */
492
+ workflowId: string;
493
+ /** Optional step ID (if job is for single step) */
494
+ stepId?: string;
495
+ /** Job type (workflow, step, etc.) */
496
+ type: 'workflow' | 'step';
497
+ /** Job payload/input data */
498
+ payload: T;
499
+ /** Current status */
500
+ status: JobStatus;
501
+ /** Priority level */
502
+ priority: JobPriority;
503
+ /** Number of execution attempts */
504
+ attempts: number;
505
+ /** Maximum retry attempts allowed */
506
+ maxRetries: number;
507
+ /** Backoff delay for retries (ms) */
508
+ retryDelayMs?: number;
509
+ /** Errors from previous attempts */
510
+ errors: Error[];
511
+ /** Job result (if completed) */
512
+ result?: any;
513
+ /** Job metadata */
514
+ metadata: JobMetadata;
515
+ /** Timeout for job execution (ms) */
516
+ timeoutMs?: number;
517
+ /** Jobs that must complete before this one */
518
+ dependencies?: string[];
519
+ }
520
+ /**
521
+ * Queue statistics
522
+ */
523
+ export interface QueueStats {
524
+ /** Total jobs in queue */
525
+ total: number;
526
+ /** Pending jobs */
527
+ pending: number;
528
+ /** Running jobs */
529
+ running: number;
530
+ /** Completed jobs */
531
+ completed: number;
532
+ /** Failed jobs */
533
+ failed: number;
534
+ /** Jobs awaiting retry */
535
+ retrying: number;
536
+ /** Average wait time (ms) */
537
+ avgWaitTimeMs: number;
538
+ /** Average execution time (ms) */
539
+ avgExecutionTimeMs: number;
540
+ }
541
+ /**
542
+ * Queue configuration
543
+ */
544
+ export interface QueueConfig {
545
+ /** Maximum queue size (0 = unlimited) */
546
+ maxSize?: number;
547
+ /** Maximum concurrent jobs */
548
+ maxConcurrent?: number;
549
+ /** Enable job persistence */
550
+ persistent?: boolean;
551
+ /** Job retention time (ms) */
552
+ retentionMs?: number;
553
+ }
554
+ /**
555
+ * Job queue interface
556
+ */
557
+ export interface JobQueue<T = any> {
558
+ /**
559
+ * Add job to queue
560
+ *
561
+ * @param job - Job to enqueue
562
+ * @returns Promise resolving when job is queued
563
+ */
564
+ enqueue(job: Job<T>): Promise<void>;
565
+ /**
566
+ * Remove and return highest priority pending job
567
+ *
568
+ * @returns Next job or null if queue is empty
569
+ */
570
+ dequeue(): Promise<Job<T> | null>;
571
+ /**
572
+ * Peek at next job without removing it
573
+ *
574
+ * @returns Next job or null if queue is empty
575
+ */
576
+ peek(): Promise<Job<T> | null>;
577
+ /**
578
+ * Get job by ID
579
+ *
580
+ * @param jobId - Job ID
581
+ * @returns Job or null if not found
582
+ */
583
+ getJob(jobId: string): Promise<Job<T> | null>;
584
+ /**
585
+ * Mark job as completed successfully
586
+ *
587
+ * @param jobId - Job ID
588
+ * @param result - Job result
589
+ */
590
+ markCompleted(jobId: string, result?: any): Promise<void>;
591
+ /**
592
+ * Mark job as failed
593
+ *
594
+ * @param jobId - Job ID
595
+ * @param error - Error that caused failure
596
+ */
597
+ markFailed(jobId: string, error: Error): Promise<void>;
598
+ /**
599
+ * Mark job as retrying
600
+ *
601
+ * @param jobId - Job ID
602
+ */
603
+ markRetrying(jobId: string): Promise<void>;
604
+ /**
605
+ * Remove job from queue
606
+ *
607
+ * @param jobId - Job ID
608
+ * @returns True if job was removed
609
+ */
610
+ remove(jobId: string): Promise<boolean>;
611
+ /**
612
+ * Get all jobs matching filter
613
+ *
614
+ * @param filter - Filter function
615
+ * @returns Matching jobs
616
+ */
617
+ find(filter: (job: Job<T>) => boolean): Promise<Job<T>[]>;
618
+ /**
619
+ * Get queue statistics
620
+ *
621
+ * @returns Queue stats
622
+ */
623
+ getStats(): Promise<QueueStats>;
624
+ /**
625
+ * Clear all jobs from queue
626
+ */
627
+ clear(): Promise<void>;
628
+ /**
629
+ * Get queue size
630
+ *
631
+ * @returns Number of jobs in queue
632
+ */
633
+ size(): Promise<number>;
634
+ /**
635
+ * Check if queue is empty
636
+ *
637
+ * @returns True if queue has no jobs
638
+ */
639
+ isEmpty(): Promise<boolean>;
640
+ }
641
+ /**
642
+ * Parsed workflow ready for execution
643
+ */
644
+ export interface ParsedWorkflow {
645
+ /** Workflow metadata */
646
+ name?: string;
647
+ description?: string;
648
+ version: string;
649
+ kind: string;
650
+ tags?: string[];
651
+ owner?: string;
652
+ /** Metadata object (if provided separately) */
653
+ metadata?: {
654
+ name?: string;
655
+ description?: string;
656
+ tags?: string[];
657
+ owner?: string;
658
+ version?: string;
659
+ createdAt?: string;
660
+ updatedAt?: string;
661
+ };
662
+ /** Annotations for AI and UI hints */
663
+ annotations?: {
664
+ 'ai.intent'?: string;
665
+ 'ui.group'?: string;
666
+ 'ui.icon'?: string;
667
+ [key: string]: any;
668
+ };
669
+ /** Workflow steps */
670
+ steps: ParsedStep[];
671
+ /** Global workflow inputs */
672
+ inputs?: Record<string, any>;
673
+ /** Global environment variables */
674
+ context?: Record<string, any>;
675
+ /** Secret references */
676
+ secrets?: {
677
+ vault?: string;
678
+ refs?: Record<string, string>;
679
+ };
680
+ /** Trigger configuration */
681
+ triggers?: Array<{
682
+ type: string;
683
+ [key: string]: any;
684
+ }>;
685
+ /** Defaults */
686
+ defaults?: {
687
+ retry?: {
688
+ max: number;
689
+ backoff?: 'linear' | 'exponential';
690
+ delay?: number;
691
+ };
692
+ timeout?: string;
693
+ adapter?: string;
694
+ };
695
+ /** Policies */
696
+ policies?: {
697
+ failure?: 'stop' | 'continue' | 'isolate';
698
+ concurrency?: number;
699
+ sandbox?: 'none' | 'basic' | 'strict';
700
+ };
701
+ /** Permissions */
702
+ permissions?: any;
703
+ /** Resources */
704
+ resources?: any;
705
+ /** Outputs */
706
+ outputs?: Record<string, string>;
707
+ }
708
+ /**
709
+ * Parsed internal step representation
710
+ */
711
+ export interface ParsedStep {
712
+ /** Unique step identifier */
713
+ id: string;
714
+ /** Adapter type (http, shell, cli, plugin, etc.) */
715
+ adapter: string;
716
+ /** Full action name (e.g., 'http.request.get') */
717
+ action: string;
718
+ /** Input parameters for the step */
719
+ input: Record<string, any>;
720
+ /** Step dependencies (other step IDs) */
721
+ needs: string[];
722
+ /** Optional name */
723
+ name?: string;
724
+ /** Conditional execution expression */
725
+ when?: string;
726
+ /** Continue workflow on failure */
727
+ continueOnError: boolean;
728
+ /** Retry policy configuration */
729
+ retry?: {
730
+ /** Maximum number of retry attempts */
731
+ max: number;
732
+ /** Backoff strategy (linear or exponential) */
733
+ backoff?: 'linear' | 'exponential';
734
+ /** Delay between retries in milliseconds */
735
+ delay?: number;
736
+ /** Store the current retry count */
737
+ count?: number;
738
+ };
739
+ /** Timeout string (e.g., '30s', '5m') */
740
+ timeout?: string;
741
+ /** Environment variables for this step */
742
+ env?: Record<string, string>;
743
+ /** Output mappings */
744
+ outputs?: Record<string, string>;
745
+ }
746
+ /**
747
+ * Workflow execution result
748
+ */
749
+ export interface WorkflowResult {
750
+ /** Workflow name */
751
+ workflowName: string;
752
+ /** Overall status */
753
+ status: 'success' | 'failure' | 'partial' | 'timeout';
754
+ /** All step results */
755
+ stepResults: Map<string, StepResult>;
756
+ /** Total execution duration (ms) */
757
+ duration: number;
758
+ /** Start timestamp */
759
+ startedAt: Date;
760
+ /** End timestamp */
761
+ completedAt: Date;
762
+ /** Error if workflow failed */
763
+ error?: Error;
764
+ /** Execution metadata */
765
+ metadata: {
766
+ totalSteps: number;
767
+ successfulSteps: number;
768
+ failedSteps: number;
769
+ skippedSteps: number;
770
+ phases: number;
771
+ };
772
+ }
773
+ /**
774
+ * Workflow execution options
775
+ */
776
+ export interface ExecutionOptions {
777
+ /** Workflow timeout (ms) */
778
+ timeout?: number;
779
+ /** Initial environment variables */
780
+ env?: Record<string, any>;
781
+ /** Workflow inputs */
782
+ inputs?: Record<string, any>;
783
+ /** Resolved secrets */
784
+ secrets?: Record<string, any>;
785
+ /** Additional context */
786
+ context?: Record<string, any>;
787
+ /** Continue on step failure */
788
+ continueOnError?: boolean;
789
+ /** Trigger source (who/what triggered this execution) */
790
+ triggeredBy?: string;
791
+ }
792
+ /**
793
+ * Runtime context for variable resolution
794
+ */
795
+ export interface ResolutionContext {
796
+ /** Global environment variables */
797
+ env: Record<string, any>;
798
+ /** Step outputs (stepId -> output data) */
799
+ steps: Map<string, any>;
800
+ /** Workflow metadata */
801
+ workflow: {
802
+ id: string;
803
+ name: string;
804
+ version?: string;
805
+ description?: string;
806
+ tags?: string[];
807
+ owner?: string;
808
+ };
809
+ /** Current run information */
810
+ run: {
811
+ id: string;
812
+ timestamp: Date;
813
+ attempt: number;
814
+ startedAt?: Date;
815
+ triggeredBy?: string;
816
+ };
817
+ /** Workflow inputs (runtime parameters) */
818
+ inputs?: Record<string, any>;
819
+ /** Resolved secrets (name -> value) */
820
+ secrets?: Record<string, any>;
821
+ /** Additional runtime context */
822
+ context?: Record<string, any>;
823
+ /** Workflow metadata (extended) */
824
+ metadata?: {
825
+ createdAt?: string;
826
+ updatedAt?: string;
827
+ annotations?: Record<string, any>;
828
+ };
829
+ /** Telemetry data (future) */
830
+ telemetry?: Record<string, any>;
831
+ /** Resource information (future) */
832
+ resources?: Record<string, any>;
833
+ /** Compliance metadata (future) */
834
+ compliance?: Record<string, any>;
835
+ }
836
+ /**
837
+ * Step execution result
838
+ */
839
+ export interface StepResult {
840
+ /** Step ID */
841
+ stepId: string;
842
+ /** Execution status */
843
+ status: 'success' | 'failure' | 'skipped' | 'timeout';
844
+ /** Step output data */
845
+ output: any;
846
+ /** Error if failed */
847
+ error?: Error;
848
+ /** Execution duration (ms) */
849
+ duration: number;
850
+ /** Number of retry attempts */
851
+ attempts: number;
852
+ /** Start timestamp */
853
+ startedAt: Date;
854
+ /** End timestamp */
855
+ completedAt: Date;
856
+ }
857
+ /**
858
+ * Adapter interface for step execution
859
+ */
860
+ export interface StepAdapter {
861
+ /** Adapter name */
862
+ name: string;
863
+ /**
864
+ * Execute step with the adapter
865
+ *
866
+ * @param action - Full action name (e.g., 'http.request.get')
867
+ * @param input - Resolved input parameters
868
+ * @param context - Execution context
869
+ * @returns Adapter output
870
+ */
871
+ execute(action: string, input: Record<string, any>, context: any): Promise<any>;
872
+ }
873
+ /**
874
+ * Step execution context for drivers
875
+ */
876
+ export interface DriverContext {
877
+ /** Current step ID */
878
+ stepId: string;
879
+ /** Workflow execution ID */
880
+ executionId: string;
881
+ /** Workflow name */
882
+ workflowName: string;
883
+ /** Logger function */
884
+ log: (message: string, level?: 'info' | 'warn' | 'error' | 'debug') => void;
885
+ /** Abort signal for cancellation */
886
+ signal?: AbortSignal;
887
+ /** Step timeout in milliseconds */
888
+ timeout?: number;
889
+ /** Working directory */
890
+ cwd?: string;
891
+ /** Environment variables */
892
+ env?: Record<string, string>;
893
+ /** Secrets access */
894
+ secrets?: Record<string, string>;
895
+ /** Temporary directory */
896
+ tempDir?: string;
897
+ /** Previous step outputs */
898
+ stepOutputs?: Record<string, any>;
899
+ /** Workflow inputs */
900
+ inputs?: Record<string, any>;
901
+ /** Workflow context */
902
+ workflowContext?: Record<string, any>;
903
+ }
904
+ /**
905
+ * Step definition for driver execution
906
+ */
907
+ export interface DriverStep {
908
+ /** Step ID */
909
+ id: string;
910
+ /** Step name (optional) */
911
+ name?: string;
912
+ /** Action to execute (e.g., 'http.request.get', 'cli.run') */
913
+ uses: string;
914
+ /** Input parameters */
915
+ with?: Record<string, any>;
916
+ /** Conditional execution */
917
+ when?: string;
918
+ /** Environment variables */
919
+ env?: Record<string, string>;
920
+ /** Retry configuration */
921
+ retry?: {
922
+ max: number;
923
+ backoff?: 'linear' | 'exponential';
924
+ delay?: number;
925
+ };
926
+ /** Timeout */
927
+ timeout?: string;
928
+ /** Continue on error */
929
+ continueOnError?: boolean;
930
+ }
931
+ /**
932
+ * Base execution driver interface
933
+ */
934
+ export interface ExecutionDriver {
935
+ /** Driver type identifier */
936
+ readonly type: string;
937
+ /** Driver name */
938
+ readonly name: string;
939
+ /** Driver version */
940
+ readonly version: string;
941
+ /** Driver description */
942
+ readonly description?: string;
943
+ /**
944
+ * Check if this driver can handle a step
945
+ *
946
+ * @param step - Step to check
947
+ * @returns True if driver can handle this step
948
+ */
949
+ canHandle(step: DriverStep): boolean;
950
+ /**
951
+ * Execute a step
952
+ *
953
+ * @param step - Step to execute
954
+ * @param context - Execution context
955
+ * @returns Execution result
956
+ */
957
+ execute(step: DriverStep, context: DriverContext): Promise<AdapterResult>;
958
+ /**
959
+ * Optional: Initialize driver
960
+ */
961
+ initialize?(): Promise<void>;
962
+ /**
963
+ * Optional: Cleanup driver
964
+ */
965
+ cleanup?(): Promise<void>;
966
+ }
967
+ /**
968
+ * Execution phase (group of steps that can run in parallel)
969
+ */
970
+ export interface ExecutionPhase {
971
+ /** Phase number (0-indexed) */
972
+ readonly phase: number;
973
+ /** Nodes that can execute in parallel */
974
+ readonly nodes: readonly ExecutionNode[];
975
+ /** Combined phase timeout (max of all node timeouts) */
976
+ readonly timeout?: number;
977
+ }
978
+ /**
979
+ * Complete execution plan for a workflow.
980
+ * This is a blueprint for execution - it contains NO execution state.
981
+ */
982
+ export interface ExecutionPlan {
983
+ /** Ordered phases of execution */
984
+ readonly phases: readonly ExecutionPhase[];
985
+ /** The validated dependency graph */
986
+ readonly graph: DependencyGraph;
987
+ /** Total number of steps */
988
+ readonly totalSteps: number;
989
+ /** Maximum parallelism (largest phase size) */
990
+ readonly maxParallelism: number;
991
+ /** Critical path length (minimum phases needed) */
992
+ readonly criticalPathLength: number;
993
+ /** Topological sort result */
994
+ readonly sortResult: TopologicalSortResult;
995
+ }
996
+ /**
997
+ * Represents a directed edge in the dependency graph
998
+ */
999
+ export interface DependencyEdge {
1000
+ /** The step that depends on another */
1001
+ readonly from: string;
1002
+ /** The step that must complete first */
1003
+ readonly to: string;
1004
+ }
1005
+ /**
1006
+ * The complete dependency graph structure
1007
+ */
1008
+ export interface DependencyGraph {
1009
+ /** All execution nodes indexed by stepId */
1010
+ readonly nodes: ReadonlyMap<string, ExecutionNode>;
1011
+ /** All dependency edges */
1012
+ readonly edges: readonly DependencyEdge[];
1013
+ /** Adjacency list: stepId → list of dependencies */
1014
+ readonly adjacencyList: ReadonlyMap<string, readonly string[]>;
1015
+ /** Reverse adjacency list: stepId → list of dependents */
1016
+ readonly reverseDependencies: ReadonlyMap<string, readonly string[]>;
1017
+ }
1018
+ /**
1019
+ * Result of cycle detection
1020
+ */
1021
+ export interface CycleDetectionResult {
1022
+ /** Whether a cycle was detected */
1023
+ readonly hasCycle: boolean;
1024
+ /** The cycle path if one was found (e.g., ['A', 'B', 'C', 'A']) */
1025
+ readonly cyclePath?: readonly string[];
1026
+ }
1027
+ /**
1028
+ * Node visit state for DFS traversal
1029
+ */
1030
+ export declare enum VisitState {
1031
+ /** Not yet visited */
1032
+ WHITE = "white",
1033
+ /** Currently being visited (in DFS stack) */
1034
+ GRAY = "gray",
1035
+ /** Fully visited, all descendants explored */
1036
+ BLACK = "black"
1037
+ }
1038
+ /**
1039
+ * Result of topological sorting
1040
+ */
1041
+ export interface TopologicalSortResult {
1042
+ /**
1043
+ * Execution phases - each inner array is a phase,
1044
+ * steps in the same phase can run in parallel
1045
+ */
1046
+ readonly phases: readonly (readonly string[])[];
1047
+ /**
1048
+ * Total number of phases
1049
+ */
1050
+ readonly phaseCount: number;
1051
+ /**
1052
+ * Map of stepId → phase number (0-indexed)
1053
+ */
1054
+ readonly stepPhases: ReadonlyMap<string, number>;
1055
+ }
1056
+ /**
1057
+ * Execution state for a single step
1058
+ */
1059
+ export type ExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
1060
+ /**
1061
+ * Pure data model for an execution node in the DAG.
1062
+ * Contains only data - no behavior, no methods (except maybe toString for debugging).
1063
+ */
1064
+ export interface ExecutionNode {
1065
+ /**
1066
+ * Unique identifier for this step (from workflow schema)
1067
+ */
1068
+ readonly stepId: string;
1069
+ /**
1070
+ * Step IDs this step depends on (from `needs` field)
1071
+ */
1072
+ readonly dependencies: readonly string[];
1073
+ /**
1074
+ * The resolved adapter instance that will execute this step
1075
+ * This is set during execution planning when adapters are resolved
1076
+ */
1077
+ readonly adapter: Adapter | null;
1078
+ /**
1079
+ * Uses clause - adapter reference from workflow schema (e.g., "fs.read")
1080
+ */
1081
+ readonly uses: string;
1082
+ /**
1083
+ * Input parameters for the adapter
1084
+ */
1085
+ readonly input: Record<string, unknown>;
1086
+ /**
1087
+ * Optional conditional expression
1088
+ * If present and evaluates to false, this step is skipped
1089
+ */
1090
+ readonly condition?: string;
1091
+ /**
1092
+ * Execution metadata
1093
+ */
1094
+ readonly metadata: ExecutionNodeMetadata;
1095
+ }
1096
+ /**
1097
+ * Metadata about how a step should be executed.
1098
+ * This is data ABOUT execution, not execution itself.
1099
+ */
1100
+ export interface ExecutionNodeMetadata {
1101
+ /**
1102
+ * Maximum number of retry attempts (default: 0)
1103
+ */
1104
+ readonly maxRetries: number;
1105
+ /**
1106
+ * Timeout in milliseconds
1107
+ * If not specified, inherits from workflow-level timeout
1108
+ */
1109
+ readonly timeout?: number;
1110
+ /**
1111
+ * Whether this step runs conditionally
1112
+ */
1113
+ readonly hasCondition: boolean;
1114
+ /**
1115
+ * Phase number (from topological sort)
1116
+ * Steps in the same phase can run in parallel
1117
+ */
1118
+ phase?: number;
1119
+ }
1120
+ /**
1121
+ * Result of critical path analysis
1122
+ */
1123
+ export interface CriticalPathResult {
1124
+ /** Steps on the critical path (zero slack) */
1125
+ readonly criticalPath: readonly string[];
1126
+ /** Estimated total workflow duration */
1127
+ readonly workflowDuration: number;
1128
+ /** Earliest start time for each step */
1129
+ readonly earliestStart: ReadonlyMap<string, number>;
1130
+ /** Latest start time for each step without delaying workflow */
1131
+ readonly latestStart: ReadonlyMap<string, number>;
1132
+ /** Slack (float) for each step - how much it can be delayed */
1133
+ readonly slack: ReadonlyMap<string, number>;
1134
+ }
1135
+ /**
1136
+ * Execution context configuration
1137
+ */
1138
+ export interface ContextConfig {
1139
+ /** Execution ID */
1140
+ executionId: string;
1141
+ /** Workflow ID */
1142
+ workflowId: string;
1143
+ /** Workflow name */
1144
+ workflowName: string;
1145
+ /** Workflow version */
1146
+ version?: string;
1147
+ /** Workflow description */
1148
+ description?: string;
1149
+ /** Workflow tags */
1150
+ tags?: string[];
1151
+ /** Workflow owner */
1152
+ owner?: string;
1153
+ /** Runtime inputs */
1154
+ inputs?: Record<string, any>;
1155
+ /** Resolved secrets */
1156
+ secrets?: Record<string, any>;
1157
+ /** Environment variables */
1158
+ env?: Record<string, any>;
1159
+ /** Workflow metadata */
1160
+ metadata?: {
1161
+ createdAt?: string;
1162
+ updatedAt?: string;
1163
+ annotations?: Record<string, any>;
1164
+ };
1165
+ /** Additional context */
1166
+ context?: Record<string, any>;
1167
+ /** Triggered by (user, system, schedule) */
1168
+ triggeredBy?: string;
1169
+ }
1170
+ /**
1171
+ * Engine runtime context
1172
+ *
1173
+ * Provides access to engine internals during execution.
1174
+ * This is the "global" context available to all components.
1175
+ *
1176
+ * Different from WorkflowHookContext or StepHookContext which are
1177
+ * specific to individual workflow/step executions.
1178
+ *
1179
+ * @example
1180
+ * ```ts
1181
+ * // Inside a custom adapter
1182
+ * async execute(step, context, engineContext) {
1183
+ * // Access engine components
1184
+ * engineContext.eventBus.emit(event);
1185
+ * const otherAdapter = engineContext.adapterRegistry.get('http');
1186
+ * }
1187
+ * ```
1188
+ */
1189
+ export interface EngineContext {
1190
+ /**
1191
+ * Engine configuration
1192
+ */
1193
+ config: OrbytEngineConfig;
1194
+ /**
1195
+ * Event bus for emitting and listening to engine events
1196
+ */
1197
+ eventBus: EventBus;
1198
+ /**
1199
+ * Hook manager for lifecycle hooks
1200
+ */
1201
+ hookManager: HookManager;
1202
+ /**
1203
+ * Adapter registry - all registered adapters
1204
+ */
1205
+ adapterRegistry: AdapterRegistry;
1206
+ /**
1207
+ * Execution engine instance
1208
+ */
1209
+ executionEngine: ExecutionEngine;
1210
+ /**
1211
+ * Step executor instance
1212
+ */
1213
+ stepExecutor: StepExecutor;
1214
+ /**
1215
+ * Workflow executor instance
1216
+ */
1217
+ workflowExecutor: WorkflowExecutor;
1218
+ /**
1219
+ * Working directory for this engine instance
1220
+ */
1221
+ workingDirectory: string;
1222
+ /**
1223
+ * Engine start time
1224
+ */
1225
+ startedAt: Date;
1226
+ /**
1227
+ * Custom metadata
1228
+ */
1229
+ metadata?: Record<string, any>;
1230
+ }
1231
+ /**
1232
+ * Logging level for engine output
1233
+ */
1234
+ export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
1235
+ /**
1236
+ * Execution mode
1237
+ */
1238
+ export type ExecutionMode = 'local' | 'distributed' | 'dry-run';
1239
+ /**
1240
+ * Engine configuration options
1241
+ *
1242
+ * Provides a clean, user-friendly API for configuring OrbytEngine.
1243
+ * All options are optional with sensible defaults.
1244
+ *
1245
+ * @example
1246
+ * ```ts
1247
+ * const config: OrbytEngineConfig = {
1248
+ * maxConcurrentWorkflows: 5,
1249
+ * logLevel: 'info',
1250
+ * enableScheduler: true,
1251
+ * adapters: [httpAdapter, shellAdapter],
1252
+ * hooks: [loggingHook, metricsHook]
1253
+ * };
1254
+ *
1255
+ * const engine = new OrbytEngine(config);
1256
+ * ```
1257
+ */
1258
+ export interface OrbytEngineConfig {
1259
+ /**
1260
+ * Maximum number of workflows that can run concurrently
1261
+ * @default 10
1262
+ */
1263
+ maxConcurrentWorkflows?: number;
1264
+ /**
1265
+ * Maximum number of steps that can execute concurrently within a workflow
1266
+ * @default 10
1267
+ */
1268
+ maxConcurrentSteps?: number;
1269
+ /**
1270
+ * Default timeout for workflows (milliseconds)
1271
+ * @default 300000 (5 minutes)
1272
+ */
1273
+ defaultTimeout?: number;
1274
+ /**
1275
+ * Execution mode
1276
+ * - 'local': Execute locally with full features
1277
+ * - 'distributed': Execute in distributed mode (future)
1278
+ * - 'dry-run': Validate and plan but don't execute
1279
+ * @default 'local'
1280
+ */
1281
+ mode?: ExecutionMode;
1282
+ /**
1283
+ * Enable the internal scheduler for cron/scheduled workflows
1284
+ * @default true
1285
+ */
1286
+ enableScheduler?: boolean;
1287
+ /**
1288
+ * Custom job queue implementation
1289
+ * If not provided, uses InMemoryQueue
1290
+ */
1291
+ queue?: JobQueue;
1292
+ /**
1293
+ * Global retry policy for all steps
1294
+ * Can be overridden per-step in workflow definition
1295
+ */
1296
+ retryPolicy?: RetryPolicy;
1297
+ /**
1298
+ * Global timeout manager
1299
+ */
1300
+ timeoutManager?: TimeoutManager;
1301
+ /**
1302
+ * Adapters to register with the engine
1303
+ * These will be available for use in workflows
1304
+ */
1305
+ adapters?: Adapter[];
1306
+ /**
1307
+ * Lifecycle hooks for extending engine behavior
1308
+ * Hooks are called at key execution moments
1309
+ */
1310
+ hooks?: LifecycleHook[];
1311
+ /**
1312
+ * Logging level
1313
+ * @default 'info'
1314
+ */
1315
+ logLevel?: LogLevel;
1316
+ /**
1317
+ * Enable verbose output (equivalent to logLevel='debug')
1318
+ * @default false
1319
+ */
1320
+ verbose?: boolean;
1321
+ /**
1322
+ * Enable metrics collection
1323
+ * @default true
1324
+ */
1325
+ enableMetrics?: boolean;
1326
+ /**
1327
+ * Enable event emission
1328
+ * @default true
1329
+ */
1330
+ enableEvents?: boolean;
1331
+ /**
1332
+ * Directory for storing execution state and logs
1333
+ * @default '.orbyt/state'
1334
+ */
1335
+ stateDir?: string;
1336
+ /**
1337
+ * Directory for storing execution logs
1338
+ * @default '.orbyt/logs'
1339
+ */
1340
+ logDir?: string;
1341
+ /**
1342
+ * Sandbox mode for step execution
1343
+ * - 'none': No sandboxing
1344
+ * - 'basic': Basic restrictions
1345
+ * - 'strict': Strict isolation (future)
1346
+ * @default 'basic'
1347
+ */
1348
+ sandboxMode?: 'none' | 'basic' | 'strict';
1349
+ /**
1350
+ * Working directory for workflow execution
1351
+ * @default process.cwd()
1352
+ */
1353
+ workingDirectory?: string;
1354
+ /**
1355
+ * Enable experimental features
1356
+ * @default false
1357
+ */
1358
+ experimental?: boolean;
1359
+ /**
1360
+ * Custom metadata to attach to all executions
1361
+ */
1362
+ metadata?: Record<string, any>;
1363
+ }
1364
+ /**
1365
+ * Explanation Types
1366
+ *
1367
+ * Type definitions for workflow execution explanations.
1368
+ * These structures represent a complete analysis of what the engine will do.
1369
+ *
1370
+ * @module explanation
1371
+ */
1372
+ /**
1373
+ * Explained step - A single step in the execution plan with all resolved configuration
1374
+ */
1375
+ export interface ExplainedStep {
1376
+ /** Step ID */
1377
+ id: string;
1378
+ /** Step name (human-readable) */
1379
+ name?: string;
1380
+ /** Adapter being used (e.g., "shell", "http", "mediaproc") */
1381
+ adapter: string;
1382
+ /** Action to execute (e.g., "shell.exec", "http.request") */
1383
+ uses: string;
1384
+ /** Dependencies - which steps must complete before this one */
1385
+ needs: string[];
1386
+ /** Execution condition (if any) */
1387
+ when?: string;
1388
+ /** Timeout configuration */
1389
+ timeout?: string | number;
1390
+ /** Retry configuration */
1391
+ retry?: {
1392
+ max?: number;
1393
+ backoff?: 'linear' | 'exponential';
1394
+ delay?: number;
1395
+ count?: number;
1396
+ };
1397
+ /** Whether to continue workflow if this step fails */
1398
+ continueOnError?: boolean;
1399
+ /** Input parameters */
1400
+ with?: Record<string, any>;
1401
+ /** Environment variables */
1402
+ env?: Record<string, any>;
1403
+ /** Expected outputs */
1404
+ outputs?: Record<string, any>;
1405
+ /** Secrets used by this step */
1406
+ secretsUsed?: string[];
1407
+ /** Workflow inputs referenced in this step */
1408
+ inputsReferenced?: string[];
1409
+ }
1410
+ /**
1411
+ * Execution explanation - Complete plan of what the engine will do
1412
+ */
1413
+ export interface ExecutionExplanation {
1414
+ /** Workflow name */
1415
+ workflowName?: string;
1416
+ /** Workflow description */
1417
+ description?: string;
1418
+ /** Workflow version */
1419
+ version: string;
1420
+ /** Workflow kind */
1421
+ kind: string;
1422
+ /** Total number of steps */
1423
+ stepCount: number;
1424
+ /** Execution strategy (sequential or parallel) */
1425
+ executionStrategy: 'sequential' | 'parallel' | 'mixed';
1426
+ /** All steps in execution order */
1427
+ steps: ExplainedStep[];
1428
+ /** Whether the workflow has circular dependencies */
1429
+ hasCycles: boolean;
1430
+ /** Cycle details (if any) */
1431
+ cycles?: string[][];
1432
+ /** Total estimated phases (for parallel execution) */
1433
+ phases?: number;
1434
+ /** Dependency graph in adjacency list format */
1435
+ dependencyGraph?: Record<string, string[]>;
1436
+ /** Workflow inputs (parameters the workflow accepts) */
1437
+ inputs?: Record<string, any>;
1438
+ /** Secrets being used (keys only, no values) */
1439
+ secrets?: {
1440
+ vault?: string;
1441
+ keys?: string[];
1442
+ };
1443
+ /** Context variables (environment) */
1444
+ context?: Record<string, any>;
1445
+ /** Workflow outputs */
1446
+ outputs?: Record<string, string>;
1447
+ /** Default configurations */
1448
+ defaults?: {
1449
+ timeout?: string;
1450
+ adapter?: string;
1451
+ };
1452
+ /** Execution policies */
1453
+ policies?: {
1454
+ failure?: 'stop' | 'continue' | 'isolate';
1455
+ concurrency?: number;
1456
+ sandbox?: 'none' | 'basic' | 'strict';
1457
+ };
1458
+ /** Unique adapters used in this workflow */
1459
+ adaptersUsed: string[];
1460
+ /** Adapter actions breakdown (e.g., { "shell": ["exec"], "http": ["request"] }) */
1461
+ adapterActions?: Record<string, string[]>;
1462
+ /** Required workflow inputs */
1463
+ requiredInputs?: string[];
1464
+ /** Optional workflow inputs with defaults */
1465
+ optionalInputs?: Record<string, any>;
1466
+ /** Annotations (AI/UI hints) */
1467
+ annotations?: Record<string, any>;
1468
+ /** Tags */
1469
+ tags?: string[];
1470
+ /** Owner */
1471
+ owner?: string;
1472
+ /** Metadata about workflow complexity */
1473
+ complexity?: {
1474
+ totalSteps: number;
1475
+ maxDepth: number;
1476
+ parallelizableSteps: number;
1477
+ sequentialSteps: number;
1478
+ };
1479
+ /** Data flow prediction - how data moves through the workflow */
1480
+ dataFlow?: DataFlowPrediction[];
1481
+ /** Conditional path analysis - all possible execution paths */
1482
+ conditionalPaths?: ConditionalPathAnalysis;
1483
+ /** Execution time estimation - predicted duration */
1484
+ timeEstimation?: ExecutionTimeEstimation;
1485
+ }
1486
+ /**
1487
+ * Data flow prediction for a step
1488
+ * Shows what data flows in and out of each step
1489
+ */
1490
+ export interface DataFlowPrediction {
1491
+ /** Step ID */
1492
+ step: string;
1493
+ /** Step name */
1494
+ stepName?: string;
1495
+ /** Input data sources */
1496
+ inputs: {
1497
+ /** Source of the data */
1498
+ source: 'workflow.inputs' | 'step.output' | 'context' | 'secrets' | 'env' | 'static';
1499
+ /** Variable/field key */
1500
+ key: string;
1501
+ /** Source step ID (if from step.output) */
1502
+ sourceStep?: string;
1503
+ /** Inferred type */
1504
+ type?: string;
1505
+ /** Sample value (for static/default values) */
1506
+ example?: any;
1507
+ }[];
1508
+ /** Output data */
1509
+ outputs: {
1510
+ /** Output key */
1511
+ key: string;
1512
+ /** Inferred type */
1513
+ type?: string;
1514
+ /** Steps that consume this output */
1515
+ usedBy: string[];
1516
+ }[];
1517
+ /** Whether this step has unresolved dependencies */
1518
+ hasUnresolvedDependencies: boolean;
1519
+ }
1520
+ /**
1521
+ * Conditional path analysis
1522
+ * Analyzes all possible execution paths based on conditions
1523
+ */
1524
+ export interface ConditionalPathAnalysis {
1525
+ /** Total number of possible paths */
1526
+ totalPaths: number;
1527
+ /** All execution paths */
1528
+ paths: {
1529
+ /** Path description */
1530
+ description: string;
1531
+ /** Conditions that must be true for this path */
1532
+ conditions: string[];
1533
+ /** Steps executed in this path */
1534
+ stepsExecuted: string[];
1535
+ /** Steps skipped in this path */
1536
+ stepsSkipped: string[];
1537
+ /** Likelihood of this path */
1538
+ likelihood: 'always' | 'likely' | 'possible' | 'unlikely' | 'never';
1539
+ }[];
1540
+ /** Steps with conditions */
1541
+ conditionalSteps: {
1542
+ step: string;
1543
+ condition: string;
1544
+ canBeSkipped: boolean;
1545
+ }[];
1546
+ /** Steps that are never reachable */
1547
+ unreachableSteps: string[];
1548
+ /** Steps that always execute */
1549
+ alwaysExecutes: string[];
1550
+ }
1551
+ /**
1552
+ * Execution time estimation
1553
+ * Predicts how long the workflow will take
1554
+ */
1555
+ export interface ExecutionTimeEstimation {
1556
+ /** Total estimated time */
1557
+ total: {
1558
+ /** Best case scenario (ms) */
1559
+ min: number;
1560
+ /** Average expected time (ms) */
1561
+ avg: number;
1562
+ /** Worst case scenario (ms) */
1563
+ max: number;
1564
+ };
1565
+ /** Estimated time by execution phase */
1566
+ byPhase: {
1567
+ /** Phase number */
1568
+ phase: number;
1569
+ /** Steps in this phase */
1570
+ steps: string[];
1571
+ /** Duration estimate (ms) */
1572
+ duration: {
1573
+ min: number;
1574
+ avg: number;
1575
+ max: number;
1576
+ };
1577
+ }[];
1578
+ /** Critical path - longest dependency chain */
1579
+ criticalPath: {
1580
+ /** Steps in the critical path */
1581
+ steps: string[];
1582
+ /** Total duration of critical path (ms) */
1583
+ duration: number;
1584
+ };
1585
+ /** Performance bottlenecks */
1586
+ bottlenecks: {
1587
+ /** Step ID */
1588
+ step: string;
1589
+ /** Reason it's a bottleneck */
1590
+ reason: string;
1591
+ /** Estimated impact if optimized (ms saved) */
1592
+ impact: number;
1593
+ }[];
1594
+ /** Time estimates per step */
1595
+ byStep: {
1596
+ step: string;
1597
+ min: number;
1598
+ avg: number;
1599
+ max: number;
1600
+ /** Whether this step is on the critical path */
1601
+ onCriticalPath: boolean;
1602
+ }[];
1603
+ }
1604
+ /**
1605
+ * Explanation event - Logged to EngineLogger
1606
+ */
1607
+ export interface ExplanationEvent {
1608
+ /** Event type */
1609
+ type: 'explanation';
1610
+ /** Explanation timestamp */
1611
+ timestamp: Date;
1612
+ /** Full explanation */
1613
+ explanation: ExecutionExplanation;
1614
+ }
1615
+ /**
1616
+ * Known workflow intents
1617
+ */
1618
+ export type WorkflowIntent = 'data-pipeline' | 'deployment' | 'testing' | 'monitoring' | 'notification' | 'integration' | 'automation' | 'orchestration' | 'unknown';
1619
+ /**
1620
+ * Intent classification confidence
1621
+ */
1622
+ export type IntentConfidence = 'high' | 'medium' | 'low';
1623
+ /**
1624
+ * Intent classification result
1625
+ */
1626
+ export interface ClassifiedIntent {
1627
+ /** Primary intent */
1628
+ intent: WorkflowIntent;
1629
+ /** Classification confidence */
1630
+ confidence: IntentConfidence;
1631
+ /** Secondary intents (if any) */
1632
+ secondaryIntents?: WorkflowIntent[];
1633
+ /** Reasoning (for debugging) */
1634
+ reasoning: string;
1635
+ /** Detected patterns */
1636
+ patterns: string[];
1637
+ }
1638
+ /**
1639
+ * Intent-based recommendations
1640
+ */
1641
+ export interface IntentRecommendations {
1642
+ /** Suggested adapters */
1643
+ suggestedAdapters?: string[];
1644
+ /** Optimization hints */
1645
+ optimizations?: string[];
1646
+ /** Common pitfalls to avoid */
1647
+ warnings?: string[];
1648
+ /** Best practices */
1649
+ bestPractices?: string[];
1650
+ }
1651
+ /**
1652
+ * Execution strategy types
1653
+ */
1654
+ export type ExecutionStrategy = 'default' | 'sequential' | 'aggressive' | 'conservative' | 'fast-fail' | 'resilient';
1655
+ /**
1656
+ * Execution context for strategy resolution
1657
+ */
1658
+ export interface ExecutionStrategyContext {
1659
+ /** Parsed workflow */
1660
+ workflow: ParsedWorkflow;
1661
+ /** System metrics (future) */
1662
+ systemLoad?: {
1663
+ cpu: number;
1664
+ memory: number;
1665
+ activeWorkflows: number;
1666
+ };
1667
+ /** Workflow intent (from annotations) */
1668
+ intent?: string;
1669
+ /** Resource limits */
1670
+ resourceLimits?: {
1671
+ maxConcurrentSteps: number;
1672
+ maxMemory: number;
1673
+ timeout: number;
1674
+ };
1675
+ /** Historical data (future) */
1676
+ history?: {
1677
+ previousExecutions: number;
1678
+ averageSuccessRate: number;
1679
+ commonFailures: string[];
1680
+ };
1681
+ }
1682
+ /**
1683
+ * Strategy resolution result
1684
+ */
1685
+ export interface ResolvedExecutionStrategy {
1686
+ /** Selected strategy */
1687
+ strategy: ExecutionStrategy;
1688
+ /** Strategy-specific adjustments */
1689
+ adjustments: {
1690
+ /** Concurrency limit */
1691
+ maxConcurrentSteps?: number;
1692
+ /** Timeout multiplier */
1693
+ timeoutMultiplier?: number;
1694
+ /** Retry strategy override */
1695
+ retryStrategy?: 'exponential' | 'linear' | 'constant';
1696
+ /** Max retry attempts */
1697
+ maxRetries?: number;
1698
+ /** Enable caching */
1699
+ enableCaching?: boolean;
1700
+ };
1701
+ /** Reason for strategy selection (for observability) */
1702
+ reason: string;
1703
+ }
1704
+ /**
1705
+ * Step execution status
1706
+ *
1707
+ * Lifecycle:
1708
+ * PENDING → RUNNING → SUCCESS → COMPLETED
1709
+ * OR
1710
+ * PENDING → RUNNING → FAILED → RETRYING → RUNNING → SUCCESS → COMPLETED
1711
+ * OR
1712
+ * PENDING → SKIPPED
1713
+ */
1714
+ export declare enum StepStatus {
1715
+ /** Step is queued, not yet started */
1716
+ PENDING = "PENDING",
1717
+ /** Step is currently executing */
1718
+ RUNNING = "RUNNING",
1719
+ /** Step completed successfully */
1720
+ SUCCESS = "SUCCESS",
1721
+ /** Step failed */
1722
+ FAILED = "FAILED",
1723
+ /** Step is retrying after failure */
1724
+ RETRYING = "RETRYING",
1725
+ /** Step was skipped (conditional execution) */
1726
+ SKIPPED = "SKIPPED",
1727
+ /** Step timed out */
1728
+ TIMEOUT = "TIMEOUT",
1729
+ /** Step was cancelled */
1730
+ CANCELLED = "CANCELLED"
1731
+ }
1732
+ /**
1733
+ * Workflow execution status
1734
+ */
1735
+ export declare enum WorkflowStatus {
1736
+ /** Workflow is queued, not yet started */
1737
+ QUEUED = "QUEUED",
1738
+ /** Workflow is currently executing */
1739
+ RUNNING = "RUNNING",
1740
+ /** Workflow completed successfully (all steps success) */
1741
+ COMPLETED = "COMPLETED",
1742
+ /** Workflow failed (one or more steps failed) */
1743
+ FAILED = "FAILED",
1744
+ /** Workflow partially completed (some steps failed but continueOnError=true) */
1745
+ PARTIAL = "PARTIAL",
1746
+ /** Workflow timed out */
1747
+ TIMEOUT = "TIMEOUT",
1748
+ /** Workflow was cancelled */
1749
+ CANCELLED = "CANCELLED",
1750
+ /** Workflow is paused (future feature) */
1751
+ PAUSED = "PAUSED"
1752
+ }
1753
+ /**
1754
+ * Step execution state
1755
+ */
1756
+ export interface StepExecutionState {
1757
+ /** Unique step ID */
1758
+ stepId: string;
1759
+ /** Current status */
1760
+ status: StepStatus;
1761
+ /** Number of execution attempts */
1762
+ attempts: number;
1763
+ /** Start timestamp (ms since epoch) */
1764
+ startTime?: number;
1765
+ /** End timestamp (ms since epoch) */
1766
+ endTime?: number;
1767
+ /** Error information if failed */
1768
+ error?: {
1769
+ message: string;
1770
+ code?: string;
1771
+ stack?: string;
1772
+ };
1773
+ /** Step output data (if successful) */
1774
+ output?: any;
1775
+ /** Execution duration in milliseconds */
1776
+ duration?: number;
1777
+ /** Last updated timestamp */
1778
+ updatedAt: number;
1779
+ }
1780
+ /**
1781
+ * Workflow execution state
1782
+ */
1783
+ export interface WorkflowExecutionState {
1784
+ /** Unique workflow execution ID */
1785
+ executionId: string;
1786
+ /** Workflow name/ID */
1787
+ workflowId: string;
1788
+ /** Current workflow status */
1789
+ status: WorkflowStatus;
1790
+ /** State of all steps (keyed by step ID) */
1791
+ steps: Record<string, StepExecutionState>;
1792
+ /** Workflow start timestamp (ms since epoch) */
1793
+ startedAt?: number;
1794
+ /** Workflow completion timestamp (ms since epoch) */
1795
+ finishedAt?: number;
1796
+ /** Total workflow duration in milliseconds */
1797
+ duration?: number;
1798
+ /** Workflow-level error (if failed) */
1799
+ error?: {
1800
+ message: string;
1801
+ stepId?: string;
1802
+ code?: string;
1803
+ };
1804
+ /** Execution metadata */
1805
+ metadata: {
1806
+ /** Total number of steps */
1807
+ totalSteps: number;
1808
+ /** Number of completed steps */
1809
+ completedSteps: number;
1810
+ /** Number of failed steps */
1811
+ failedSteps: number;
1812
+ /** Number of skipped steps */
1813
+ skippedSteps: number;
1814
+ /** Current phase being executed */
1815
+ currentPhase?: number;
1816
+ /** Total number of phases */
1817
+ totalPhases?: number;
1818
+ };
1819
+ /** Last state update timestamp */
1820
+ updatedAt: number;
1821
+ /** Execution context snapshot */
1822
+ context?: {
1823
+ env?: Record<string, any>;
1824
+ inputs?: Record<string, any>;
1825
+ };
1826
+ }
1827
+ /**
1828
+ * State transition record for audit trail
1829
+ */
1830
+ export interface StateTransition<T> {
1831
+ /** State before transition */
1832
+ readonly from: T;
1833
+ /** State after transition */
1834
+ readonly to: T;
1835
+ /** Timestamp of transition (ms since epoch) */
1836
+ readonly timestamp: number;
1837
+ /** Optional reason for transition */
1838
+ readonly reason?: string;
1839
+ }
1840
+ /**
1841
+ * State machine configuration
1842
+ */
1843
+ export interface StateMachineConfig<T> {
1844
+ /** Initial state */
1845
+ readonly initialState: T;
1846
+ /** Valid transitions map: from → allowed to states */
1847
+ readonly transitions: ReadonlyMap<T, readonly T[]>;
1848
+ /** Terminal states (no further transitions allowed) */
1849
+ readonly terminalStates: ReadonlySet<T>;
1850
+ }
1851
+ /**
1852
+ * Permission types for workflow execution
1853
+ */
1854
+ export declare enum Permission {
1855
+ HTTP_REQUEST = "http:request",
1856
+ SHELL_EXECUTE = "shell:execute",
1857
+ FILE_READ = "file:read",
1858
+ FILE_WRITE = "file:write",
1859
+ DB_READ = "db:read",
1860
+ DB_WRITE = "db:write",
1861
+ NETWORK_ACCESS = "network:access",
1862
+ SYSTEM_ACCESS = "system:access"
1863
+ }
1864
+ /**
1865
+ * Reserved top-level workflow fields
1866
+ * These are NEVER user-controlled, always engine-injected
1867
+ */
1868
+ export declare const RESERVED_WORKFLOW_FIELDS: readonly ["_internal", "_identity", "_ownership", "_billing", "_usage", "_audit", "_system", "_engine", "_execution", "_runtime", "_security", "_metadata"];
1869
+ /**
1870
+ * Reserved context field names
1871
+ * Users cannot set these in workflow context
1872
+ */
1873
+ export declare const RESERVED_CONTEXT_FIELDS: readonly ["_internal", "_identity", "_ownership", "_billing", "_usage", "_audit", "_system", "_engine", "_security", "executionId", "runId", "traceId", "userId", "workspaceId", "subscriptionId", "subscriptionTier", "billingId", "billingMode", "pricingTier", "pricingModel", "billingSnapshot"];
1874
+ /**
1875
+ * Reserved step field names
1876
+ * Users cannot set these in step definitions
1877
+ */
1878
+ export declare const RESERVED_STEP_FIELDS: readonly ["_internal", "_billing", "_usage", "_audit", "executionId", "runId", "stepExecutionId"];
1879
+ /**
1880
+ * Reserved annotation prefixes
1881
+ * These annotation namespaces are reserved for engine use
1882
+ */
1883
+ export declare const RESERVED_ANNOTATION_PREFIXES: readonly ["engine.", "system.", "internal.", "billing.", "audit.", "security."];
1884
+ /**
1885
+ * Security error codes
1886
+ */
1887
+ export declare enum SecurityErrorCode {
1888
+ /** User attempted to set a reserved field name */
1889
+ RESERVED_FIELD_OVERRIDE = "ENGINE_RESERVED_FIELD_OVERRIDE",
1890
+ /** User attempted to set billing-related fields */
1891
+ BILLING_FIELD_OVERRIDE = "ENGINE_BILLING_FIELD_OVERRIDE",
1892
+ /** User attempted to set execution identity fields */
1893
+ IDENTITY_FIELD_OVERRIDE = "ENGINE_IDENTITY_FIELD_OVERRIDE",
1894
+ /** User attempted to set ownership fields */
1895
+ OWNERSHIP_FIELD_OVERRIDE = "ENGINE_OWNERSHIP_FIELD_OVERRIDE",
1896
+ /** User attempted to set usage counter fields */
1897
+ USAGE_COUNTER_OVERRIDE = "ENGINE_USAGE_COUNTER_OVERRIDE",
1898
+ /** User attempted to set internal state fields */
1899
+ INTERNAL_STATE_OVERRIDE = "ENGINE_INTERNAL_STATE_OVERRIDE",
1900
+ /** User attempted to use reserved annotation namespace */
1901
+ RESERVED_ANNOTATION_NAMESPACE = "ENGINE_RESERVED_ANNOTATION_NAMESPACE"
1902
+ }
1903
+ /**
1904
+ * Security violation details (legacy format for backward compatibility)
1905
+ * @deprecated Use SecurityError factory methods instead
1906
+ */
1907
+ export interface SecurityViolationDetails {
1908
+ /** Error code for programmatic handling */
1909
+ code: SecurityErrorCode;
1910
+ /** Location where violation occurred */
1911
+ location: string;
1912
+ /** The reserved field that was attempted */
1913
+ field: string;
1914
+ /** The value user tried to set (for debugging) */
1915
+ attemptedValue?: any;
1916
+ /** Why this field is protected */
1917
+ reason: string;
1918
+ /** Suggested fix */
1919
+ suggestion: string;
1920
+ }
1921
+ /**
1922
+ * Diagnostic error information
1923
+ * Contains all data needed to understand and debug an error
1924
+ */
1925
+ export interface OrbytErrorDiagnostic {
1926
+ /** Structured error code (e.g., ORB-S-001) */
1927
+ code: OrbytErrorCode;
1928
+ /** Human-readable error message */
1929
+ message: string;
1930
+ /** Process exit code from ecosystem-core (for CLI) */
1931
+ exitCode?: ExitCodes;
1932
+ /** Path to the error location (e.g., "workflow.steps[2].uses") */
1933
+ path?: string;
1934
+ /** Optional suggestion for fixing the error */
1935
+ hint?: string;
1936
+ /** Error severity (ERROR, WARNING, INFO) */
1937
+ severity: ErrorSeverity;
1938
+ /** Additional context data for debugging */
1939
+ context?: Record<string, any>;
1940
+ }
1941
+ /**
1942
+ * Schedule status
1943
+ */
1944
+ export type ScheduleStatus = 'active' | 'paused' | 'disabled' | 'expired';
1945
+ /**
1946
+ * Extended schedule trigger type for internal scheduling
1947
+ * Includes core TriggerType values and internal scheduling types
1948
+ */
1949
+ export type ScheduleTriggerType = TriggerType | 'interval' | 'once';
1950
+ /**
1951
+ * Workflow schedule configuration
1952
+ */
1953
+ export interface WorkflowSchedule {
1954
+ /** Unique schedule ID */
1955
+ id: string;
1956
+ /** Workflow ID to execute */
1957
+ workflowId: string;
1958
+ /** Schedule name */
1959
+ name?: string;
1960
+ /** Schedule description */
1961
+ description?: string;
1962
+ /** Trigger type */
1963
+ triggerType: ScheduleTriggerType;
1964
+ /** Cron expression (for cron trigger) */
1965
+ cron?: string;
1966
+ /** Interval in milliseconds (for interval trigger) */
1967
+ intervalMs?: number;
1968
+ /** Timezone for schedule (default: UTC) */
1969
+ timezone?: string;
1970
+ /** Schedule status */
1971
+ status: ScheduleStatus;
1972
+ /** When schedule was created */
1973
+ createdAt: Date;
1974
+ /** When schedule was last updated */
1975
+ updatedAt: Date;
1976
+ /** Last execution timestamp */
1977
+ lastRunAt?: Date;
1978
+ /** Next scheduled execution timestamp */
1979
+ nextRunAt?: Date;
1980
+ /** Start date (schedule won't run before this) */
1981
+ startDate?: Date;
1982
+ /** End date (schedule won't run after this) */
1983
+ endDate?: Date;
1984
+ /** Maximum number of executions (undefined = unlimited) */
1985
+ maxExecutions?: number;
1986
+ /** Current execution count */
1987
+ executionCount: number;
1988
+ /** Input data to pass to workflow */
1989
+ input?: Record<string, any>;
1990
+ /** Schedule metadata */
1991
+ metadata?: Record<string, any>;
1992
+ /** Execution options */
1993
+ options?: ScheduleOptions;
1994
+ }
1995
+ /**
1996
+ * Schedule execution options
1997
+ */
1998
+ export interface ScheduleOptions {
1999
+ /** Skip if previous run is still running */
2000
+ skipIfRunning?: boolean;
2001
+ /** Maximum concurrent executions allowed */
2002
+ maxConcurrent?: number;
2003
+ /** Timeout for single execution (ms) */
2004
+ timeoutMs?: number;
2005
+ /** Retry failed executions */
2006
+ retry?: {
2007
+ max: number;
2008
+ delayMs: number;
2009
+ };
2010
+ /** Handle missed runs when scheduler restarts */
2011
+ catchUpMissedRuns?: boolean;
2012
+ }
2013
+ /**
2014
+ * Schedule execution record
2015
+ */
2016
+ export interface ScheduleExecution {
2017
+ /** Execution ID */
2018
+ id: string;
2019
+ /** Schedule ID */
2020
+ scheduleId: string;
2021
+ /** Workflow ID */
2022
+ workflowId: string;
2023
+ /** Scheduled time */
2024
+ scheduledAt: Date;
2025
+ /** Actual start time */
2026
+ startedAt: Date;
2027
+ /** Completion time */
2028
+ completedAt?: Date;
2029
+ /** Execution status */
2030
+ status: 'running' | 'completed' | 'failed' | 'timeout';
2031
+ /** Execution result */
2032
+ result?: any;
2033
+ /** Error if failed */
2034
+ error?: Error;
2035
+ /** Duration in milliseconds */
2036
+ durationMs?: number;
2037
+ }
2038
+ /**
2039
+ * Schedule creation input
2040
+ */
2041
+ export interface CreateScheduleInput {
2042
+ /** Workflow ID */
2043
+ workflowId: string;
2044
+ /** Schedule name */
2045
+ name?: string;
2046
+ /** Description */
2047
+ description?: string;
2048
+ /** Trigger type */
2049
+ triggerType: ScheduleTriggerType;
2050
+ /** Cron expression (required for cron trigger) */
2051
+ cron?: string;
2052
+ /** Interval in milliseconds (required for interval trigger) */
2053
+ intervalMs?: number;
2054
+ /** Timezone for schedule */
2055
+ timezone?: string;
2056
+ /** Start date */
2057
+ startDate?: Date;
2058
+ /** End date */
2059
+ endDate?: Date;
2060
+ /** Max executions */
2061
+ maxExecutions?: number;
2062
+ /** Input data */
2063
+ input?: Record<string, any>;
2064
+ /** Options */
2065
+ options?: ScheduleOptions;
2066
+ /** Event source (for event triggers) */
2067
+ eventSource?: string;
2068
+ /** Webhook endpoint (for webhook triggers) */
2069
+ webhookEndpoint?: string;
2070
+ }
2071
+ /**
2072
+ * Scheduler configuration
2073
+ */
2074
+ export interface CronSchedulerConfig {
2075
+ /** Enable schedule execution (false = dry run mode) */
2076
+ enabled?: boolean;
2077
+ /** Maximum concurrent workflow executions */
2078
+ maxConcurrent?: number;
2079
+ /** Timezone for schedules (default: UTC) */
2080
+ defaultTimezone?: string;
2081
+ }
2082
+ /**
2083
+ * Schedule trigger callback
2084
+ */
2085
+ export type ScheduleTriggerCallback = (schedule: WorkflowSchedule, execution: ScheduleExecution) => Promise<void> | void;
2086
+ /**
2087
+ * Scheduler event listeners
2088
+ */
2089
+ export interface SchedulerEventListeners {
2090
+ /** Called when schedule is triggered */
2091
+ onScheduleTrigger?: ScheduleTriggerCallback;
2092
+ /** Called when schedule execution completes */
2093
+ onExecutionComplete?: (execution: ScheduleExecution) => void | Promise<void>;
2094
+ /** Called when schedule execution fails */
2095
+ onExecutionFailed?: (execution: ScheduleExecution, error: Error) => void | Promise<void>;
2096
+ /** Called when scheduler starts */
2097
+ onStart?: () => void | Promise<void>;
2098
+ /** Called when scheduler stops */
2099
+ onStop?: () => void | Promise<void>;
2100
+ }
2101
+ /**
2102
+ * Permission policy for workflow execution
2103
+ */
2104
+ export interface PermissionPolicy {
2105
+ /** Allow network access */
2106
+ allowNetwork?: boolean;
2107
+ /** Allow file system access */
2108
+ allowFileSystem?: boolean;
2109
+ /** Allow shell command execution */
2110
+ allowShell?: boolean;
2111
+ /** Allowed adapter types */
2112
+ allowedAdapters?: string[];
2113
+ /** Blocked adapter types */
2114
+ blockedAdapters?: string[];
2115
+ /** Maximum step timeout (ms) */
2116
+ maxStepTimeout?: number;
2117
+ /** Maximum workflow timeout (ms) */
2118
+ maxWorkflowTimeout?: number;
2119
+ }
2120
+ /**
2121
+ * Sandbox configuration
2122
+ */
2123
+ export interface SandboxConfig {
2124
+ /** Policy to enforce */
2125
+ policy: PermissionPolicy;
2126
+ /** Isolated environment variables */
2127
+ env?: Record<string, string>;
2128
+ /** Working directory */
2129
+ cwd?: string;
2130
+ }
2131
+ /**
2132
+ * Sandbox execution context
2133
+ */
2134
+ export interface SandboxContext {
2135
+ /** Sandbox ID */
2136
+ id: string;
2137
+ /** Policy being enforced */
2138
+ policy: PermissionPolicy;
2139
+ /** Start time */
2140
+ startedAt: Date;
2141
+ /** Resource usage tracking */
2142
+ usage: {
2143
+ memory: number;
2144
+ cpu: number;
2145
+ duration: number;
2146
+ };
2147
+ }
2148
+ /**
2149
+ * Core event interface - all events must conform to this shape
2150
+ */
2151
+ export interface OrbytEvent<T = any> {
2152
+ /** Event type identifier */
2153
+ type: string;
2154
+ /** Unix timestamp in milliseconds */
2155
+ timestamp: number;
2156
+ /** ID of the workflow execution */
2157
+ workflowId?: string;
2158
+ /** ID of the step being executed */
2159
+ stepId?: string;
2160
+ /** ID of the specific execution run */
2161
+ runId?: string;
2162
+ /** Event-specific payload data */
2163
+ payload?: T;
2164
+ }
2165
+ /**
2166
+ * Engine-wide event types
2167
+ * These cover all significant lifecycle moments in the execution flow
2168
+ */
2169
+ export declare enum EngineEventType {
2170
+ WORKFLOW_STARTED = "workflow.started",
2171
+ WORKFLOW_COMPLETED = "workflow.completed",
2172
+ WORKFLOW_FAILED = "workflow.failed",
2173
+ WORKFLOW_PAUSED = "workflow.paused",
2174
+ WORKFLOW_RESUMED = "workflow.resumed",
2175
+ WORKFLOW_CANCELLED = "workflow.cancelled",
2176
+ STEP_STARTED = "step.started",
2177
+ STEP_COMPLETED = "step.completed",
2178
+ STEP_FAILED = "step.failed",
2179
+ STEP_SKIPPED = "step.skipped",
2180
+ STEP_RETRYING = "step.retrying",
2181
+ STEP_TIMEOUT = "step.timeout",
2182
+ JOB_ENQUEUED = "job.enqueued",
2183
+ JOB_DEQUEUED = "job.dequeued",
2184
+ JOB_RETRY = "job.retry",
2185
+ SCHEDULE_TRIGGERED = "schedule.triggered",
2186
+ TRIGGER_FIRED = "trigger.fired",
2187
+ STATE_CHANGED = "state.changed",
2188
+ ENGINE_STARTED = "engine.started",
2189
+ ENGINE_STOPPED = "engine.stopped",
2190
+ WORKER_ONLINE = "worker.online",
2191
+ WORKER_OFFLINE = "worker.offline"
2192
+ }
2193
+ /**
2194
+ * Typed event payloads for better type safety
2195
+ */
2196
+ export interface WorkflowStartedPayload {
2197
+ workflowId: string;
2198
+ workflowName: string;
2199
+ runId: string;
2200
+ triggeredBy?: string;
2201
+ inputs?: Record<string, any>;
2202
+ }
2203
+ export interface WorkflowCompletedPayload {
2204
+ workflowId: string;
2205
+ workflowName: string;
2206
+ runId: string;
2207
+ durationMs: number;
2208
+ stepCount: number;
2209
+ }
2210
+ export interface WorkflowFailedPayload {
2211
+ workflowId: string;
2212
+ workflowName: string;
2213
+ runId: string;
2214
+ error: string;
2215
+ failedStep?: string;
2216
+ durationMs: number;
2217
+ }
2218
+ export interface StepStartedPayload {
2219
+ workflowId: string;
2220
+ runId: string;
2221
+ stepId: string;
2222
+ stepName: string;
2223
+ adapterType: string;
2224
+ }
2225
+ export interface StepCompletedPayload {
2226
+ workflowId: string;
2227
+ runId: string;
2228
+ stepId: string;
2229
+ stepName: string;
2230
+ adapterType: string;
2231
+ durationMs: number;
2232
+ output?: any;
2233
+ }
2234
+ export interface StepFailedPayload {
2235
+ workflowId: string;
2236
+ runId: string;
2237
+ stepId: string;
2238
+ stepName: string;
2239
+ adapterType: string;
2240
+ error: string;
2241
+ attempt: number;
2242
+ willRetry: boolean;
2243
+ }
2244
+ export interface StepRetryingPayload {
2245
+ workflowId: string;
2246
+ runId: string;
2247
+ stepId: string;
2248
+ stepName: string;
2249
+ attempt: number;
2250
+ maxAttempts: number;
2251
+ delayMs: number;
2252
+ }
2253
+ export interface JobEnqueuedPayload {
2254
+ jobId: string;
2255
+ workflowId: string;
2256
+ priority: number;
2257
+ queueDepth: number;
2258
+ }
2259
+ export interface ScheduleTriggeredPayload {
2260
+ scheduleId: string;
2261
+ workflowId: string;
2262
+ triggerType: string;
2263
+ nextRun?: Date;
2264
+ }
2265
+ export interface StateChangedPayload {
2266
+ workflowId: string;
2267
+ runId: string;
2268
+ from: string;
2269
+ to: string;
2270
+ }
2271
+ /**
2272
+ * Failure strategy type
2273
+ */
2274
+ export type FailureStrategyType = 'abort' | 'continue' | 'skipDependent';
2275
+ /**
2276
+ * Failure strategy configuration
2277
+ */
2278
+ export interface FailureStrategyConfig {
2279
+ /** Strategy type */
2280
+ type: FailureStrategyType;
2281
+ /** Allow partial workflow completion */
2282
+ allowPartialSuccess?: boolean;
2283
+ /** Maximum number of step failures before aborting workflow */
2284
+ maxFailures?: number;
2285
+ /** Critical step IDs that must succeed (failure = abort) */
2286
+ criticalSteps?: string[];
2287
+ /** Cleanup function to run on failure */
2288
+ onFailure?: (stepId: string, error: Error) => Promise<void> | void;
2289
+ }
2290
+ /**
2291
+ * Failure decision for a specific step failure
2292
+ */
2293
+ export interface FailureDecision {
2294
+ /** Should workflow continue? */
2295
+ continueWorkflow: boolean;
2296
+ /** Should execute cleanup? */
2297
+ runCleanup: boolean;
2298
+ /** Should skip dependent steps? */
2299
+ skipDependentSteps: boolean;
2300
+ /** Reason for decision */
2301
+ reason: string;
2302
+ /** Final workflow status if abort */
2303
+ finalStatus?: 'failed' | 'partial';
2304
+ }
2305
+ /**
2306
+ * Failure context for tracking execution state
2307
+ */
2308
+ export interface FailureContext {
2309
+ /** ID of failed step */
2310
+ stepId: string;
2311
+ /** Error that caused failure */
2312
+ error: Error;
2313
+ /** Total steps in workflow */
2314
+ totalSteps: number;
2315
+ /** Number of completed steps */
2316
+ completedSteps: number;
2317
+ /** Number of failed steps so far */
2318
+ failureCount: number;
2319
+ /** Workflow execution ID */
2320
+ executionId?: string;
2321
+ }
2322
+ /**
2323
+ * Failure handling result
2324
+ */
2325
+ export interface FailureHandlingResult {
2326
+ /** Failure decision */
2327
+ decision: FailureDecision;
2328
+ /** Cleanup completed successfully */
2329
+ cleanupSuccess: boolean;
2330
+ /** Error during cleanup (if any) */
2331
+ cleanupError?: Error;
2332
+ /** Steps to skip based on decision */
2333
+ stepsToSkip: string[];
2334
+ }
2335
+ /**
2336
+ * Failure event listeners
2337
+ */
2338
+ export interface FailureListeners {
2339
+ /** Called before handling failure */
2340
+ onBeforeHandle?: (context: FailureContext) => void | Promise<void>;
2341
+ /** Called after decision is made */
2342
+ onDecision?: (decision: FailureDecision, context: FailureContext) => void | Promise<void>;
2343
+ /** Called before cleanup */
2344
+ onBeforeCleanup?: (context: FailureContext) => void | Promise<void>;
2345
+ /** Called after cleanup */
2346
+ onAfterCleanup?: (success: boolean, context: FailureContext) => void | Promise<void>;
2347
+ /** Called when workflow should abort */
2348
+ onAbort?: (reason: string, context: FailureContext) => void | Promise<void>;
2349
+ /** Called when workflow continues after failure */
2350
+ onContinue?: (context: FailureContext) => void | Promise<void>;
2351
+ }
2352
+ /**
2353
+ * Dependency information for skip decisions
2354
+ */
2355
+ export interface DependencyInfo {
2356
+ /** Step ID to dependencies map */
2357
+ stepDependencies: Map<string, string[]>;
2358
+ /** Step ID to dependents map (reverse) */
2359
+ stepDependents: Map<string, string[]>;
58
2360
  }
59
2361
  //# sourceMappingURL=core-types.d.ts.map