@hexabot-ai/agentic 3.0.1-alpha.0

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 (176) hide show
  1. package/LICENSE.md +120 -0
  2. package/README.md +231 -0
  3. package/dist/cjs/action/abstract-action.js +141 -0
  4. package/dist/cjs/action/action.js +47 -0
  5. package/dist/cjs/action/action.types.js +7 -0
  6. package/dist/cjs/bindings/base-binding.js +278 -0
  7. package/dist/cjs/context.js +79 -0
  8. package/dist/cjs/dsl.types.js +318 -0
  9. package/dist/cjs/index.js +52 -0
  10. package/dist/cjs/runner-runtime-control.js +343 -0
  11. package/dist/cjs/step-executors/conditional-executor.js +63 -0
  12. package/dist/cjs/step-executors/loop-executor.js +187 -0
  13. package/dist/cjs/step-executors/parallel-executor.js +51 -0
  14. package/dist/cjs/step-executors/skip-helpers.js +29 -0
  15. package/dist/cjs/step-executors/task-executor.js +155 -0
  16. package/dist/cjs/step-executors/types.js +7 -0
  17. package/dist/cjs/suspension-rebuilder.js +301 -0
  18. package/dist/cjs/utils/deferred.js +17 -0
  19. package/dist/cjs/utils/naming.js +48 -0
  20. package/dist/cjs/utils/timeout.js +42 -0
  21. package/dist/cjs/utils/workflow-definition.js +102 -0
  22. package/dist/cjs/workflow-compiler.js +212 -0
  23. package/dist/cjs/workflow-event-emitter.js +40 -0
  24. package/dist/cjs/workflow-runner.js +448 -0
  25. package/dist/cjs/workflow-types.js +7 -0
  26. package/dist/cjs/workflow-values.js +99 -0
  27. package/dist/cjs/workflow.js +243 -0
  28. package/dist/esm/action/abstract-action.js +137 -0
  29. package/dist/esm/action/action.js +44 -0
  30. package/dist/esm/action/action.types.js +6 -0
  31. package/dist/esm/bindings/base-binding.js +273 -0
  32. package/dist/esm/context.js +75 -0
  33. package/dist/esm/dsl.types.js +309 -0
  34. package/dist/esm/index.js +16 -0
  35. package/dist/esm/runner-runtime-control.js +338 -0
  36. package/dist/esm/step-executors/conditional-executor.js +60 -0
  37. package/dist/esm/step-executors/loop-executor.js +182 -0
  38. package/dist/esm/step-executors/parallel-executor.js +48 -0
  39. package/dist/esm/step-executors/skip-helpers.js +25 -0
  40. package/dist/esm/step-executors/task-executor.js +152 -0
  41. package/dist/esm/step-executors/types.js +6 -0
  42. package/dist/esm/suspension-rebuilder.js +296 -0
  43. package/dist/esm/utils/deferred.js +14 -0
  44. package/dist/esm/utils/naming.js +42 -0
  45. package/dist/esm/utils/timeout.js +37 -0
  46. package/dist/esm/utils/workflow-definition.js +98 -0
  47. package/dist/esm/workflow-compiler.js +208 -0
  48. package/dist/esm/workflow-event-emitter.js +36 -0
  49. package/dist/esm/workflow-runner.js +444 -0
  50. package/dist/esm/workflow-types.js +6 -0
  51. package/dist/esm/workflow-values.js +89 -0
  52. package/dist/esm/workflow.js +236 -0
  53. package/dist/types/action/abstract-action.d.ts +54 -0
  54. package/dist/types/action/abstract-action.d.ts.map +1 -0
  55. package/dist/types/action/action.d.ts +23 -0
  56. package/dist/types/action/action.d.ts.map +1 -0
  57. package/dist/types/action/action.types.d.ts +55 -0
  58. package/dist/types/action/action.types.d.ts.map +1 -0
  59. package/dist/types/bindings/base-binding.d.ts +52 -0
  60. package/dist/types/bindings/base-binding.d.ts.map +1 -0
  61. package/dist/types/context.d.ts +105 -0
  62. package/dist/types/context.d.ts.map +1 -0
  63. package/dist/types/dsl.types.d.ts +220 -0
  64. package/dist/types/dsl.types.d.ts.map +1 -0
  65. package/dist/types/index.d.ts +18 -0
  66. package/dist/types/index.d.ts.map +1 -0
  67. package/dist/types/runner-runtime-control.d.ts +64 -0
  68. package/dist/types/runner-runtime-control.d.ts.map +1 -0
  69. package/dist/types/step-executors/conditional-executor.d.ts +13 -0
  70. package/dist/types/step-executors/conditional-executor.d.ts.map +1 -0
  71. package/dist/types/step-executors/loop-executor.d.ts +33 -0
  72. package/dist/types/step-executors/loop-executor.d.ts.map +1 -0
  73. package/dist/types/step-executors/parallel-executor.d.ts +14 -0
  74. package/dist/types/step-executors/parallel-executor.d.ts.map +1 -0
  75. package/dist/types/step-executors/skip-helpers.d.ts +12 -0
  76. package/dist/types/step-executors/skip-helpers.d.ts.map +1 -0
  77. package/dist/types/step-executors/task-executor.d.ts +13 -0
  78. package/dist/types/step-executors/task-executor.d.ts.map +1 -0
  79. package/dist/types/step-executors/types.d.ts +24 -0
  80. package/dist/types/step-executors/types.d.ts.map +1 -0
  81. package/dist/types/suspension-rebuilder.d.ts +67 -0
  82. package/dist/types/suspension-rebuilder.d.ts.map +1 -0
  83. package/dist/types/utils/deferred.d.ts +7 -0
  84. package/dist/types/utils/deferred.d.ts.map +1 -0
  85. package/dist/types/utils/naming.d.ts +24 -0
  86. package/dist/types/utils/naming.d.ts.map +1 -0
  87. package/dist/types/utils/timeout.d.ts +17 -0
  88. package/dist/types/utils/timeout.d.ts.map +1 -0
  89. package/dist/types/utils/workflow-definition.d.ts +3 -0
  90. package/dist/types/utils/workflow-definition.d.ts.map +1 -0
  91. package/dist/types/workflow-compiler.d.ts +12 -0
  92. package/dist/types/workflow-compiler.d.ts.map +1 -0
  93. package/dist/types/workflow-event-emitter.d.ts +70 -0
  94. package/dist/types/workflow-event-emitter.d.ts.map +1 -0
  95. package/dist/types/workflow-runner.d.ts +179 -0
  96. package/dist/types/workflow-runner.d.ts.map +1 -0
  97. package/dist/types/workflow-types.d.ts +195 -0
  98. package/dist/types/workflow-types.d.ts.map +1 -0
  99. package/dist/types/workflow-values.d.ts +34 -0
  100. package/dist/types/workflow-values.d.ts.map +1 -0
  101. package/dist/types/workflow.d.ts +75 -0
  102. package/dist/types/workflow.d.ts.map +1 -0
  103. package/examples/defs-bindings-agent/actions/ai-agent.ts +110 -0
  104. package/examples/defs-bindings-agent/actions/caculate-score.ts +49 -0
  105. package/examples/defs-bindings-agent/actions/index.ts +15 -0
  106. package/examples/defs-bindings-agent/bindings.ts +20 -0
  107. package/examples/defs-bindings-agent/context.ts +32 -0
  108. package/examples/defs-bindings-agent/workflow.ts +67 -0
  109. package/examples/defs-bindings-agent/workflow.yml +28 -0
  110. package/examples/full/actions/await-user-input.ts +46 -0
  111. package/examples/full/actions/call-llm.ts +133 -0
  112. package/examples/full/actions/create-ticket.ts +46 -0
  113. package/examples/full/actions/decision-router.ts +83 -0
  114. package/examples/full/actions/get-calendar-events.ts +55 -0
  115. package/examples/full/actions/get-user-profile.ts +72 -0
  116. package/examples/full/actions/index.ts +33 -0
  117. package/examples/full/actions/query-memory.ts +45 -0
  118. package/examples/full/actions/search-web.ts +53 -0
  119. package/examples/full/actions/send-email.ts +50 -0
  120. package/examples/full/context.ts +41 -0
  121. package/examples/full/workflow.ts +75 -0
  122. package/examples/full/workflow.yml +359 -0
  123. package/examples/loop/actions/await-reply.ts +47 -0
  124. package/examples/loop/actions/index.ts +19 -0
  125. package/examples/loop/actions/send-text-message.ts +40 -0
  126. package/examples/loop/context.ts +32 -0
  127. package/examples/loop/workflow.ts +66 -0
  128. package/examples/loop/workflow.yml +66 -0
  129. package/examples/suspend-resume/actions/format-reply.ts +43 -0
  130. package/examples/suspend-resume/actions/index.ts +13 -0
  131. package/examples/suspend-resume/actions/wait-for-user.ts +51 -0
  132. package/examples/suspend-resume/context.ts +32 -0
  133. package/examples/suspend-resume/workflow.ts +79 -0
  134. package/examples/suspend-resume/workflow.yml +29 -0
  135. package/package.json +60 -0
  136. package/src/__tests__/parser.test.ts +95 -0
  137. package/src/__tests__/suspension-rebuilder.test.ts +361 -0
  138. package/src/__tests__/test-helpers.ts +36 -0
  139. package/src/__tests__/validation.test.ts +526 -0
  140. package/src/__tests__/workflow-compiler.test.ts +715 -0
  141. package/src/__tests__/workflow-definition-path.test.ts +381 -0
  142. package/src/__tests__/workflow-event-emitter.test.ts +50 -0
  143. package/src/__tests__/workflow-runner.test.ts +1397 -0
  144. package/src/__tests__/workflow-values.test.ts +132 -0
  145. package/src/__tests__/workflow.test.ts +320 -0
  146. package/src/action/__tests__/abstract-action-timing.test.ts +183 -0
  147. package/src/action/__tests__/action.test.ts +473 -0
  148. package/src/action/abstract-action.ts +215 -0
  149. package/src/action/action.ts +83 -0
  150. package/src/action/action.types.ts +93 -0
  151. package/src/bindings/base-binding.ts +508 -0
  152. package/src/context.ts +179 -0
  153. package/src/dsl.types.ts +473 -0
  154. package/src/index.ts +114 -0
  155. package/src/runner-runtime-control.ts +544 -0
  156. package/src/step-executors/conditional-executor.test.ts +192 -0
  157. package/src/step-executors/conditional-executor.ts +83 -0
  158. package/src/step-executors/loop-executor.test.ts +303 -0
  159. package/src/step-executors/loop-executor.ts +299 -0
  160. package/src/step-executors/parallel-executor.test.ts +182 -0
  161. package/src/step-executors/parallel-executor.ts +77 -0
  162. package/src/step-executors/skip-helpers.ts +68 -0
  163. package/src/step-executors/task-executor.test.ts +257 -0
  164. package/src/step-executors/task-executor.ts +248 -0
  165. package/src/step-executors/types.ts +70 -0
  166. package/src/suspension-rebuilder.ts +504 -0
  167. package/src/utils/deferred.ts +23 -0
  168. package/src/utils/naming.ts +55 -0
  169. package/src/utils/timeout.ts +48 -0
  170. package/src/utils/workflow-definition.ts +173 -0
  171. package/src/workflow-compiler.ts +317 -0
  172. package/src/workflow-event-emitter.ts +86 -0
  173. package/src/workflow-runner.ts +603 -0
  174. package/src/workflow-types.ts +207 -0
  175. package/src/workflow-values.ts +159 -0
  176. package/src/workflow.ts +387 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-compiler.d.ts","sourceRoot":"","sources":["../../src/workflow-compiler.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAMlE,OAAO,KAAK,EAIV,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAIrB,OAAO,KAAK,EAIV,gBAAgB,EAIjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,GAAG;IACzD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,YAAY,CAAC,EAAE,kBAAkB,CAAC;CACnC,CAAC;AAgQF,+EAA+E;AAC/E,eAAO,MAAM,eAAe,GAC1B,YAAY,kBAAkB,EAC9B,SAAS,sBAAsB,KAC9B,gBAcF,CAAC"}
@@ -0,0 +1,70 @@
1
+ export declare enum StepType {
2
+ Task = "task",
3
+ Parallel = "parallel",
4
+ Conditional = "conditional",
5
+ Loop = "loop"
6
+ }
7
+ export type StepInfo = {
8
+ id: string;
9
+ name: string;
10
+ type: StepType;
11
+ };
12
+ export type WorkflowEventMap = {
13
+ 'hook:workflow:start': {
14
+ runId?: string;
15
+ };
16
+ 'hook:workflow:finish': {
17
+ runId?: string;
18
+ output: Record<string, unknown>;
19
+ };
20
+ 'hook:workflow:failure': {
21
+ runId?: string;
22
+ error: unknown;
23
+ };
24
+ 'hook:workflow:suspended': {
25
+ runId?: string;
26
+ step: StepInfo;
27
+ reason?: string;
28
+ data?: unknown;
29
+ };
30
+ 'hook:step:start': {
31
+ runId?: string;
32
+ step: StepInfo;
33
+ };
34
+ 'hook:step:success': {
35
+ runId?: string;
36
+ step: StepInfo;
37
+ };
38
+ 'hook:step:error': {
39
+ runId?: string;
40
+ step: StepInfo;
41
+ error: unknown;
42
+ };
43
+ 'hook:step:suspended': {
44
+ runId?: string;
45
+ step: StepInfo;
46
+ reason?: string;
47
+ data?: unknown;
48
+ };
49
+ 'hook:step:skipped': {
50
+ runId?: string;
51
+ step: StepInfo;
52
+ reason?: string;
53
+ };
54
+ };
55
+ export type EventEmitterLike = {
56
+ emit(event: string | symbol, ...args: any[]): unknown;
57
+ on(event: string | symbol, listener: (...args: any[]) => void): unknown;
58
+ };
59
+ export type WorkflowEventEmitterLike<E = unknown> = E & EventEmitterLike;
60
+ /**
61
+ * Minimal, browser-friendly event emitter that preserves the typed payloads
62
+ * exposed by {@link WorkflowEventMap}. It supports the subset of the Node.js
63
+ * EventEmitter API that the runtime relies on (`emit` and `on`).
64
+ */
65
+ export declare class WorkflowEventEmitter implements WorkflowEventEmitterLike<WorkflowEventEmitter> {
66
+ private listeners;
67
+ emit<K extends keyof WorkflowEventMap>(event: K, payload: WorkflowEventMap[K]): boolean;
68
+ on<K extends keyof WorkflowEventMap>(event: K, listener: (payload: WorkflowEventMap[K]) => void): this;
69
+ }
70
+ //# sourceMappingURL=workflow-event-emitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-event-emitter.d.ts","sourceRoot":"","sources":["../../src/workflow-event-emitter.ts"],"names":[],"mappings":"AAMA,oBAAY,QAAQ;IAClB,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,WAAW,gBAAgB;IAC3B,IAAI,SAAS;CACd;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,qBAAqB,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,sBAAsB,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;IAC5E,uBAAuB,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;IAC5D,yBAAyB,EAAE;QACzB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,QAAQ,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,OAAO,CAAC;KAChB,CAAC;IACF,iBAAiB,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,QAAQ,CAAA;KAAE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E,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,IAAI,GAC/C,IAAI;CAOR"}
@@ -0,0 +1,179 @@
1
+ import type { BaseWorkflowContext, StepExecutionRecord, WorkflowRunStatus, WorkflowSnapshot } from './context';
2
+ import { type StepInfo } from './workflow-event-emitter';
3
+ import type { CompiledWorkflow, ExecutionState, PersistedSuspension, ResumeResult, RunnerResumeArgs, RunnerStartArgs, StartResult, WorkflowRunOptions } from './workflow-types';
4
+ /**
5
+ * Executes a compiled workflow definition, tracking state, suspensions, and event hooks.
6
+ * Create a new instance per execution to avoid leaking state between runs.
7
+ */
8
+ export declare class WorkflowRunner {
9
+ private readonly compiled;
10
+ private readonly runId?;
11
+ private status;
12
+ private snapshots;
13
+ private stepLog;
14
+ private suspension?;
15
+ private runtimeControl?;
16
+ private currentStep?;
17
+ private lastResumeData?;
18
+ private state?;
19
+ private context?;
20
+ /**
21
+ * Create a new runner for a compiled workflow definition.
22
+ *
23
+ * @param compiled The compiled workflow to execute.
24
+ * @param options Optional runner configuration such as run id.
25
+ */
26
+ constructor(compiled: CompiledWorkflow, options?: WorkflowRunOptions);
27
+ /**
28
+ * Get the current state of the workflow run.
29
+ *
30
+ * @returns The state of the workflow execution.
31
+ */
32
+ getState(): ExecutionState | undefined;
33
+ /**
34
+ * Get the current lifecycle status of the workflow run.
35
+ *
36
+ * @returns The status of the workflow execution.
37
+ */
38
+ getStatus(): WorkflowRunStatus;
39
+ /**
40
+ * Snapshot the current workflow status and action states.
41
+ *
42
+ * @returns A snapshot representing the workflow and each action's status.
43
+ */
44
+ getSnapshot(): WorkflowSnapshot;
45
+ /**
46
+ * Read the per-step execution records captured for UI/telemetry.
47
+ *
48
+ * @returns A shallow copy of the step execution log.
49
+ */
50
+ getStepLog(): Record<string, StepExecutionRecord>;
51
+ /**
52
+ * Read the step currently being executed.
53
+ *
54
+ * @returns Metadata for the in-flight step, if any.
55
+ */
56
+ getCurrentStep(): StepInfo | undefined;
57
+ /**
58
+ * Access the last payload supplied to a resume call.
59
+ *
60
+ * @returns The most recent resume data, or undefined if none.
61
+ */
62
+ getLastResumeData(): unknown;
63
+ /**
64
+ * Begin executing the workflow from the first step.
65
+ * Returns a status object describing whether execution finished, suspended, or failed.
66
+ *
67
+ * @param args Input payload and context to seed execution.
68
+ * @returns Execution result including status and snapshot.
69
+ */
70
+ start(args: RunnerStartArgs): Promise<StartResult>;
71
+ /**
72
+ * Resume a previously suspended workflow using the supplied resume data.
73
+ *
74
+ * @param args Data provided to resume the suspended step.
75
+ * @returns Execution result including status and snapshot.
76
+ */
77
+ resume(args: RunnerResumeArgs): Promise<ResumeResult>;
78
+ /**
79
+ * Execute the provided workflow operation and normalize suspension, finish, and failure handling.
80
+ *
81
+ * @param execute Function that advances workflow execution and may return a suspension.
82
+ * @returns Result of the execution attempt.
83
+ */
84
+ private runExecution;
85
+ /**
86
+ * Rebuild a runner from persisted state, allowing hosts to resume after restarts.
87
+ *
88
+ * @param compiled The compiled workflow definition.
89
+ * @param options Persisted state and metadata needed to rebuild the runner.
90
+ * @returns A runner positioned to continue from the prior suspension or status.
91
+ */
92
+ static fromPersistedState(compiled: CompiledWorkflow, options: {
93
+ state: ExecutionState;
94
+ context: BaseWorkflowContext;
95
+ snapshot: WorkflowSnapshot;
96
+ suspension?: PersistedSuspension;
97
+ runId?: string;
98
+ lastResumeData?: unknown;
99
+ }): Promise<WorkflowRunner>;
100
+ /**
101
+ * Emit an event if an emitter is provided.
102
+ *
103
+ * @param event The event name to emit.
104
+ * @param payload The event payload.
105
+ */
106
+ private emit;
107
+ /**
108
+ * Evaluate and map the workflow outputs after all steps have completed.
109
+ * Throws if the internal state or context were not initialized.
110
+ *
111
+ * @returns The evaluated workflow outputs.
112
+ * @throws When state or context are missing.
113
+ */
114
+ private evaluateWorkflowOutputs;
115
+ /**
116
+ * Build a stable step id that reflects the current loop iteration stack.
117
+ *
118
+ * @param step The compiled step to annotate.
119
+ * @param iterationStack The loop stack representing nested iterations.
120
+ * @returns A step info object with an iteration-aware id.
121
+ */
122
+ private buildInstanceStepInfo;
123
+ /**
124
+ * Record an action snapshot for the given step id.
125
+ *
126
+ * @param step The step being updated.
127
+ * @param status The new snapshot status.
128
+ * @param reason Optional reason to include when marking failure/suspension.
129
+ */
130
+ private markSnapshot;
131
+ /**
132
+ * Record a detailed execution entry for the given step.
133
+ *
134
+ * @param step The step being updated.
135
+ * @param update Partial record fields to merge into the log.
136
+ */
137
+ private recordStepExecution;
138
+ /**
139
+ * Construct the environment object passed to step executors.
140
+ *
141
+ * @returns A step executor environment bound to this runner.
142
+ * @throws When the workflow context is missing.
143
+ */
144
+ private createExecutorEnv;
145
+ /**
146
+ * Build dependencies used to reconstruct a suspension from persisted state.
147
+ *
148
+ * @returns Dependency bag for suspension rebuilders.
149
+ */
150
+ private createSuspensionRebuilderDeps;
151
+ /**
152
+ * Walk a list of compiled steps, threading state and returning a suspension when encountered.
153
+ *
154
+ * @param steps The steps to execute sequentially.
155
+ * @param state Mutable execution state shared across steps.
156
+ * @param path Path tokens leading to the current step for tracing.
157
+ * @param startIndex Index to resume from within the flow.
158
+ * @returns A suspension if execution pauses, otherwise void.
159
+ */
160
+ private executeFlow;
161
+ /**
162
+ * Execute a single compiled step by delegating to its executor.
163
+ *
164
+ * @param step The step to run.
165
+ * @param state The shared execution state.
166
+ * @param path Tokens describing the location of the step in the workflow.
167
+ * @returns A suspension if the step pauses execution, otherwise void.
168
+ */
169
+ private executeStep;
170
+ /**
171
+ * Store the raw task result under the task name in the workflow output state.
172
+ * @reviewed
173
+ * @param task The task whose output is being captured.
174
+ * @param state Current execution state to mutate.
175
+ * @param result Raw result returned by the task action.
176
+ */
177
+ private captureTaskOutput;
178
+ }
179
+ //# sourceMappingURL=workflow-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-runner.d.ts","sourceRoot":"","sources":["../../src/workflow-runner.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAGV,mBAAmB,EACnB,m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E,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC;IAiB3D;;;;;OAKG;YACW,YAAY;IAkD1B;;;;;;OAMG;WACU,kBAAkB,CAC7B,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE;QACP,KAAK,EAAE,cAAc,CAAC;QACtB,OAAO,EAAE,mBAAmB,CAAC;QAC7B,QAAQ,EAAE,gBAAgB,CAAC;QAC3B,UAAU,CAAC,EAAE,mBAAmB,CAAC;QACjC,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,GACA,OAAO,CAAC,cAAc,CAAC;IAgD1B;;;;;OAKG;IACH,OAAO,CAAC,IAAI;IAOZ;;;;;;OAMG;YACW,uBAAuB;IAYrC;;;;;;OAMG;IACH,OAAO,CAAC,qBAAqB;IAc7B;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;IASpB;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IA2B3B;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAqDzB;;;;OAIG;IACH,OAAO,CAAC,6BAA6B;IAkBrC;;;;;;;;OAQG;YACW,WAAW;IA8BzB;;;;;;;OAOG;YACW,WAAW;IAkBzB;;;;;;OAMG;YACW,iBAAiB;CAOhC"}
@@ -0,0 +1,195 @@
1
+ import type { Expression } from 'jsonata';
2
+ import type { ZodType } from 'zod';
3
+ import type { Action } from './action/action.types';
4
+ import type { CompiledTaskBindings } from './bindings/base-binding';
5
+ import type { BaseWorkflowContext, WorkflowSnapshot } from './context';
6
+ import type { Settings, TaskDefinition, WorkflowDefinition } from './dsl.types';
7
+ import { StepType, type StepInfo } from './workflow-event-emitter';
8
+ export type { CompiledTaskBindings } from './bindings/base-binding';
9
+ /** Value representation used by the runtime after compilation. */
10
+ export type CompiledValue = {
11
+ kind: 'literal';
12
+ value: unknown;
13
+ } | {
14
+ kind: 'expression';
15
+ source: string;
16
+ expression: Expression;
17
+ };
18
+ /** Map of variable names to compiled values. */
19
+ export type CompiledMapping = Record<string, CompiledValue>;
20
+ /** Fully resolved task with parsed settings and compiled IO mappings. */
21
+ export type CompiledTask = {
22
+ name: string;
23
+ definition: TaskDefinition;
24
+ actionName: string;
25
+ action: Action;
26
+ inputs: CompiledMapping;
27
+ settings: Settings;
28
+ bindings: CompiledTaskBindings;
29
+ };
30
+ /** Complete workflow ready for execution. */
31
+ export type CompiledWorkflow = {
32
+ definition: WorkflowDefinition;
33
+ tasks: Record<string, CompiledTask>;
34
+ flow: CompiledStep[];
35
+ outputMapping: CompiledMapping;
36
+ inputParser: ZodType<Record<string, unknown>>;
37
+ defaultSettings?: Settings;
38
+ };
39
+ /** Any executable step inside the compiled flow. */
40
+ export type CompiledStep = TaskStep | ParallelStep | ConditionalStep | LoopStep;
41
+ export type BaseStep = {
42
+ id: string;
43
+ label: string;
44
+ type: StepType;
45
+ };
46
+ /** Single task execution. */
47
+ export type TaskStep = BaseStep & {
48
+ type: StepType.Task;
49
+ taskName: string;
50
+ };
51
+ /** Runs nested steps with either wait-all or wait-any semantics. */
52
+ export type ParallelStep = BaseStep & {
53
+ type: StepType.Parallel;
54
+ description?: string;
55
+ strategy: 'wait_all' | 'wait_any';
56
+ steps: CompiledStep[];
57
+ };
58
+ /** Conditional branch tree describing when to run a step list. */
59
+ export type ConditionalBranch = {
60
+ id: string;
61
+ condition?: CompiledValue;
62
+ steps: CompiledStep[];
63
+ };
64
+ /** Conditional step with multiple branches. */
65
+ export type ConditionalStep = BaseStep & {
66
+ type: StepType.Conditional;
67
+ description?: string;
68
+ branches: ConditionalBranch[];
69
+ };
70
+ type BaseLoopStep = BaseStep & {
71
+ type: StepType.Loop;
72
+ name?: string;
73
+ description?: string;
74
+ accumulate?: {
75
+ as: string;
76
+ initial: unknown;
77
+ merge: CompiledValue;
78
+ };
79
+ steps: CompiledStep[];
80
+ };
81
+ /** Loop over items with optional post-iteration break condition. */
82
+ export type ForEachLoopStep = BaseLoopStep & {
83
+ loopType: 'for_each';
84
+ forEach: {
85
+ item: string;
86
+ in: CompiledValue;
87
+ };
88
+ maxConcurrency?: number;
89
+ until?: CompiledValue;
90
+ };
91
+ /** Classic while-loop evaluated before each iteration. */
92
+ export type WhileLoopStep = BaseLoopStep & {
93
+ loopType: 'while';
94
+ while: CompiledValue;
95
+ };
96
+ export type LoopStep = ForEachLoopStep | WhileLoopStep;
97
+ /** Scope passed to value evaluators, reflecting the live runtime state. */
98
+ export type EvaluationScope = {
99
+ input: Record<string, unknown>;
100
+ context: Record<string, unknown>;
101
+ output: Record<string, unknown>;
102
+ iteration?: {
103
+ item: unknown;
104
+ index: number;
105
+ };
106
+ accumulator?: unknown;
107
+ result?: unknown;
108
+ };
109
+ /** Minimal mutable state for the executor. */
110
+ export type ExecutionState = {
111
+ input: Record<string, unknown>;
112
+ output: Record<string, unknown>;
113
+ iteration?: {
114
+ item: unknown;
115
+ index: number;
116
+ };
117
+ accumulator?: unknown;
118
+ iterationStack: number[];
119
+ };
120
+ /** Encapsulates a suspended step and how to continue it. */
121
+ export type Suspension = {
122
+ step: StepInfo;
123
+ reason?: string;
124
+ data?: unknown;
125
+ stepExecId?: string;
126
+ suspendIndex?: number;
127
+ suspendKey?: string;
128
+ awaitResults?: Record<string, unknown>;
129
+ continue: (resumeData: unknown) => Promise<Suspension | void>;
130
+ };
131
+ export type PersistedSuspension = {
132
+ stepId: string;
133
+ reason?: string | null;
134
+ data?: unknown;
135
+ stepExecId?: string;
136
+ suspendIndex?: number;
137
+ suspendKey?: string;
138
+ awaitResults?: Record<string, unknown>;
139
+ };
140
+ /** Result of starting a workflow run. */
141
+ export type StartResult = {
142
+ status: 'finished';
143
+ output: Record<string, unknown>;
144
+ snapshot: WorkflowSnapshot;
145
+ } | {
146
+ status: 'suspended';
147
+ step: StepInfo;
148
+ reason?: string;
149
+ data?: unknown;
150
+ stepExecId?: string;
151
+ suspendIndex?: number;
152
+ suspendKey?: string;
153
+ awaitResults?: Record<string, unknown>;
154
+ snapshot: WorkflowSnapshot;
155
+ } | {
156
+ status: 'failed';
157
+ error: unknown;
158
+ snapshot: WorkflowSnapshot;
159
+ };
160
+ /** Result of resuming a suspended workflow. */
161
+ export type ResumeResult = {
162
+ status: 'finished';
163
+ output: Record<string, unknown>;
164
+ snapshot: WorkflowSnapshot;
165
+ } | {
166
+ status: 'suspended';
167
+ step: StepInfo;
168
+ reason?: string;
169
+ data?: unknown;
170
+ stepExecId?: string;
171
+ suspendIndex?: number;
172
+ suspendKey?: string;
173
+ awaitResults?: Record<string, unknown>;
174
+ snapshot: WorkflowSnapshot;
175
+ } | {
176
+ status: 'failed';
177
+ error: unknown;
178
+ snapshot: WorkflowSnapshot;
179
+ };
180
+ /** Options that influence how the workflow runner behaves. */
181
+ export type WorkflowRunOptions = {
182
+ runId?: string;
183
+ };
184
+ export type WorkflowStartResult = StartResult;
185
+ export type WorkflowResumeResult = ResumeResult;
186
+ /** Arguments required to start a run. */
187
+ export type RunnerStartArgs = {
188
+ inputData: unknown;
189
+ context: BaseWorkflowContext;
190
+ };
191
+ /** Payload passed when resuming a suspended run. */
192
+ export type RunnerResumeArgs = {
193
+ resumeData?: unknown;
194
+ };
195
+ //# sourceMappingURL=workflow-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-types.d.ts","sourceRoot":"","sources":["../../src/workflow-types.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAA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ErE,+CAA+C;AAC/C,MAAM,MAAM,YAAY,GACpB;IACE,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,GACD;IACE,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,GACD;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAErE,8DAA8D;AAC9D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAAC;AAE9C,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAEhD,yCAAyC;AACzC,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,mBAAmB,CAAC;CAC9B,CAAC;AAEF,oDAAoD;AACpD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { Focus } from 'jsonata';
2
+ import type { Settings } from './dsl.types';
3
+ import type { CompiledMapping, CompiledValue, EvaluationScope } from './workflow-types';
4
+ export type JsonataFunctionImplementation = (this: Focus, ...args: any[]) => unknown;
5
+ export type JsonataFunctionConfig = JsonataFunctionImplementation | {
6
+ implementation: JsonataFunctionImplementation;
7
+ signature?: string;
8
+ };
9
+ export type JsonataFunctionRegistry = Record<string, JsonataFunctionConfig>;
10
+ export type CompileValueOptions = {
11
+ jsonataFunctions?: JsonataFunctionRegistry;
12
+ };
13
+ /**
14
+ * Prepares a workflow value for evaluation.
15
+ * Strings prefixed with `=` are treated as JSONata expressions; everything else is a literal.
16
+ */
17
+ export declare const compileValue: (value: unknown, options?: CompileValueOptions) => CompiledValue;
18
+ /**
19
+ * Evaluate a compiled value against the current workflow scope.
20
+ * Expressions are executed via JSONata with the scope exposed as variables; `context`
21
+ * represents the workflow context state, not the context instance itself.
22
+ */
23
+ export declare const evaluateValue: (compiled: CompiledValue, scope: EvaluationScope) => Promise<unknown>;
24
+ /**
25
+ * Evaluate all entries of a compiled mapping, returning a plain object.
26
+ * Missing mappings resolve to an empty object.
27
+ */
28
+ export declare const evaluateMapping: (mapping: CompiledMapping | undefined, scope: EvaluationScope) => Promise<Record<string, unknown>>;
29
+ /**
30
+ * Deep-merge workflow settings, preferring non-undefined overrides.
31
+ * Nested objects are merged recursively to preserve defaults.
32
+ */
33
+ export declare const mergeSettings: (base?: Partial<Settings>, override?: Partial<Settings>) => Partial<Settings>;
34
+ //# sourceMappingURL=workflow-values.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-values.d.ts","sourceRoot":"","sources":["../../src/workflow-values.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAc,KAAK,EAAE,MAAM,SAAS,CAAC;AAGjD,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACb,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,6BAA6B,GAAG,CAC1C,IAAI,EAAE,KAAK,EACX,GAAG,IAAI,EAAE,GAAG,EAAE,KACX,OAAO,CAAC;AAEb,MAAM,MAAM,qBAAqB,GAC7B,6BAA6B,GAC7B;IACE,cAAc,EAAE,6BAA6B,CAAC;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEN,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;AAE5E,MAAM,MAAM,mBAAmB,GAAG;IAChC,gBAAgB,CAAC,EAAE,uBAAuB,CAAC;CAC5C,CAAC;AAgCF;;;GAGG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,OAAO,EACd,UAAU,mBAAmB,KAC5B,aASF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,UAAU,aAAa,EACvB,OAAO,eAAe,KACrB,OAAO,CAAC,OAAO,CAgBjB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,eAAe,GAAG,SAAS,EACpC,OAAO,eAAe,KACrB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO,OAAO,CAAC,QAAQ,CAAC,EACxB,WAAW,OAAO,CAAC,QAAQ,CAAC,KAC3B,OAAO,CAAC,QAAQ,CAsBlB,CAAC"}
@@ -0,0 +1,75 @@
1
+ import type { BaseWorkflowContext, WorkflowSnapshot } from './context';
2
+ import { WorkflowDefinition, type FlowStep } from './dsl.types';
3
+ import { type WorkflowCompileOptions } from './workflow-compiler';
4
+ import { WorkflowRunner } from './workflow-runner';
5
+ import type { ExecutionState, PersistedSuspension, WorkflowRunOptions } from './workflow-types';
6
+ export { compileWorkflow } from './workflow-compiler';
7
+ export { WorkflowEventEmitter } from './workflow-event-emitter';
8
+ export { WorkflowRunner } from './workflow-runner';
9
+ export type { WorkflowResumeResult, WorkflowRunOptions, WorkflowStartResult, } from './workflow-types';
10
+ export type { WorkflowCompileOptions } from './workflow-compiler';
11
+ export type FlowStepPath = Array<string | number>;
12
+ /**
13
+ * Entry point for preparing and executing workflows from YAML or object definitions.
14
+ * Instances are thin wrappers around a compiled workflow graph.
15
+ */
16
+ export declare class Workflow {
17
+ private readonly compiled;
18
+ private constructor();
19
+ /**
20
+ * Create a workflow from an already parsed definition.
21
+ * The definition is validated before compilation to catch schema issues early.
22
+ */
23
+ static fromDefinition(definition: WorkflowDefinition, options: WorkflowCompileOptions): Workflow;
24
+ /**
25
+ * Create a workflow from YAML source.
26
+ * YAML is validated and compiled before being wrapped in a {@link Workflow} instance.
27
+ */
28
+ static fromYaml(yaml: string, options: WorkflowCompileOptions): Workflow;
29
+ /**
30
+ * Convert a workflow definition to YAML.
31
+ * The definition is validated before serialization.
32
+ */
33
+ static stringifyDefinition(definition: WorkflowDefinition): string;
34
+ /**
35
+ * Resolve a nested value from a workflow definition by path.
36
+ */
37
+ static getValueAtPath(value: unknown, path: FlowStepPath): unknown;
38
+ /**
39
+ * Create a new value with a nested path updated immutably.
40
+ */
41
+ static setValueAtPath<T>(value: T, path: FlowStepPath, nextValue: unknown): T;
42
+ /**
43
+ * Remove a flow step from the definition at the given path, if valid.
44
+ */
45
+ static removeStepAtPath(definition: WorkflowDefinition, stepPath: FlowStepPath): WorkflowDefinition | null;
46
+ /**
47
+ * Insert a flow step into the definition at the given path, if valid.
48
+ */
49
+ static insertStepAtPath(definition: WorkflowDefinition, insertPath: FlowStepPath, step: FlowStep): WorkflowDefinition | null;
50
+ /**
51
+ * Rename a task key and update references in flow steps and output expressions.
52
+ */
53
+ static safeRenameTaskInDefinition(definition: WorkflowDefinition, currentTaskName: string, nextTaskName: string): WorkflowDefinition;
54
+ /**
55
+ * Run the workflow until completion or suspension.
56
+ * Throws when a task suspends so callers can capture the state.
57
+ */
58
+ run(inputData: unknown, context: BaseWorkflowContext, options?: WorkflowRunOptions): Promise<Record<string, unknown>>;
59
+ /**
60
+ * Construct a runner without executing, allowing hosts to manage start/resume manually.
61
+ */
62
+ buildAsyncRunner(options?: WorkflowRunOptions): Promise<WorkflowRunner>;
63
+ /**
64
+ * Rebuild a runner from persisted state and snapshot, useful after restarts.
65
+ */
66
+ buildRunnerFromState(options: {
67
+ state: ExecutionState;
68
+ context: BaseWorkflowContext;
69
+ snapshot: WorkflowSnapshot;
70
+ suspension?: PersistedSuspension;
71
+ runId?: string;
72
+ lastResumeData?: unknown;
73
+ }): Promise<WorkflowRunner>;
74
+ }
75
+ //# sourceMappingURL=workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/workflow.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAEL,kBAAkB,EAGlB,KAAK,QAAQ,EACd,MAAM,aAAa,CAAC;AAErB,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAEV,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,YAAY,EACV,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;AAqDlD;;;GAGG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmB;IAE5C,OAAO;IAIP;;;OAGG;IACH,MAAM,CAAC,cAAc,CACnB,UAAU,EAAE,kBAAkB,EAC9B,OAAO,EAAE,sBAAsB,GAC9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