@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.
- package/README.md +67 -15
- package/dist/cjs/action/abstract-action.js +13 -1
- package/dist/cjs/checkpoint.js +301 -0
- package/dist/cjs/context.js +11 -27
- package/dist/cjs/dsl.types.js +3 -0
- package/dist/cjs/errors.js +116 -9
- package/dist/cjs/index.js +15 -6
- package/dist/cjs/resume-payload.js +257 -0
- package/dist/cjs/runner-runtime-control.js +181 -306
- package/dist/cjs/step-executors/conditional-executor.js +27 -29
- package/dist/cjs/step-executors/loop-executor.js +53 -62
- package/dist/cjs/step-executors/parallel-executor.js +169 -102
- package/dist/cjs/step-executors/task-executor.js +180 -96
- package/dist/cjs/utils/clone.js +73 -0
- package/dist/cjs/workflow-fingerprint.js +138 -0
- package/dist/cjs/workflow-runner.js +220 -155
- package/dist/cjs/workflow.js +24 -12
- package/dist/esm/action/abstract-action.js +14 -2
- package/dist/esm/checkpoint.js +293 -0
- package/dist/esm/context.js +11 -27
- package/dist/esm/dsl.types.js +3 -0
- package/dist/esm/errors.js +105 -6
- package/dist/esm/index.js +3 -3
- package/dist/esm/resume-payload.js +250 -0
- package/dist/esm/runner-runtime-control.js +179 -303
- package/dist/esm/step-executors/conditional-executor.js +27 -29
- package/dist/esm/step-executors/loop-executor.js +53 -62
- package/dist/esm/step-executors/parallel-executor.js +165 -98
- package/dist/esm/step-executors/task-executor.js +181 -97
- package/dist/esm/utils/clone.js +67 -0
- package/dist/esm/workflow-fingerprint.js +134 -0
- package/dist/esm/workflow-runner.js +220 -155
- package/dist/esm/workflow.js +24 -12
- package/dist/types/action/abstract-action.d.ts.map +1 -1
- package/dist/types/action/action.types.d.ts +0 -14
- package/dist/types/action/action.types.d.ts.map +1 -1
- package/dist/types/checkpoint.d.ts +188 -0
- package/dist/types/checkpoint.d.ts.map +1 -0
- package/dist/types/context.d.ts +45 -11
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/dsl.types.d.ts.map +1 -1
- package/dist/types/errors.d.ts +77 -3
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/index.d.ts +6 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/resume-payload.d.ts +69 -0
- package/dist/types/resume-payload.d.ts.map +1 -0
- package/dist/types/runner-runtime-control.d.ts +63 -51
- package/dist/types/runner-runtime-control.d.ts.map +1 -1
- package/dist/types/step-executors/conditional-executor.d.ts +6 -3
- package/dist/types/step-executors/conditional-executor.d.ts.map +1 -1
- package/dist/types/step-executors/loop-executor.d.ts +6 -4
- package/dist/types/step-executors/loop-executor.d.ts.map +1 -1
- package/dist/types/step-executors/parallel-executor.d.ts +11 -3
- package/dist/types/step-executors/parallel-executor.d.ts.map +1 -1
- package/dist/types/step-executors/task-executor.d.ts +11 -4
- package/dist/types/step-executors/task-executor.d.ts.map +1 -1
- package/dist/types/step-executors/types.d.ts +21 -13
- package/dist/types/step-executors/types.d.ts.map +1 -1
- package/dist/types/utils/clone.d.ts +33 -0
- package/dist/types/utils/clone.d.ts.map +1 -0
- package/dist/types/workflow-event-emitter.d.ts +29 -5
- package/dist/types/workflow-event-emitter.d.ts.map +1 -1
- package/dist/types/workflow-fingerprint.d.ts +14 -0
- package/dist/types/workflow-fingerprint.d.ts.map +1 -0
- package/dist/types/workflow-runner.d.ts +83 -41
- package/dist/types/workflow-runner.d.ts.map +1 -1
- package/dist/types/workflow-types.d.ts +25 -54
- package/dist/types/workflow-types.d.ts.map +1 -1
- package/dist/types/workflow.d.ts +24 -9
- package/dist/types/workflow.d.ts.map +1 -1
- package/examples/defs-bindings-agent/bindings.ts +1 -1
- package/examples/defs-bindings-agent/workflow.ts +3 -2
- package/examples/full/actions/await-user-input.ts +3 -2
- package/examples/full/actions/call-llm.ts +18 -18
- package/examples/full/actions/create-ticket.ts +1 -2
- package/examples/full/actions/decision-router.ts +6 -2
- package/examples/full/actions/get-calendar-events.ts +1 -2
- package/examples/full/actions/get-user-profile.ts +1 -2
- package/examples/full/actions/query-memory.ts +1 -2
- package/examples/full/actions/search-web.ts +1 -2
- package/examples/full/actions/send-email.ts +3 -2
- package/examples/full/workflow.ts +3 -2
- package/examples/loop/actions/await-reply.ts +2 -7
- package/examples/loop/workflow.ts +4 -2
- package/examples/suspend-resume/actions/wait-for-user.ts +11 -9
- package/examples/suspend-resume/workflow.ts +51 -11
- package/package.json +3 -3
- package/src/__tests__/checkpoint.test.ts +2568 -0
- package/src/__tests__/resume-payload.test.ts +245 -0
- package/src/__tests__/runner-runtime-control.test.ts +265 -0
- package/src/__tests__/workflow-fingerprint.test.ts +165 -0
- package/src/__tests__/workflow-runner.test.ts +167 -144
- package/src/__tests__/workflow.test.ts +97 -6
- package/src/action/abstract-action.ts +21 -2
- package/src/action/action.types.ts +0 -12
- package/src/checkpoint.ts +561 -0
- package/src/context.ts +51 -41
- package/src/dsl.types.ts +3 -0
- package/src/errors.ts +161 -8
- package/src/index.ts +33 -14
- package/src/resume-payload.ts +326 -0
- package/src/runner-runtime-control.ts +222 -456
- package/src/step-executors/conditional-executor.test.ts +77 -46
- package/src/step-executors/conditional-executor.ts +47 -40
- package/src/step-executors/loop-executor.test.ts +106 -92
- package/src/step-executors/loop-executor.ts +84 -101
- package/src/step-executors/parallel-executor.test.ts +300 -89
- package/src/step-executors/parallel-executor.ts +243 -125
- package/src/step-executors/task-executor.test.ts +321 -51
- package/src/step-executors/task-executor.ts +232 -145
- package/src/step-executors/types.ts +23 -22
- package/src/utils/clone.ts +75 -0
- package/src/workflow-event-emitter.ts +32 -6
- package/src/workflow-fingerprint.ts +159 -0
- package/src/workflow-runner.ts +325 -209
- package/src/workflow-types.ts +25 -56
- package/src/workflow.ts +41 -34
- package/dist/cjs/step-executors/suspension-continuation.js +0 -27
- package/dist/cjs/suspension-rebuilder.js +0 -265
- package/dist/cjs/utils/deferred.js +0 -17
- package/dist/esm/step-executors/suspension-continuation.js +0 -24
- package/dist/esm/suspension-rebuilder.js +0 -260
- package/dist/esm/utils/deferred.js +0 -14
- package/dist/types/step-executors/suspension-continuation.d.ts +0 -10
- package/dist/types/step-executors/suspension-continuation.d.ts.map +0 -1
- package/dist/types/suspension-rebuilder.d.ts +0 -67
- package/dist/types/suspension-rebuilder.d.ts.map +0 -1
- package/dist/types/utils/deferred.d.ts +0 -7
- package/dist/types/utils/deferred.d.ts.map +0 -1
- package/src/__tests__/suspension-rebuilder.test.ts +0 -404
- package/src/step-executors/suspension-continuation.ts +0 -31
- package/src/suspension-rebuilder.ts +0 -446
- package/src/utils/deferred.ts +0 -23
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Hexabot — Fair Core License (FCL-1.0-ALv2)
|
|
3
|
-
* Copyright (c) 2025 Hexastack.
|
|
4
|
-
* Full terms: see LICENSE.md.
|
|
5
|
-
*/
|
|
6
|
-
import { executeLoop as runLoopExecutor, shouldStopLoop, updateAccumulator, } from './step-executors/loop-executor';
|
|
7
|
-
import { wrapSuspensionContinuation } from './step-executors/suspension-continuation';
|
|
8
|
-
import { StepType, } from './workflow-event-emitter';
|
|
9
|
-
/**
|
|
10
|
-
* Parse a suspended step id into its execution path and iteration stack.
|
|
11
|
-
*
|
|
12
|
-
* @param stepId The serialized step identifier stored in snapshots.
|
|
13
|
-
* @returns The decoded path tokens and iteration stack.
|
|
14
|
-
*/
|
|
15
|
-
export function parseSuspendedStepId(stepId) {
|
|
16
|
-
const iterationMatch = stepId.match(/^(.*)\[(.+)\]$/);
|
|
17
|
-
const baseId = iterationMatch ? iterationMatch[1] : stepId;
|
|
18
|
-
const iterationStack = iterationMatch
|
|
19
|
-
? iterationMatch[2]
|
|
20
|
-
.split('.')
|
|
21
|
-
.map((token) => Number.parseInt(token, 10))
|
|
22
|
-
.filter((value) => !Number.isNaN(value))
|
|
23
|
-
: [];
|
|
24
|
-
const [pathPart] = baseId.split(':');
|
|
25
|
-
const path = pathPart.length === 0 || pathPart === 'root'
|
|
26
|
-
? []
|
|
27
|
-
: pathPart.split('.').map((token) => {
|
|
28
|
-
const numeric = Number.parseInt(token, 10);
|
|
29
|
-
return Number.isNaN(numeric) ? token : numeric;
|
|
30
|
-
});
|
|
31
|
-
return { path, iterationStack };
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Rebuild a suspension object based on persisted state and step identifiers.
|
|
35
|
-
*
|
|
36
|
-
* @param deps Dependencies needed to reconstruct executors and events.
|
|
37
|
-
* @param param0 Persisted state and metadata about the suspended step.
|
|
38
|
-
* @param param0.state Execution state captured at suspension time.
|
|
39
|
-
* @param param0.stepId Serialized step id used to locate the suspension point.
|
|
40
|
-
* @param param0.reason Optional reason supplied when the workflow suspended.
|
|
41
|
-
* @param param0.data Arbitrary payload provided with the suspension.
|
|
42
|
-
* @returns A suspension ready to be resumed, or null if reconstruction fails.
|
|
43
|
-
*/
|
|
44
|
-
export function rebuildSuspension(deps, { state, stepId, reason, data, stepExecId, suspendIndex, suspendKey, awaitResults, }) {
|
|
45
|
-
if (!state) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
const { path, iterationStack } = parseSuspendedStepId(stepId);
|
|
49
|
-
const executionState = {
|
|
50
|
-
...state,
|
|
51
|
-
iterationStack: iterationStack.length > 0 ? iterationStack : (state.iterationStack ?? []),
|
|
52
|
-
};
|
|
53
|
-
const suspensionMetadata = {
|
|
54
|
-
stepExecId,
|
|
55
|
-
suspendIndex,
|
|
56
|
-
suspendKey,
|
|
57
|
-
reason,
|
|
58
|
-
awaitResults,
|
|
59
|
-
};
|
|
60
|
-
const suspension = buildSuspensionForPath(deps, deps.compiled.flow, executionState, path, [], 0, suspensionMetadata);
|
|
61
|
-
if (!suspension) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
...suspension,
|
|
66
|
-
reason,
|
|
67
|
-
data,
|
|
68
|
-
stepExecId,
|
|
69
|
-
suspendIndex,
|
|
70
|
-
suspendKey,
|
|
71
|
-
awaitResults,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Walk the compiled flow to rebuild the continuation matching a target path.
|
|
76
|
-
*
|
|
77
|
-
* @param deps Dependencies for executor creation and event emission.
|
|
78
|
-
* @param steps The steps to search for the suspended step.
|
|
79
|
-
* @param state Mutable execution state to thread through the traversal.
|
|
80
|
-
* @param targetPath Path tokens identifying the suspended step location.
|
|
81
|
-
* @param pathPrefix Prefix accumulated while descending the tree.
|
|
82
|
-
* @param iterationDepth Current loop depth to match iteration stacks.
|
|
83
|
-
* @returns A rebuilt suspension or null if the path cannot be matched.
|
|
84
|
-
*/
|
|
85
|
-
export function buildSuspensionForPath(deps, steps, state, targetPath, pathPrefix, iterationDepth = 0, suspensionMetadata = {}) {
|
|
86
|
-
if (!deps.context) {
|
|
87
|
-
throw new Error('Workflow context is not attached.');
|
|
88
|
-
}
|
|
89
|
-
const env = deps.createExecutorEnv();
|
|
90
|
-
if (targetPath.length === 0) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
const [current, ...rest] = targetPath;
|
|
94
|
-
if (typeof current !== 'number') {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
const step = steps[current];
|
|
98
|
-
const currentPath = [...pathPrefix, current];
|
|
99
|
-
if (!step) {
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
if (rest.length === 0) {
|
|
103
|
-
if (step.type !== StepType.Task) {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
const stepInfo = deps.buildInstanceStepInfo(step, state.iterationStack);
|
|
107
|
-
const replayStepExecId = suspensionMetadata.stepExecId ?? `${stepInfo.id}#1`;
|
|
108
|
-
const replaySuspension = suspensionMetadata.suspendIndex !== undefined ||
|
|
109
|
-
suspensionMetadata.suspendKey !== undefined
|
|
110
|
-
? {
|
|
111
|
-
suspendIndex: suspensionMetadata.suspendIndex,
|
|
112
|
-
suspendKey: suspensionMetadata.suspendKey,
|
|
113
|
-
reason: suspensionMetadata.reason,
|
|
114
|
-
}
|
|
115
|
-
: undefined;
|
|
116
|
-
return {
|
|
117
|
-
step: stepInfo,
|
|
118
|
-
continue: async (resumeData) => {
|
|
119
|
-
const executorEnv = deps.createExecutorEnv();
|
|
120
|
-
const prepareStepReplay = executorEnv
|
|
121
|
-
.prepareStepReplay;
|
|
122
|
-
const recordStepSuspendResult = executorEnv.recordStepSuspendResult;
|
|
123
|
-
const primeStepResumeData = executorEnv
|
|
124
|
-
.primeStepResumeData;
|
|
125
|
-
const executeStep = executorEnv
|
|
126
|
-
.executeStep;
|
|
127
|
-
if (typeof executeStep === 'function') {
|
|
128
|
-
if (typeof prepareStepReplay === 'function') {
|
|
129
|
-
prepareStepReplay({
|
|
130
|
-
stepId: stepInfo.id,
|
|
131
|
-
stepExecId: replayStepExecId,
|
|
132
|
-
awaitResults: suspensionMetadata.awaitResults,
|
|
133
|
-
activeSuspension: replaySuspension,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
if (typeof recordStepSuspendResult === 'function' &&
|
|
137
|
-
replaySuspension) {
|
|
138
|
-
recordStepSuspendResult({
|
|
139
|
-
stepId: stepInfo.id,
|
|
140
|
-
stepExecId: replayStepExecId,
|
|
141
|
-
suspendIndex: suspensionMetadata.suspendIndex,
|
|
142
|
-
suspendKey: suspensionMetadata.suspendKey,
|
|
143
|
-
resumeData,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
else if (typeof primeStepResumeData === 'function') {
|
|
147
|
-
primeStepResumeData(stepInfo.id, resumeData);
|
|
148
|
-
}
|
|
149
|
-
const resumed = await executeStep(step, state, currentPath);
|
|
150
|
-
if (resumed) {
|
|
151
|
-
return wrapSuspensionContinuation(resumed, () => deps.executeFlow(steps, state, pathPrefix, current + 1));
|
|
152
|
-
}
|
|
153
|
-
return deps.executeFlow(steps, state, pathPrefix, current + 1);
|
|
154
|
-
}
|
|
155
|
-
const task = deps.compiled.tasks[step.taskName];
|
|
156
|
-
if (!task) {
|
|
157
|
-
throw new Error(`Task "${step.taskName}" is not defined.`);
|
|
158
|
-
}
|
|
159
|
-
await deps.captureTaskOutput(task, state, resumeData);
|
|
160
|
-
deps.markSnapshot(stepInfo, 'completed');
|
|
161
|
-
deps.emit('hook:step:success', { runId: deps.runId, step: stepInfo });
|
|
162
|
-
return deps.executeFlow(steps, state, pathPrefix, current + 1);
|
|
163
|
-
},
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
if (step.type === StepType.Parallel) {
|
|
167
|
-
return null;
|
|
168
|
-
}
|
|
169
|
-
if (step.type === StepType.Conditional) {
|
|
170
|
-
if (rest[0] !== 'branch' || typeof rest[1] !== 'number') {
|
|
171
|
-
return null;
|
|
172
|
-
}
|
|
173
|
-
const branchIndex = rest[1];
|
|
174
|
-
const childPath = rest.slice(2);
|
|
175
|
-
const branch = step.branches[branchIndex];
|
|
176
|
-
if (!branch) {
|
|
177
|
-
return null;
|
|
178
|
-
}
|
|
179
|
-
const branchSuspension = buildSuspensionForPath(deps, branch.steps, state, childPath, [...currentPath, 'branch', branchIndex], iterationDepth, suspensionMetadata);
|
|
180
|
-
if (!branchSuspension) {
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
return wrapSuspensionContinuation(branchSuspension, () => deps.executeFlow(steps, state, pathPrefix, current + 1));
|
|
184
|
-
}
|
|
185
|
-
if (step.type === StepType.Loop) {
|
|
186
|
-
if (rest.length < 1 || typeof rest[0] !== 'string') {
|
|
187
|
-
return null;
|
|
188
|
-
}
|
|
189
|
-
const loopToken = rest[0];
|
|
190
|
-
const childPath = rest.slice(1);
|
|
191
|
-
const targetIterationStack = state.iterationStack ?? [];
|
|
192
|
-
const iterationIndex = targetIterationStack[iterationDepth] ?? state.iteration?.index;
|
|
193
|
-
if (iterationIndex === undefined) {
|
|
194
|
-
return null;
|
|
195
|
-
}
|
|
196
|
-
const ancestorIterationStack = targetIterationStack.slice(0, iterationDepth);
|
|
197
|
-
const iterationState = {
|
|
198
|
-
...state,
|
|
199
|
-
iterationStack: targetIterationStack,
|
|
200
|
-
iteration: state.iteration ??
|
|
201
|
-
{
|
|
202
|
-
item: undefined,
|
|
203
|
-
index: iterationIndex,
|
|
204
|
-
},
|
|
205
|
-
};
|
|
206
|
-
const childSuspension = buildSuspensionForPath(deps, step.steps, iterationState, childPath, [...currentPath, loopToken], iterationDepth + 1, suspensionMetadata);
|
|
207
|
-
if (!childSuspension) {
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
const accumulator = iterationState.accumulator ?? state.accumulator ?? undefined;
|
|
211
|
-
return wrapSuspensionContinuation(childSuspension, async () => {
|
|
212
|
-
const scope = {
|
|
213
|
-
input: iterationState.input,
|
|
214
|
-
context: env.context.state,
|
|
215
|
-
output: iterationState.output,
|
|
216
|
-
iteration: iterationState.iteration ?? {
|
|
217
|
-
item: undefined,
|
|
218
|
-
index: iterationIndex,
|
|
219
|
-
},
|
|
220
|
-
accumulator,
|
|
221
|
-
};
|
|
222
|
-
const updatedAccumulator = await updateAccumulator(step, scope, accumulator);
|
|
223
|
-
const shouldStop = await shouldStopLoop(step, scope);
|
|
224
|
-
state.output = iterationState.output;
|
|
225
|
-
if (step.accumulate && step.name) {
|
|
226
|
-
state.output[step.name] = {
|
|
227
|
-
[step.accumulate.as]: updatedAccumulator,
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
if (step.accumulate) {
|
|
231
|
-
state.accumulator = updatedAccumulator;
|
|
232
|
-
}
|
|
233
|
-
if (shouldStop) {
|
|
234
|
-
return deps.executeFlow(steps, state, pathPrefix, current + 1);
|
|
235
|
-
}
|
|
236
|
-
const baseState = {
|
|
237
|
-
...iterationState,
|
|
238
|
-
iterationStack: ancestorIterationStack,
|
|
239
|
-
accumulator: updatedAccumulator,
|
|
240
|
-
output: state.output,
|
|
241
|
-
};
|
|
242
|
-
const next = await runLoopExecutor(env, step, baseState, currentPath, iterationIndex + 1);
|
|
243
|
-
state.output = baseState.output;
|
|
244
|
-
if (step.accumulate) {
|
|
245
|
-
state.accumulator = baseState.accumulator;
|
|
246
|
-
}
|
|
247
|
-
if (next) {
|
|
248
|
-
return wrapSuspensionContinuation(next, async () => {
|
|
249
|
-
state.output = baseState.output;
|
|
250
|
-
if (step.accumulate) {
|
|
251
|
-
state.accumulator = baseState.accumulator;
|
|
252
|
-
}
|
|
253
|
-
return deps.executeFlow(steps, state, pathPrefix, current + 1);
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
return deps.executeFlow(steps, state, pathPrefix, current + 1);
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
return null;
|
|
260
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Hexabot — Fair Core License (FCL-1.0-ALv2)
|
|
3
|
-
* Copyright (c) 2025 Hexastack.
|
|
4
|
-
* Full terms: see LICENSE.md.
|
|
5
|
-
*/
|
|
6
|
-
export function createDeferred() {
|
|
7
|
-
let resolve;
|
|
8
|
-
let reject;
|
|
9
|
-
const promise = new Promise((res, rej) => {
|
|
10
|
-
resolve = res;
|
|
11
|
-
reject = rej;
|
|
12
|
-
});
|
|
13
|
-
return { promise, resolve, reject };
|
|
14
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Suspension } from '../workflow-types';
|
|
2
|
-
/**
|
|
3
|
-
* Compose a suspension with the continuation that should run once it completes.
|
|
4
|
-
*
|
|
5
|
-
* When resuming a suspension yields another suspension from the same logical
|
|
6
|
-
* step, the follow-up suspension still needs to remember how to continue the
|
|
7
|
-
* surrounding flow after that step eventually finishes.
|
|
8
|
-
*/
|
|
9
|
-
export declare function wrapSuspensionContinuation(suspension: Suspension, onComplete: () => Promise<Suspension | void>): Suspension;
|
|
10
|
-
//# sourceMappingURL=suspension-continuation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"suspension-continuation.d.ts","sourceRoot":"","sources":["../../../src/step-executors/suspension-continuation.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,MAAM,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,GAC3C,UAAU,CAYZ"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type { ActionSnapshot, BaseWorkflowContext } from './context';
|
|
2
|
-
import type { StepExecutorEnv } from './step-executors/types';
|
|
3
|
-
import { type StepInfo, type WorkflowEventMap } from './workflow-event-emitter';
|
|
4
|
-
import type { CompiledStep, CompiledTask, CompiledWorkflow, ExecutionState, Suspension } from './workflow-types';
|
|
5
|
-
export type SuspensionRebuilderDeps = {
|
|
6
|
-
compiled: CompiledWorkflow;
|
|
7
|
-
context?: BaseWorkflowContext;
|
|
8
|
-
runId?: string;
|
|
9
|
-
createExecutorEnv: () => StepExecutorEnv;
|
|
10
|
-
buildInstanceStepInfo: (step: CompiledStep, iterationStack: number[]) => StepInfo;
|
|
11
|
-
captureTaskOutput: (task: CompiledTask, state: ExecutionState, result: unknown) => Promise<void>;
|
|
12
|
-
markSnapshot: (step: StepInfo, status: ActionSnapshot['status'], reason?: string) => void;
|
|
13
|
-
emit: <K extends keyof WorkflowEventMap>(event: K, payload: WorkflowEventMap[K]) => void;
|
|
14
|
-
executeFlow: (steps: CompiledStep[], state: ExecutionState, path: Array<number | string>, startIndex?: number) => Promise<Suspension | void>;
|
|
15
|
-
};
|
|
16
|
-
type RebuildSuspensionMetadata = {
|
|
17
|
-
stepExecId?: string;
|
|
18
|
-
suspendIndex?: number;
|
|
19
|
-
suspendKey?: string;
|
|
20
|
-
reason?: string;
|
|
21
|
-
awaitResults?: Record<string, unknown>;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Parse a suspended step id into its execution path and iteration stack.
|
|
25
|
-
*
|
|
26
|
-
* @param stepId The serialized step identifier stored in snapshots.
|
|
27
|
-
* @returns The decoded path tokens and iteration stack.
|
|
28
|
-
*/
|
|
29
|
-
export declare function parseSuspendedStepId(stepId: string): {
|
|
30
|
-
path: Array<number | string>;
|
|
31
|
-
iterationStack: number[];
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Rebuild a suspension object based on persisted state and step identifiers.
|
|
35
|
-
*
|
|
36
|
-
* @param deps Dependencies needed to reconstruct executors and events.
|
|
37
|
-
* @param param0 Persisted state and metadata about the suspended step.
|
|
38
|
-
* @param param0.state Execution state captured at suspension time.
|
|
39
|
-
* @param param0.stepId Serialized step id used to locate the suspension point.
|
|
40
|
-
* @param param0.reason Optional reason supplied when the workflow suspended.
|
|
41
|
-
* @param param0.data Arbitrary payload provided with the suspension.
|
|
42
|
-
* @returns A suspension ready to be resumed, or null if reconstruction fails.
|
|
43
|
-
*/
|
|
44
|
-
export declare function rebuildSuspension(deps: SuspensionRebuilderDeps, { state, stepId, reason, data, stepExecId, suspendIndex, suspendKey, awaitResults, }: {
|
|
45
|
-
state?: ExecutionState;
|
|
46
|
-
stepId: string;
|
|
47
|
-
reason?: string;
|
|
48
|
-
data?: unknown;
|
|
49
|
-
stepExecId?: string;
|
|
50
|
-
suspendIndex?: number;
|
|
51
|
-
suspendKey?: string;
|
|
52
|
-
awaitResults?: Record<string, unknown>;
|
|
53
|
-
}): Suspension | null;
|
|
54
|
-
/**
|
|
55
|
-
* Walk the compiled flow to rebuild the continuation matching a target path.
|
|
56
|
-
*
|
|
57
|
-
* @param deps Dependencies for executor creation and event emission.
|
|
58
|
-
* @param steps The steps to search for the suspended step.
|
|
59
|
-
* @param state Mutable execution state to thread through the traversal.
|
|
60
|
-
* @param targetPath Path tokens identifying the suspended step location.
|
|
61
|
-
* @param pathPrefix Prefix accumulated while descending the tree.
|
|
62
|
-
* @param iterationDepth Current loop depth to match iteration stacks.
|
|
63
|
-
* @returns A rebuilt suspension or null if the path cannot be matched.
|
|
64
|
-
*/
|
|
65
|
-
export declare function buildSuspensionForPath(deps: SuspensionRebuilderDeps, steps: CompiledStep[], state: ExecutionState, targetPath: Array<number | string>, pathPrefix: Array<number | string>, iterationDepth?: number, suspensionMetadata?: RebuildSuspensionMetadata): Suspension | null;
|
|
66
|
-
export {};
|
|
67
|
-
//# sourceMappingURL=suspension-rebuilder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"suspension-rebuilder.d.ts","sourceRoot":"","sources":["../../src/suspension-rebuilder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAOrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAEhB,cAAc,EACd,UAAU,EACX,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,MAAM,eAAe,CAAC;IACzC,qBAAqB,EAAE,CACrB,IAAI,EAAE,YAAY,EAClB,cAAc,EAAE,MAAM,EAAE,KACrB,QAAQ,CAAC;IACd,iBAAiB,EAAE,CACjB,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,cAAc,EACrB,MAAM,EAAE,OAAO,KACZ,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,YAAY,EAAE,CACZ,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,EAChC,MAAM,CAAC,EAAE,MAAM,KACZ,IAAI,CAAC;IACV,IAAI,EAAE,CAAC,CAAC,SAAS,MAAM,gBAAgB,E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