@hexabot-ai/agentic 3.4.0 → 3.5.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 (134) hide show
  1. package/README.md +67 -15
  2. package/dist/cjs/action/abstract-action.js +13 -1
  3. package/dist/cjs/checkpoint.js +301 -0
  4. package/dist/cjs/context.js +11 -27
  5. package/dist/cjs/dsl.types.js +3 -0
  6. package/dist/cjs/errors.js +116 -9
  7. package/dist/cjs/index.js +15 -6
  8. package/dist/cjs/resume-payload.js +257 -0
  9. package/dist/cjs/runner-runtime-control.js +181 -306
  10. package/dist/cjs/step-executors/conditional-executor.js +27 -29
  11. package/dist/cjs/step-executors/loop-executor.js +53 -62
  12. package/dist/cjs/step-executors/parallel-executor.js +169 -102
  13. package/dist/cjs/step-executors/task-executor.js +180 -96
  14. package/dist/cjs/utils/clone.js +73 -0
  15. package/dist/cjs/workflow-fingerprint.js +138 -0
  16. package/dist/cjs/workflow-runner.js +220 -155
  17. package/dist/cjs/workflow.js +24 -12
  18. package/dist/esm/action/abstract-action.js +14 -2
  19. package/dist/esm/checkpoint.js +293 -0
  20. package/dist/esm/context.js +11 -27
  21. package/dist/esm/dsl.types.js +3 -0
  22. package/dist/esm/errors.js +105 -6
  23. package/dist/esm/index.js +3 -3
  24. package/dist/esm/resume-payload.js +250 -0
  25. package/dist/esm/runner-runtime-control.js +179 -303
  26. package/dist/esm/step-executors/conditional-executor.js +27 -29
  27. package/dist/esm/step-executors/loop-executor.js +53 -62
  28. package/dist/esm/step-executors/parallel-executor.js +165 -98
  29. package/dist/esm/step-executors/task-executor.js +181 -97
  30. package/dist/esm/utils/clone.js +67 -0
  31. package/dist/esm/workflow-fingerprint.js +134 -0
  32. package/dist/esm/workflow-runner.js +220 -155
  33. package/dist/esm/workflow.js +24 -12
  34. package/dist/types/action/abstract-action.d.ts.map +1 -1
  35. package/dist/types/action/action.types.d.ts +0 -14
  36. package/dist/types/action/action.types.d.ts.map +1 -1
  37. package/dist/types/checkpoint.d.ts +188 -0
  38. package/dist/types/checkpoint.d.ts.map +1 -0
  39. package/dist/types/context.d.ts +45 -11
  40. package/dist/types/context.d.ts.map +1 -1
  41. package/dist/types/dsl.types.d.ts.map +1 -1
  42. package/dist/types/errors.d.ts +77 -3
  43. package/dist/types/errors.d.ts.map +1 -1
  44. package/dist/types/index.d.ts +6 -7
  45. package/dist/types/index.d.ts.map +1 -1
  46. package/dist/types/resume-payload.d.ts +69 -0
  47. package/dist/types/resume-payload.d.ts.map +1 -0
  48. package/dist/types/runner-runtime-control.d.ts +63 -51
  49. package/dist/types/runner-runtime-control.d.ts.map +1 -1
  50. package/dist/types/step-executors/conditional-executor.d.ts +6 -3
  51. package/dist/types/step-executors/conditional-executor.d.ts.map +1 -1
  52. package/dist/types/step-executors/loop-executor.d.ts +6 -4
  53. package/dist/types/step-executors/loop-executor.d.ts.map +1 -1
  54. package/dist/types/step-executors/parallel-executor.d.ts +11 -3
  55. package/dist/types/step-executors/parallel-executor.d.ts.map +1 -1
  56. package/dist/types/step-executors/task-executor.d.ts +11 -4
  57. package/dist/types/step-executors/task-executor.d.ts.map +1 -1
  58. package/dist/types/step-executors/types.d.ts +21 -13
  59. package/dist/types/step-executors/types.d.ts.map +1 -1
  60. package/dist/types/utils/clone.d.ts +33 -0
  61. package/dist/types/utils/clone.d.ts.map +1 -0
  62. package/dist/types/workflow-event-emitter.d.ts +29 -5
  63. package/dist/types/workflow-event-emitter.d.ts.map +1 -1
  64. package/dist/types/workflow-fingerprint.d.ts +14 -0
  65. package/dist/types/workflow-fingerprint.d.ts.map +1 -0
  66. package/dist/types/workflow-runner.d.ts +83 -41
  67. package/dist/types/workflow-runner.d.ts.map +1 -1
  68. package/dist/types/workflow-types.d.ts +25 -54
  69. package/dist/types/workflow-types.d.ts.map +1 -1
  70. package/dist/types/workflow.d.ts +24 -9
  71. package/dist/types/workflow.d.ts.map +1 -1
  72. package/examples/defs-bindings-agent/bindings.ts +1 -1
  73. package/examples/defs-bindings-agent/workflow.ts +3 -2
  74. package/examples/full/actions/await-user-input.ts +3 -2
  75. package/examples/full/actions/call-llm.ts +18 -18
  76. package/examples/full/actions/create-ticket.ts +1 -2
  77. package/examples/full/actions/decision-router.ts +6 -2
  78. package/examples/full/actions/get-calendar-events.ts +1 -2
  79. package/examples/full/actions/get-user-profile.ts +1 -2
  80. package/examples/full/actions/query-memory.ts +1 -2
  81. package/examples/full/actions/search-web.ts +1 -2
  82. package/examples/full/actions/send-email.ts +3 -2
  83. package/examples/full/workflow.ts +3 -2
  84. package/examples/loop/actions/await-reply.ts +2 -7
  85. package/examples/loop/workflow.ts +4 -2
  86. package/examples/suspend-resume/actions/wait-for-user.ts +11 -9
  87. package/examples/suspend-resume/workflow.ts +51 -11
  88. package/package.json +3 -3
  89. package/src/__tests__/checkpoint.test.ts +2568 -0
  90. package/src/__tests__/resume-payload.test.ts +245 -0
  91. package/src/__tests__/runner-runtime-control.test.ts +265 -0
  92. package/src/__tests__/workflow-fingerprint.test.ts +165 -0
  93. package/src/__tests__/workflow-runner.test.ts +167 -144
  94. package/src/__tests__/workflow.test.ts +97 -6
  95. package/src/action/abstract-action.ts +21 -2
  96. package/src/action/action.types.ts +0 -12
  97. package/src/checkpoint.ts +561 -0
  98. package/src/context.ts +51 -41
  99. package/src/dsl.types.ts +3 -0
  100. package/src/errors.ts +161 -8
  101. package/src/index.ts +33 -14
  102. package/src/resume-payload.ts +326 -0
  103. package/src/runner-runtime-control.ts +222 -456
  104. package/src/step-executors/conditional-executor.test.ts +77 -46
  105. package/src/step-executors/conditional-executor.ts +47 -40
  106. package/src/step-executors/loop-executor.test.ts +106 -92
  107. package/src/step-executors/loop-executor.ts +84 -101
  108. package/src/step-executors/parallel-executor.test.ts +300 -89
  109. package/src/step-executors/parallel-executor.ts +243 -125
  110. package/src/step-executors/task-executor.test.ts +321 -51
  111. package/src/step-executors/task-executor.ts +232 -145
  112. package/src/step-executors/types.ts +23 -22
  113. package/src/utils/clone.ts +75 -0
  114. package/src/workflow-event-emitter.ts +32 -6
  115. package/src/workflow-fingerprint.ts +159 -0
  116. package/src/workflow-runner.ts +325 -209
  117. package/src/workflow-types.ts +25 -56
  118. package/src/workflow.ts +41 -34
  119. package/dist/cjs/step-executors/suspension-continuation.js +0 -27
  120. package/dist/cjs/suspension-rebuilder.js +0 -265
  121. package/dist/cjs/utils/deferred.js +0 -17
  122. package/dist/esm/step-executors/suspension-continuation.js +0 -24
  123. package/dist/esm/suspension-rebuilder.js +0 -260
  124. package/dist/esm/utils/deferred.js +0 -14
  125. package/dist/types/step-executors/suspension-continuation.d.ts +0 -10
  126. package/dist/types/step-executors/suspension-continuation.d.ts.map +0 -1
  127. package/dist/types/suspension-rebuilder.d.ts +0 -67
  128. package/dist/types/suspension-rebuilder.d.ts.map +0 -1
  129. package/dist/types/utils/deferred.d.ts +0 -7
  130. package/dist/types/utils/deferred.d.ts.map +0 -1
  131. package/src/__tests__/suspension-rebuilder.test.ts +0 -404
  132. package/src/step-executors/suspension-continuation.ts +0 -31
  133. package/src/suspension-rebuilder.ts +0 -446
  134. package/src/utils/deferred.ts +0 -23
@@ -0,0 +1,188 @@
1
+ import { z } from 'zod';
2
+ import { WorkflowResumeError } from './errors';
3
+ import { type StepInfo } from './workflow-event-emitter';
4
+ import type { CompiledStep, CompiledWorkflow } from './workflow-types';
5
+ /** Current format version of {@link WorkflowCheckpoint}. */
6
+ export declare const CHECKPOINT_VERSION = 1;
7
+ /** One open suspension a run is waiting on. */
8
+ export type WaitInfo = {
9
+ /**
10
+ * Handle a host passes to `resume()` to satisfy this wait. Opaque: unique
11
+ * within a run and stable for as long as the wait is open, but never meant
12
+ * to be parsed.
13
+ */
14
+ waitId: string;
15
+ /** Instance step (loop iterations included) that suspended. */
16
+ step: StepInfo;
17
+ /** Normalized suspend point inside the step body (`index:<n>` or `key:<k>`). */
18
+ suspendKey: string;
19
+ reason?: string;
20
+ data?: unknown;
21
+ /**
22
+ * JSON Schema of the payload the wait accepts, in its JSON form, when
23
+ * `suspend()` was given an `accepts` schema. It is relaxed so that it never
24
+ * refuses a JSON payload the action would accept; the action's schema still
25
+ * has the final say.
26
+ */
27
+ accepts?: Record<string, unknown>;
28
+ /**
29
+ * Set when the `accepts` schema also accepts a resume without payload,
30
+ * which JSON Schema cannot express: `accepts` describes a payload that is
31
+ * given.
32
+ */
33
+ payloadOptional?: boolean;
34
+ };
35
+ /**
36
+ * Answer recorded for one `suspend()` call. The value is wrapped so that a
37
+ * resume without payload, whose value is `undefined`, is still recorded as
38
+ * answered once JSON drops the value.
39
+ */
40
+ export type RecordedResult = {
41
+ value?: unknown;
42
+ };
43
+ /**
44
+ * Suspended task: the only frame that runs code on resume. Its body re-runs
45
+ * with `inputs`, and every `suspend()` call already answered in
46
+ * `awaitResults` resolves immediately.
47
+ */
48
+ export type TaskFrame = {
49
+ kind: 'task';
50
+ stepId: string;
51
+ inputs: Record<string, unknown>;
52
+ /** Answers of the body's earlier `suspend()` calls, by suspend key. */
53
+ awaitResults: Record<string, RecordedResult>;
54
+ wait: WaitInfo;
55
+ };
56
+ /** Conditional whose chosen branch suspended; conditions are not re-evaluated. */
57
+ export type ConditionalFrame = {
58
+ kind: 'conditional';
59
+ stepId: string;
60
+ branchIndex: number;
61
+ child: SequenceFrame;
62
+ };
63
+ /** Loop suspended inside iteration `index`. */
64
+ export type LoopFrame = {
65
+ kind: 'loop';
66
+ stepId: string;
67
+ index: number;
68
+ /** Items resolved when a `for_each` loop started; absent for `while`. */
69
+ items?: unknown[];
70
+ /** Accumulator value at the start of iteration `index`. */
71
+ accumulator?: unknown;
72
+ child: SequenceFrame;
73
+ };
74
+ /** Settled state of one parallel branch when the block suspended. */
75
+ export type ParallelBranchFrame = {
76
+ status: 'fulfilled';
77
+ outputDelta: Record<string, unknown>;
78
+ } | {
79
+ status: 'suspended';
80
+ outputDelta: Record<string, unknown>;
81
+ child: StepFrame;
82
+ };
83
+ /** Parallel block with at least one suspended branch. */
84
+ export type ParallelFrame = {
85
+ kind: 'parallel';
86
+ stepId: string;
87
+ branches: ParallelBranchFrame[];
88
+ };
89
+ /** Frame of a single compiled step. `stepId` is the compiled (not instance) id. */
90
+ export type StepFrame = TaskFrame | ConditionalFrame | LoopFrame | ParallelFrame;
91
+ /** Position inside a list of sequential steps. */
92
+ export type SequenceFrame = {
93
+ kind: 'sequence';
94
+ index: number;
95
+ /**
96
+ * `$accumulator` of the sequence's scope when it suspended. A loop that
97
+ * finished earlier in the sequence may have replaced the one the scope
98
+ * started with.
99
+ */
100
+ accumulator?: unknown;
101
+ child: StepFrame;
102
+ };
103
+ /**
104
+ * Everything needed to resume a suspended run, in any process.
105
+ *
106
+ * The frame tree mirrors the compiled flow: each composite step records only
107
+ * the local state it needs to continue (sequence position, chosen branch,
108
+ * loop position, parallel branch outcomes), so resuming never replays work
109
+ * that already completed.
110
+ */
111
+ export type WorkflowCheckpoint = {
112
+ version: typeof CHECKPOINT_VERSION;
113
+ /** Definition fingerprint the frames were taken against. */
114
+ fingerprint: string;
115
+ input: Record<string, unknown>;
116
+ output: Record<string, unknown>;
117
+ root: SequenceFrame;
118
+ /** Every open wait in the frame tree, in flow order. */
119
+ waits: WaitInfo[];
120
+ };
121
+ export type CheckpointValidationResult = {
122
+ ok: true;
123
+ checkpoint: WorkflowCheckpoint;
124
+ } | {
125
+ ok: false;
126
+ error: WorkflowResumeError;
127
+ };
128
+ /** Schema of a persisted {@link WorkflowCheckpoint}, for hosts to type storage. */
129
+ export declare const workflowCheckpointSchema: z.ZodType<WorkflowCheckpoint>;
130
+ /**
131
+ * Build the handle of a wait from the instance step that suspended and its
132
+ * suspend key.
133
+ *
134
+ * @param stepInstanceId Instance step id, including any loop iteration suffix.
135
+ * @param suspendKey Normalized suspend key within the step body.
136
+ * @returns The wait id.
137
+ */
138
+ export declare const buildWaitId: (stepInstanceId: string, suspendKey: string) => string;
139
+ /**
140
+ * List the open waits held by a frame tree, in flow order.
141
+ *
142
+ * @param frame Root or subtree of a checkpoint.
143
+ * @returns The waits of every suspended task under the frame.
144
+ */
145
+ export declare function collectWaits(frame: SequenceFrame | StepFrame): WaitInfo[];
146
+ /**
147
+ * Pick the wait a resume targets. `resume()` and `validateCheckpoint` both
148
+ * use it, so a payload is always checked against the wait it would resolve.
149
+ *
150
+ * @param waits Open waits of the suspended run.
151
+ * @param waitId Requested wait, optional when exactly one wait is open.
152
+ * @returns The targeted wait.
153
+ * @throws {WorkflowWaitNotFoundError} When `waitId` is not an open wait.
154
+ * @throws {WorkflowWaitAmbiguousError} When several waits are open and no
155
+ * `waitId` is given.
156
+ */
157
+ export declare function selectWait(waits: WaitInfo[], waitId?: string): WaitInfo;
158
+ /**
159
+ * Check that a frame was taken for the given compiled step.
160
+ *
161
+ * @param frame The frame about to be resumed, if any.
162
+ * @param step The compiled step it is being handed to.
163
+ * @param path Location used in the error message.
164
+ * @throws {WorkflowCheckpointInvalidError} When the frame belongs elsewhere.
165
+ */
166
+ export declare function assertFrameMatchesStep(frame: StepFrame | undefined, step: CompiledStep, path?: Array<string | number>): void;
167
+ /**
168
+ * Decide whether a checkpoint can resume against a compiled workflow, without
169
+ * running anything.
170
+ *
171
+ * Checks, in order: presence and shape, format version, definition
172
+ * fingerprint, that every frame lines up with the compiled step it names, that
173
+ * the `waits` index matches the frame tree, and (optionally) that a given wait
174
+ * is open and accepts a given payload.
175
+ *
176
+ * @param compiled The compiled workflow the run will resume against.
177
+ * @param checkpoint The persisted checkpoint, as stored.
178
+ * @param options.waitId Wait the caller is about to resume.
179
+ * @param options.resumeData Payload the caller is about to resume with. When
180
+ * the key is present, it is checked against the wait `resume()` would pick:
181
+ * the one named by `waitId`, or the only open wait.
182
+ * @returns The parsed checkpoint, or the typed reason it cannot resume.
183
+ */
184
+ export declare function validateCheckpoint(compiled: CompiledWorkflow, checkpoint: unknown, options?: {
185
+ waitId?: string;
186
+ resumeData?: unknown;
187
+ }): CheckpointValidationResult;
188
+ //# sourceMappingURL=checkpoint.d.ts.map
@@ -0,0 +1 @@
1
+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import type { ZodType } from 'zod';
1
2
  import type { EventEmitterLike, WorkflowEventEmitterLike } from './workflow-event-emitter';
2
3
  /**
3
4
  * Lifecycle of a workflow run:
@@ -5,7 +6,7 @@ import type { EventEmitterLike, WorkflowEventEmitterLike } from './workflow-even
5
6
  * - running: set when `start` or `resume` begins executing steps.
6
7
  * - suspended: an action awaited `workflow.suspend`; `resume` moves back to running.
7
8
  * - finished: all steps completed and outputs were evaluated successfully.
8
- * - failed: an uncaught error bubbled out of a step or continuation.
9
+ * - failed: an uncaught error bubbled out of a step or the output mapping.
9
10
  */
10
11
  export declare enum EWorkflowRunStatus {
11
12
  IDLE = "idle",
@@ -27,10 +28,22 @@ export declare const WORKFLOW_RUN_STATUSES: WorkflowRunStatus[];
27
28
  * - skipped: control flow bypassed the step (e.g., alternate branch or wait_any short-circuit).
28
29
  */
29
30
  export type ActionStatus = 'pending' | 'running' | 'suspended' | 'completed' | 'failed' | 'cancelled' | 'skipped';
30
- export interface SuspensionOptions {
31
+ export interface SuspensionOptions<T = unknown> {
31
32
  key?: string;
32
33
  reason?: string;
33
34
  data?: unknown;
35
+ /**
36
+ * Schema the resume payload must match. It is stored on the wait as a
37
+ * relaxed JSON Schema, so hosts can refuse a bad payload before resuming,
38
+ * and the payload `suspend()` resolves with is parsed through it. A payload
39
+ * that fails it is refused and the wait stays open.
40
+ *
41
+ * The payload is parsed in its JSON form, as the checkpoint stores it: a
42
+ * `Date` arrives as its ISO string. `suspend()` throws when part of the
43
+ * schema is a type JSON cannot carry, such as `z.date()`; accept the JSON
44
+ * form instead, e.g. `z.coerce.date()` or `z.iso.datetime()`.
45
+ */
46
+ accepts?: ZodType<T>;
34
47
  }
35
48
  export interface ActionSnapshot {
36
49
  id: string;
@@ -62,20 +75,22 @@ export interface WorkflowSnapshot {
62
75
  actions: Record<string, ActionSnapshot>;
63
76
  }
64
77
  export interface WorkflowRuntimeControl {
65
- readonly status: WorkflowRunStatus;
66
- readonly resumeData: unknown;
67
78
  /**
68
79
  * Suspends the currently running action and returns a promise that settles when the workflow resumes.
69
80
  *
70
81
  * @param options - Optional metadata describing why the suspension occurred.
71
- * @returns Promise resolved with the data supplied to {@link resume}.
82
+ * @returns Promise resolved with the JSON copy of the payload the run was
83
+ * resumed with, or `undefined` when it was resumed without one; parsed
84
+ * through `options.accepts` when given. It rejects with a
85
+ * `WorkflowResumeRejectedError` when that payload fails `options.accepts`.
86
+ * @throws {TypeError} When `options.accepts` uses a type JSON cannot carry.
72
87
  */
73
- suspend<T = unknown>(options?: SuspensionOptions): Promise<T>;
88
+ suspend<T = unknown>(options?: SuspensionOptions<T>): Promise<T>;
74
89
  /**
75
90
  * Reports whether the next {@link suspend} call in the currently running
76
- * action already has a recorded resume result. This happens during
77
- * deterministic replay of a resumed step: the action body re-executes and
78
- * `suspend()` resolves immediately with the recorded payload. Actions that
91
+ * action already has a recorded resume result. This happens when a resumed
92
+ * step re-runs its action body from the top: `suspend()` calls it already
93
+ * made resolve immediately with their recorded payloads. Actions that
79
94
  * perform side effects before suspending must skip those side effects when
80
95
  * this returns `true`, otherwise they run once per resume.
81
96
  *
@@ -83,8 +98,21 @@ export interface WorkflowRuntimeControl {
83
98
  * @returns `true` when the upcoming suspension resolves from a recorded result.
84
99
  */
85
100
  hasRecordedResult(key?: string): boolean;
86
- resume(data?: unknown): void;
87
- getSnapshot(): WorkflowSnapshot;
101
+ /**
102
+ * Record where the running step's suspend cursor stands, before an action
103
+ * run starts its attempts.
104
+ *
105
+ * Suspend keys are positional within a body, so whoever retries a body
106
+ * must rewind the cursor before each attempt: the retry then reproduces the
107
+ * keys of the first attempt and resolves from the recorded results, instead
108
+ * of suspending on new ones. {@link AbstractAction} does this; an action
109
+ * with its own retry loop should too. The rewind point is where the run
110
+ * started, so an action run nested inside a body never rewinds the body.
111
+ *
112
+ * @returns A function rewinding the cursor to the recorded position. It
113
+ * does nothing once the step has ended.
114
+ */
115
+ markSuspendCursor?(): () => void;
88
116
  }
89
117
  /**
90
118
  * Base context that is threaded through every workflow execution.
@@ -115,6 +143,12 @@ export declare abstract class BaseWorkflowContext<S extends Record<string, unkno
115
143
  * @throws Error when the context is not currently attached to a runner.
116
144
  */
117
145
  get workflow(): WorkflowRuntimeControl;
146
+ /**
147
+ * Reads the runtime control without throwing when none is attached.
148
+ *
149
+ * @returns The attached runtime control, or `undefined` outside a run.
150
+ */
151
+ getWorkflowRuntime(): WorkflowRuntimeControl | undefined;
118
152
  /**
119
153
  * Attaches or detaches the runtime control object.
120
154
  *
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,0BAA0B,CAAC;AAElC;;;;;;;GAOG;AACH,oBAAY,kBAAkB;IAC5B,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,iBAAiB,GAAG,GAAG,kBAAkB,EAAE,CAAC;AAExD,eAAO,MAAM,qBAAqB,EAAE,iBAAiB,EAMpD,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,SAAS,GACT,WAAW,GACX,WAAW,GACX,QAAQ,GACR,WAAW,GACX,SAAS,CAAC;AAEd,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAA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AC;AAEtE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,MAAM,MAAM,gCAAgC,GAAG;IAC7C,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,WAAW,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC;IAC3B,aAAa,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gCAAgC,CAAC,CAAC;CAC5D,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAChC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,kBAAkB,CAAA;CAAE,GAC3C;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,uBAAuB,EAAE,CAAA;CAAE,CAAC;AAgE1D,eAAO,MAAM,gBAAgB,GAC3B,YAAY,aAAa,KACxB,UAAU,IAAI,cAA+C,CAAC;AAEjE,eAAO,MAAM,sBAAsB,GAAI,MAAM,cAAc,KAAG,eAOtD,CAAC;AA0JT,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,GAAG,OAAO,EACvB,OAAO,CAAC,EAAE,uBAAuB,GAChC,wBAAwB,CAyD1B"}
@@ -1,10 +1,84 @@
1
1
  export declare class WorkflowCancellationError extends Error {
2
2
  constructor(message?: string);
3
3
  }
4
- export declare class ParallelSuspensionError extends Error {
5
- constructor();
4
+ /** Base class for every reason a suspended run cannot be resumed. */
5
+ export declare abstract class WorkflowResumeError extends Error {
6
6
  }
7
- export declare const isWorkflowCancellationError: (error: unknown) => error is WorkflowCancellationError;
7
+ export type WorkflowCheckpointInvalidCode = 'missing' | 'malformed' | 'unsupported_version' | 'structure';
8
+ /**
9
+ * The checkpoint cannot be used: nothing was persisted, its shape is wrong,
10
+ * its format version is unsupported, or its frames do not line up with the
11
+ * compiled flow they claim to describe.
12
+ */
13
+ export declare class WorkflowCheckpointInvalidError extends WorkflowResumeError {
14
+ readonly code: WorkflowCheckpointInvalidCode;
15
+ /** Location inside the checkpoint where validation failed, when known. */
16
+ readonly path?: Array<string | number>;
17
+ /** Individual schema issues, for `malformed` checkpoints. */
18
+ readonly issues?: string[];
19
+ constructor(code: WorkflowCheckpointInvalidCode, message: string, options?: {
20
+ path?: Array<string | number>;
21
+ issues?: string[];
22
+ });
23
+ }
24
+ /**
25
+ * The compiled definition no longer matches the one the checkpoint was taken
26
+ * against, so its frames cannot be trusted to point at the same steps.
27
+ */
28
+ export declare class WorkflowDefinitionDriftError extends WorkflowResumeError {
29
+ readonly expected: string;
30
+ readonly actual: string;
31
+ constructor(expected: string, actual: string);
32
+ }
33
+ /** Several waits are open and the resume did not say which one it satisfies. */
34
+ export declare class WorkflowWaitAmbiguousError extends WorkflowResumeError {
35
+ readonly openWaitIds: string[];
36
+ constructor(openWaitIds: string[]);
37
+ }
38
+ /** The run is not waiting on the requested suspension. */
39
+ export declare class WorkflowWaitNotFoundError extends WorkflowResumeError {
40
+ readonly waitId: string;
41
+ readonly openWaitIds: string[];
42
+ constructor(waitId: string, openWaitIds: string[]);
43
+ }
44
+ /**
45
+ * The resume payload was refused. The wait stays open under the same
46
+ * `waitId`, so it can be resumed again, and the run's checkpoint, snapshot
47
+ * and step log are left as they were. Events already emitted by
48
+ * a body that refused the payload stay emitted, and its side effects,
49
+ * including writes to context state, are not undone.
50
+ *
51
+ * The runtime raises it when a payload does not match the `accepts` schema of
52
+ * the wait. An action may throw it itself, after its `suspend()` call
53
+ * resolved, to refuse a payload for reasons a schema cannot express.
54
+ */
55
+ export declare class WorkflowResumeRejectedError extends WorkflowResumeError {
56
+ /** Individual schema issues, when a schema refused the payload. */
57
+ readonly issues?: string[];
58
+ constructor(message: string, options?: {
59
+ issues?: string[];
60
+ });
61
+ }
62
+ /**
63
+ * A resumed action body did not replay the way it ran before it suspended,
64
+ * so the results recorded for it cannot be trusted.
65
+ */
66
+ export declare class NonDeterministicWorkflowError extends Error {
67
+ constructor(message: string);
68
+ }
69
+ export declare const isWorkflowResumeRejectedError: (error: unknown) => error is WorkflowResumeRejectedError;
70
+ export declare const isNonDeterministicWorkflowError: (error: unknown) => error is NonDeterministicWorkflowError;
8
71
  export declare const getAbortReason: (signal: AbortSignal) => Error;
9
72
  export declare const throwIfAborted: (signal: AbortSignal) => void;
73
+ /**
74
+ * Create a controller that aborts along with a parent signal, so a child
75
+ * scope can be cancelled on its own without cancelling the parent.
76
+ *
77
+ * @param parent Signal whose abort propagates to the new controller.
78
+ * @returns The controller, and a function detaching it from `parent`.
79
+ */
80
+ export declare const createLinkedAbortController: (parent: AbortSignal) => {
81
+ controller: AbortController;
82
+ unlink: () => void;
83
+ };
10
84
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAMA,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,OAAO,SAAsC;CAI1D;AAED,qBAAa,uBAAwB,SAAQ,KAAK;;CAKjD;AAED,eAAO,MAAM,2BAA2B,GACtC,OAAO,OAAO,KACb,KAAK,IAAI,yBAE4D,CAAC;AAEzE,eAAO,MAAM,cAAc,GAAI,QAAQ,WAAW,KAAG,KAUpD,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,WAAW,KAAG,IAIpD,CAAC"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAMA,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,OAAO,SAAsC;CAI1D;AAED,qEAAqE;AACrE,8BAAsB,mBAAoB,SAAQ,KAAK;CAAG;AAE1D,MAAM,MAAM,6BAA6B,GACrC,SAAS,GACT,WAAW,GACX,qBAAqB,GACrB,WAAW,CAAC;AAEhB;;;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1C,OAAO,EAAE,MAAM;CAI5B;AAQD,eAAO,MAAM,6BAA6B,GACxC,OAAO,OAAO,KACb,KAAK,IAAI,2BAEwC,CAAC;AAErD,eAAO,MAAM,+BAA+B,GAC1C,OAAO,OAAO,KACb,KAAK,IAAI,6BAE0C,CAAC;AAEvD,eAAO,MAAM,cAAc,GAAI,QAAQ,WAAW,KAAG,KAUpD,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,WAAW,KAAG,IAIpD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GACtC,QAAQ,WAAW,KAClB;IAAE,UAAU,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,MAAM,IAAI,CAAA;CAenD,CAAC"}
@@ -1,20 +1,19 @@
1
1
  export { AbstractAction } from './action/abstract-action';
2
2
  export { defineAction } from './action/action';
3
3
  export type { DefineActionParams } from './action/action';
4
- export type { Action, ActionExecutionArgs, ActionExecutionOutcome, ActionMetadata, Actions, InferActionArgs, InferActionBindings, InferActionContext, InferActionInput, InferActionOutput, InferActionSettings, SuspensionNotice, } from './action/action.types';
4
+ export type { Action, ActionExecutionArgs, ActionMetadata, Actions, InferActionArgs, InferActionBindings, InferActionContext, InferActionInput, InferActionOutput, InferActionSettings, } from './action/action.types';
5
5
  export { BaseWorkflowContext, EWorkflowRunStatus, WORKFLOW_RUN_STATUSES, type ActionSnapshot, type ActionStatus, type StepExecutionRecord, type SuspensionOptions, type WorkflowRunStatus, type WorkflowRuntimeControl, type WorkflowSnapshot, } from './context';
6
6
  export * from './dsl.types';
7
7
  export { issueMessages, type WorkflowValidationIssue, type WorkflowValidationIssueCode, } from './validation-issue';
8
8
  export type { BindingKindDescriptor, BindingKindSchemas, InferMountedBindingValue, InferWorkflowBindings, } from './bindings/base-binding';
9
- export { compileWorkflow, Workflow, WorkflowEventEmitter, WorkflowRunner, type FlowStepPath, type WorkflowCompileOptions, type WorkflowResumeResult, type WorkflowRunOptions, type WorkflowStartResult, } from './workflow';
9
+ export { compileWorkflow, Workflow, WorkflowEventEmitter, WorkflowRunner, type FlowStepPath, type WorkflowCompileOptions, type WorkflowRunOptions, type WorkflowRunResult, } from './workflow';
10
10
  export { StepType } from './workflow-event-emitter';
11
11
  export type { StepInfo, WorkflowEventEmitterLike, WorkflowEventMap, } from './workflow-event-emitter';
12
- export type { BaseStep as CompiledBaseStep, ConditionalBranch as CompiledConditionalBranch, ConditionalStep as CompiledConditionalStep, LoopStep as CompiledLoopStep, CompiledMapping, ParallelStep as CompiledParallelStep, CompiledStep, CompiledTask, CompiledTaskBindings, TaskStep as CompiledTaskStep, CompiledValue, CompiledWorkflow, EvaluationScope, ExecutionState, PersistedSuspension, RunnerResumeArgs, RunnerStartArgs, Suspension, ResumeResult as WorkflowResumeOutcome, StartResult as WorkflowStartOutcome, } from './workflow-types';
13
- export { NonDeterministicWorkflowError } from './runner-runtime-control';
14
- export { ParallelSuspensionError, WorkflowCancellationError } from './errors';
12
+ export type { BaseStep as CompiledBaseStep, ConditionalBranch as CompiledConditionalBranch, ConditionalStep as CompiledConditionalStep, LoopStep as CompiledLoopStep, CompiledMapping, ParallelStep as CompiledParallelStep, CompiledStep, CompiledTask, CompiledTaskBindings, TaskStep as CompiledTaskStep, CompiledValue, CompiledWorkflow, EvaluationScope, ExecutionState, ResumeRejection, RunnerResumeArgs, RunnerStartArgs, SuspendedResult, } from './workflow-types';
13
+ export { CHECKPOINT_VERSION, collectWaits, validateCheckpoint, workflowCheckpointSchema, type CheckpointValidationResult, type ConditionalFrame, type LoopFrame, type ParallelBranchFrame, type ParallelFrame, type RecordedResult, type SequenceFrame, type StepFrame, type TaskFrame, type WaitInfo, type WorkflowCheckpoint, } from './checkpoint';
14
+ export { fingerprintWorkflow } from './workflow-fingerprint';
15
+ export { NonDeterministicWorkflowError, WorkflowCancellationError, WorkflowCheckpointInvalidError, WorkflowDefinitionDriftError, WorkflowResumeError, WorkflowResumeRejectedError, WorkflowWaitAmbiguousError, WorkflowWaitNotFoundError, type WorkflowCheckpointInvalidCode, } from './errors';
15
16
  export { compileValue, evaluateMapping, evaluateValue, mergeSettings, type CompileValueOptions, type JsonataFunctionConfig, type JsonataFunctionImplementation, type JsonataFunctionRegistry, } from './workflow-values';
16
- export { createDeferred } from './utils/deferred';
17
- export type { Deferred } from './utils/deferred';
18
17
  export { assertSnakeCaseName, isSnakeCaseName, toSnakeCase, } from './utils/naming';
19
18
  export { sleep, withTimeout } from './utils/timeout';
20
19
  export { collectWorkflowDefinitionResourceRefs, remapWorkflowDefinitionResourceRefs, type WorkflowDefinitionResourceDescriptor, type WorkflowDefinitionResourceIdMaps, type WorkflowDefinitionResourceRefs, } from './utils/workflow-definition-resources';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,YAAY,EACV,MAAM,EACN,mBAAmB,EACnB,sBAAsB,EACtB,cAAc,EACd,OAAO,EACP,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,GACtB,MAAM,WAAW,CAAC;AAEnB,cAAc,aAAa,CAAC;AAE5B,OAAO,EACL,aAAa,EACb,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,GACjC,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,qBAAqB,EACrB,k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,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EACL,qCAAqC,EACrC,mCAAmC,EACnC,KAAK,oCAAoC,EACzC,KAAK,gCAAgC,EACrC,KAAK,8BAA8B,GACpC,MAAM,uCAAuC,CAAC"}
@@ -0,0 +1,69 @@
1
+ import { z, type ZodType } from 'zod';
2
+ import type { WaitInfo } from './checkpoint';
3
+ import { WorkflowResumeRejectedError } from './errors';
4
+ type JsonSchema = Record<string, unknown>;
5
+ /** Result of checking a resume payload against the wait it resolves. */
6
+ export type ResumePayloadCheck = {
7
+ ok: true;
8
+ value: unknown;
9
+ } | {
10
+ ok: false;
11
+ error: WorkflowResumeRejectedError;
12
+ };
13
+ /**
14
+ * Describe the payload a `suspend()` call accepts as a JSON Schema that can
15
+ * be stored on its wait.
16
+ *
17
+ * JSON Schema cannot express everything a Zod schema checks, so the result is
18
+ * relaxed until it never refuses a JSON payload the Zod schema accepts:
19
+ * coerced, preprocessed and `catch` nodes accept anything, and keywords that
20
+ * do not round-trip exactly are dropped. The Zod schema stays authoritative
21
+ * when the action body reads the payload.
22
+ *
23
+ * @param schema The `accepts` schema passed to `suspend()`.
24
+ * @returns The relaxed JSON Schema, or undefined when it cannot be generated.
25
+ */
26
+ export declare function describeResumePayload(schema: ZodType): JsonSchema | undefined;
27
+ /**
28
+ * Report whether an `accepts` schema also accepts a resume without payload.
29
+ * Its JSON Schema cannot say so, since JSON has no `undefined`.
30
+ *
31
+ * @param schema The `accepts` schema passed to `suspend()`.
32
+ * @returns True when the schema accepts `undefined`, e.g. when it is optional.
33
+ */
34
+ export declare function isPayloadOptional(schema: ZodType): boolean;
35
+ /**
36
+ * List the parts of an `accepts` schema that no JSON payload can match.
37
+ *
38
+ * Payloads are read back from the checkpoint as JSON, so a type JSON cannot
39
+ * carry, such as `z.date()`, refuses every payload: a `Date` resumes as its
40
+ * ISO string. Parts that coerce, preprocess or catch their input are fine.
41
+ *
42
+ * @param schema The `accepts` schema passed to `suspend()`.
43
+ * @returns One `<path> (<type>)` entry per offending part, in schema order.
44
+ */
45
+ export declare function findNonJsonTypes(schema: ZodType): string[];
46
+ /**
47
+ * Check a resume payload against the wait it resolves, without running
48
+ * anything.
49
+ *
50
+ * The payload is first normalized the way the checkpoint stores it, so the
51
+ * check sees what the action body will read. A resume without payload stays
52
+ * `undefined`, which a wait with `accepts` takes only when its payload is
53
+ * optional.
54
+ *
55
+ * @param wait The wait the payload resolves.
56
+ * @param resumeData The payload, as passed to `resume()`.
57
+ * @returns The normalized payload, or why it is refused.
58
+ */
59
+ export declare function checkResumePayload(wait: WaitInfo, resumeData: unknown): ResumePayloadCheck;
60
+ /**
61
+ * Build the error refusing a payload that failed a schema.
62
+ *
63
+ * @param subject What the payload was meant for, used in the message.
64
+ * @param issues The schema issues.
65
+ * @returns The rejection error.
66
+ */
67
+ export declare function rejectResumePayload(subject: string, issues: z.core.$ZodIssue[]): WorkflowResumeRejectedError;
68
+ export {};
69
+ //# sourceMappingURL=resume-payload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resume-payload.d.ts","sourceRoot":"","sources":["../../src/resume-payload.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,CAAC,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAEtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAGvD,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAsB1C,wEAAwE;AACxE,MAAM,MAAM,kBAAkB,GAC1B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC5B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,2BAA2B,CAAA;CAAE,CAAC;AAiEtD;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAc7E;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAW1D;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,CAuD1D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,OAAO,GAClB,kBAAkB,CAoCpB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,GACzB,2BAA2B,CAS7B"}