@hexabot-ai/agentic 3.1.2-alpha.1 → 3.1.2-alpha.11
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/dist/cjs/index.js +4 -1
- package/dist/cjs/step-executors/loop-executor.js +26 -39
- package/dist/cjs/step-executors/parallel-executor.js +9 -15
- package/dist/cjs/step-executors/suspension-continuation.js +27 -0
- package/dist/cjs/suspension-rebuilder.js +61 -74
- package/dist/cjs/utils/workflow-definition-resources.js +73 -0
- package/dist/cjs/workflow-runner.js +2 -10
- package/dist/esm/index.js +1 -0
- package/dist/esm/step-executors/loop-executor.js +26 -39
- package/dist/esm/step-executors/parallel-executor.js +9 -15
- package/dist/esm/step-executors/suspension-continuation.js +24 -0
- package/dist/esm/suspension-rebuilder.js +61 -74
- package/dist/esm/utils/workflow-definition-resources.js +68 -0
- package/dist/esm/workflow-runner.js +2 -10
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/step-executors/loop-executor.d.ts.map +1 -1
- package/dist/types/step-executors/parallel-executor.d.ts.map +1 -1
- package/dist/types/step-executors/suspension-continuation.d.ts +10 -0
- package/dist/types/step-executors/suspension-continuation.d.ts.map +1 -0
- package/dist/types/suspension-rebuilder.d.ts.map +1 -1
- package/dist/types/utils/workflow-definition-resources.d.ts +16 -0
- package/dist/types/utils/workflow-definition-resources.d.ts.map +1 -0
- package/dist/types/workflow-runner.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/suspension-rebuilder.test.ts +43 -9
- package/src/__tests__/workflow-definition-resources.test.ts +97 -0
- package/src/__tests__/workflow-runner.test.ts +119 -1
- package/src/index.ts +8 -0
- package/src/step-executors/loop-executor.ts +49 -64
- package/src/step-executors/parallel-executor.ts +13 -20
- package/src/step-executors/suspension-continuation.ts +31 -0
- package/src/suspension-rebuilder.ts +94 -100
- package/src/utils/workflow-definition-resources.ts +111 -0
- package/src/workflow-runner.ts +4 -11
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { executeLoop as runLoopExecutor, shouldStopLoop, updateAccumulator, } from './step-executors/loop-executor';
|
|
7
7
|
import { executeParallel as runParallelExecutor } from './step-executors/parallel-executor';
|
|
8
8
|
import { markStepsSkipped } from './step-executors/skip-helpers';
|
|
9
|
+
import { wrapSuspensionContinuation } from './step-executors/suspension-continuation';
|
|
9
10
|
import { StepType, } from './workflow-event-emitter';
|
|
10
11
|
/**
|
|
11
12
|
* Parse a suspended step id into its execution path and iteration stack.
|
|
@@ -149,16 +150,7 @@ export function buildSuspensionForPath(deps, steps, state, targetPath, pathPrefi
|
|
|
149
150
|
}
|
|
150
151
|
const resumed = await executeStep(step, state, currentPath);
|
|
151
152
|
if (resumed) {
|
|
152
|
-
return
|
|
153
|
-
...resumed,
|
|
154
|
-
continue: async (nextResumeData) => {
|
|
155
|
-
const next = await resumed.continue(nextResumeData);
|
|
156
|
-
if (next) {
|
|
157
|
-
return next;
|
|
158
|
-
}
|
|
159
|
-
return deps.executeFlow(steps, state, pathPrefix, current + 1);
|
|
160
|
-
},
|
|
161
|
-
};
|
|
153
|
+
return wrapSuspensionContinuation(resumed, () => deps.executeFlow(steps, state, pathPrefix, current + 1));
|
|
162
154
|
}
|
|
163
155
|
return deps.executeFlow(steps, state, pathPrefix, current + 1);
|
|
164
156
|
}
|
|
@@ -183,22 +175,19 @@ export function buildSuspensionForPath(deps, steps, state, targetPath, pathPrefi
|
|
|
183
175
|
return null;
|
|
184
176
|
}
|
|
185
177
|
const childIndex = typeof childPath[0] === 'number' ? childPath[0] : 0;
|
|
186
|
-
return {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if (next) {
|
|
191
|
-
return next;
|
|
178
|
+
return wrapSuspensionContinuation(childSuspension, async () => {
|
|
179
|
+
if (step.strategy === 'wait_any') {
|
|
180
|
+
if (childIndex + 1 < step.steps.length) {
|
|
181
|
+
markStepsSkipped(env, step.steps.slice(childIndex + 1), state.iterationStack ?? []);
|
|
192
182
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
};
|
|
183
|
+
return deps.executeFlow(steps, state, pathPrefix, current + 1);
|
|
184
|
+
}
|
|
185
|
+
const next = await runParallelExecutor(env, step, state, currentPath, childIndex + 1);
|
|
186
|
+
if (next) {
|
|
187
|
+
return wrapSuspensionContinuation(next, () => deps.executeFlow(steps, state, pathPrefix, current + 1));
|
|
188
|
+
}
|
|
189
|
+
return deps.executeFlow(steps, state, pathPrefix, current + 1);
|
|
190
|
+
});
|
|
202
191
|
}
|
|
203
192
|
if (step.type === StepType.Conditional) {
|
|
204
193
|
if (rest[0] !== 'branch' || typeof rest[1] !== 'number') {
|
|
@@ -214,16 +203,7 @@ export function buildSuspensionForPath(deps, steps, state, targetPath, pathPrefi
|
|
|
214
203
|
if (!branchSuspension) {
|
|
215
204
|
return null;
|
|
216
205
|
}
|
|
217
|
-
return
|
|
218
|
-
...branchSuspension,
|
|
219
|
-
continue: async (resumeData) => {
|
|
220
|
-
const next = await branchSuspension.continue(resumeData);
|
|
221
|
-
if (next) {
|
|
222
|
-
return next;
|
|
223
|
-
}
|
|
224
|
-
return deps.executeFlow(steps, state, pathPrefix, current + 1);
|
|
225
|
-
},
|
|
226
|
-
};
|
|
206
|
+
return wrapSuspensionContinuation(branchSuspension, () => deps.executeFlow(steps, state, pathPrefix, current + 1));
|
|
227
207
|
}
|
|
228
208
|
if (step.type === StepType.Loop) {
|
|
229
209
|
if (rest.length < 1 || typeof rest[0] !== 'string') {
|
|
@@ -251,46 +231,53 @@ export function buildSuspensionForPath(deps, steps, state, targetPath, pathPrefi
|
|
|
251
231
|
return null;
|
|
252
232
|
}
|
|
253
233
|
const accumulator = iterationState.accumulator ?? state.accumulator ?? undefined;
|
|
254
|
-
return {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const updatedAccumulator = await updateAccumulator(step, scope, accumulator);
|
|
272
|
-
const shouldStop = await shouldStopLoop(step, scope);
|
|
273
|
-
state.output = iterationState.output;
|
|
274
|
-
if (step.accumulate && step.name) {
|
|
275
|
-
state.output[step.name] = {
|
|
276
|
-
[step.accumulate.as]: updatedAccumulator,
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
if (step.accumulate) {
|
|
280
|
-
state.accumulator = updatedAccumulator;
|
|
281
|
-
}
|
|
282
|
-
if (shouldStop) {
|
|
283
|
-
return undefined;
|
|
284
|
-
}
|
|
285
|
-
const baseState = {
|
|
286
|
-
...iterationState,
|
|
287
|
-
iterationStack: ancestorIterationStack,
|
|
288
|
-
accumulator: updatedAccumulator,
|
|
289
|
-
output: state.output,
|
|
234
|
+
return wrapSuspensionContinuation(childSuspension, async () => {
|
|
235
|
+
const scope = {
|
|
236
|
+
input: iterationState.input,
|
|
237
|
+
context: env.context.state,
|
|
238
|
+
output: iterationState.output,
|
|
239
|
+
iteration: iterationState.iteration ?? {
|
|
240
|
+
item: undefined,
|
|
241
|
+
index: iterationIndex,
|
|
242
|
+
},
|
|
243
|
+
accumulator,
|
|
244
|
+
};
|
|
245
|
+
const updatedAccumulator = await updateAccumulator(step, scope, accumulator);
|
|
246
|
+
const shouldStop = await shouldStopLoop(step, scope);
|
|
247
|
+
state.output = iterationState.output;
|
|
248
|
+
if (step.accumulate && step.name) {
|
|
249
|
+
state.output[step.name] = {
|
|
250
|
+
[step.accumulate.as]: updatedAccumulator,
|
|
290
251
|
};
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
252
|
+
}
|
|
253
|
+
if (step.accumulate) {
|
|
254
|
+
state.accumulator = updatedAccumulator;
|
|
255
|
+
}
|
|
256
|
+
if (shouldStop) {
|
|
257
|
+
return deps.executeFlow(steps, state, pathPrefix, current + 1);
|
|
258
|
+
}
|
|
259
|
+
const baseState = {
|
|
260
|
+
...iterationState,
|
|
261
|
+
iterationStack: ancestorIterationStack,
|
|
262
|
+
accumulator: updatedAccumulator,
|
|
263
|
+
output: state.output,
|
|
264
|
+
};
|
|
265
|
+
const next = await runLoopExecutor(env, step, baseState, currentPath, iterationIndex + 1);
|
|
266
|
+
state.output = baseState.output;
|
|
267
|
+
if (step.accumulate) {
|
|
268
|
+
state.accumulator = baseState.accumulator;
|
|
269
|
+
}
|
|
270
|
+
if (next) {
|
|
271
|
+
return wrapSuspensionContinuation(next, async () => {
|
|
272
|
+
state.output = baseState.output;
|
|
273
|
+
if (step.accumulate) {
|
|
274
|
+
state.accumulator = baseState.accumulator;
|
|
275
|
+
}
|
|
276
|
+
return deps.executeFlow(steps, state, pathPrefix, current + 1);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
return deps.executeFlow(steps, state, pathPrefix, current + 1);
|
|
280
|
+
});
|
|
294
281
|
}
|
|
295
282
|
return null;
|
|
296
283
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Hexabot — Fair Core License (FCL-1.0-ALv2)
|
|
3
|
+
* Copyright (c) 2026 Hexastack.
|
|
4
|
+
* Full terms: see LICENSE.md.
|
|
5
|
+
*/
|
|
6
|
+
const getSettingsRef = (definition, settingsKey) => {
|
|
7
|
+
const settings = definition.settings;
|
|
8
|
+
if (!settings || typeof settings !== 'object') {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const value = settings[settingsKey];
|
|
12
|
+
return typeof value === 'string' && value.trim() ? value : null;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Collect external resource IDs referenced by workflow definition defs.
|
|
16
|
+
*/
|
|
17
|
+
export const collectWorkflowDefinitionResourceRefs = (definition, descriptors) => {
|
|
18
|
+
const result = Object.fromEntries(descriptors.map((descriptor) => [descriptor.kind, new Set()]));
|
|
19
|
+
for (const def of Object.values(definition.defs ?? {})) {
|
|
20
|
+
for (const descriptor of descriptors) {
|
|
21
|
+
if (def.kind !== descriptor.kind) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const ref = getSettingsRef(def, descriptor.settingsKey);
|
|
25
|
+
if (ref) {
|
|
26
|
+
result[descriptor.kind].add(ref);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return Object.fromEntries(Object.entries(result).map(([kind, refs]) => [kind, Array.from(refs)]));
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Rewrite external resource IDs referenced by workflow definition defs.
|
|
34
|
+
*/
|
|
35
|
+
export const remapWorkflowDefinitionResourceRefs = (definition, descriptors, idMaps) => {
|
|
36
|
+
let didChange = false;
|
|
37
|
+
const nextDefs = Object.fromEntries(Object.entries(definition.defs ?? {}).map(([defName, def]) => {
|
|
38
|
+
const descriptor = descriptors.find((item) => item.kind === def.kind);
|
|
39
|
+
if (!descriptor) {
|
|
40
|
+
return [defName, def];
|
|
41
|
+
}
|
|
42
|
+
const currentRef = getSettingsRef(def, descriptor.settingsKey);
|
|
43
|
+
const nextRef = currentRef
|
|
44
|
+
? idMaps[descriptor.kind]?.[currentRef]
|
|
45
|
+
: undefined;
|
|
46
|
+
if (!currentRef || !nextRef || nextRef === currentRef) {
|
|
47
|
+
return [defName, def];
|
|
48
|
+
}
|
|
49
|
+
didChange = true;
|
|
50
|
+
return [
|
|
51
|
+
defName,
|
|
52
|
+
{
|
|
53
|
+
...def,
|
|
54
|
+
settings: {
|
|
55
|
+
...(def.settings ?? {}),
|
|
56
|
+
[descriptor.settingsKey]: nextRef,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
}));
|
|
61
|
+
if (!didChange) {
|
|
62
|
+
return definition;
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
...definition,
|
|
66
|
+
defs: nextDefs,
|
|
67
|
+
};
|
|
68
|
+
};
|
|
@@ -8,6 +8,7 @@ import { RunnerRuntimeControl } from './runner-runtime-control';
|
|
|
8
8
|
import { executeConditional as runConditionalExecutor } from './step-executors/conditional-executor';
|
|
9
9
|
import { executeLoop as runLoopExecutor } from './step-executors/loop-executor';
|
|
10
10
|
import { executeParallel as runParallelExecutor } from './step-executors/parallel-executor';
|
|
11
|
+
import { wrapSuspensionContinuation } from './step-executors/suspension-continuation';
|
|
11
12
|
import { executeTaskStep as runTaskExecutor } from './step-executors/task-executor';
|
|
12
13
|
import { rebuildSuspension, } from './suspension-rebuilder';
|
|
13
14
|
import { StepType, } from './workflow-event-emitter';
|
|
@@ -405,16 +406,7 @@ export class WorkflowRunner {
|
|
|
405
406
|
const stepPath = [...path, index];
|
|
406
407
|
const suspension = await this.executeStep(step, state, stepPath);
|
|
407
408
|
if (suspension) {
|
|
408
|
-
return
|
|
409
|
-
...suspension,
|
|
410
|
-
continue: async (resumeData) => {
|
|
411
|
-
const next = await suspension.continue(resumeData);
|
|
412
|
-
if (next) {
|
|
413
|
-
return next;
|
|
414
|
-
}
|
|
415
|
-
return this.executeFlow(steps, state, path, index + 1);
|
|
416
|
-
},
|
|
417
|
-
};
|
|
409
|
+
return wrapSuspensionContinuation(suspension, () => this.executeFlow(steps, state, path, index + 1));
|
|
418
410
|
}
|
|
419
411
|
}
|
|
420
412
|
return undefined;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -15,4 +15,5 @@ export { createDeferred } from './utils/deferred';
|
|
|
15
15
|
export type { Deferred } from './utils/deferred';
|
|
16
16
|
export { assertSnakeCaseName, isSnakeCaseName, toSnakeCase, } from './utils/naming';
|
|
17
17
|
export { sleep, withTimeout } from './utils/timeout';
|
|
18
|
+
export { collectWorkflowDefinitionResourceRefs, remapWorkflowDefinitionResourceRefs, type WorkflowDefinitionResourceDescriptor, type WorkflowDefinitionResourceIdMaps, type WorkflowDefinitionResourceRefs, } from './utils/workflow-definition-resources';
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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,YAAY,EACV,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,eAAe,EACf,QAAQ,EACR,oBAAoB,EACpB,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,YAAY,EACV,QAAQ,EACR,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAElC,YAAY,EACV,QAAQ,IAAI,gBAAgB,EAC5B,iBAAiB,IAAI,yB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AAK,6BAA6B,EAClC,KAAK,uBAAuB,GAC7B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,WAAW,GACZ,MAAM,gBAAgB,CAAC;AAExB,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop-executor.d.ts","sourceRoot":"","sources":["../../../src/step-executors/loop-executor.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EAEd,QAAQ,EACR,UAAU,EAEX,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"loop-executor.d.ts","sourceRoot":"","sources":["../../../src/step-executors/loop-executor.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EAEd,QAAQ,EACR,UAAU,EAEX,MAAM,mBAAmB,CAAC;AAI3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,KAAK,SAAS,GAAG,eAAe,CAAC;AAEjC;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,EAC5B,UAAU,SAAI,GACb,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAM5B;AA+KD;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,OAAO,GAChB,OAAO,CAAC,OAAO,CAAC,CASlB;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,SAAS,GACf,OAAO,CAAC,OAAO,CAAC,CAQlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parallel-executor.d.ts","sourceRoot":"","sources":["../../../src/step-executors/parallel-executor.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACX,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"parallel-executor.d.ts","sourceRoot":"","sources":["../../../src/step-executors/parallel-executor.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACX,MAAM,mBAAmB,CAAC;AAI3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,EAC5B,UAAU,SAAI,GACb,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAqC5B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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 +1 @@
|
|
|
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;
|
|
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;AASrE,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,cAA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AAC,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;CACxC,GACA,UAAU,GAAG,IAAI,CAyCnB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,uBAAuB,EAC7B,KAAK,EAAE,YAAY,EAAE,EACrB,KAAK,EAAE,cAAc,EACrB,UAAU,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,EAClC,UAAU,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,EAClC,cAAc,SAAI,EAClB,kBAAkB,GAAE,yBAA8B,GACjD,UAAU,GAAG,IAAI,CA+SnB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { WorkflowDefinition } from '../dsl.types';
|
|
2
|
+
export type WorkflowDefinitionResourceDescriptor = {
|
|
3
|
+
kind: string;
|
|
4
|
+
settingsKey: string;
|
|
5
|
+
};
|
|
6
|
+
export type WorkflowDefinitionResourceRefs = Record<string, string[]>;
|
|
7
|
+
export type WorkflowDefinitionResourceIdMaps = Record<string, Record<string, string>>;
|
|
8
|
+
/**
|
|
9
|
+
* Collect external resource IDs referenced by workflow definition defs.
|
|
10
|
+
*/
|
|
11
|
+
export declare const collectWorkflowDefinitionResourceRefs: (definition: WorkflowDefinition, descriptors: WorkflowDefinitionResourceDescriptor[]) => WorkflowDefinitionResourceRefs;
|
|
12
|
+
/**
|
|
13
|
+
* Rewrite external resource IDs referenced by workflow definition defs.
|
|
14
|
+
*/
|
|
15
|
+
export declare const remapWorkflowDefinitionResourceRefs: (definition: WorkflowDefinition, descriptors: WorkflowDefinitionResourceDescriptor[], idMaps: WorkflowDefinitionResourceIdMaps) => WorkflowDefinition;
|
|
16
|
+
//# sourceMappingURL=workflow-definition-resources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-definition-resources.d.ts","sourceRoot":"","sources":["../../../src/utils/workflow-definition-resources.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAiB,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEtE,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAEtE,MAAM,MAAM,gCAAgC,GAAG,MAAM,CACnD,MAAM,EACN,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CACvB,CAAC;AAgBF;;GAEG;AACH,eAAO,MAAM,qCAAqC,GAChD,YAAY,kBAAkB,EAC9B,aAAa,oCAAoC,EAAE,KAClD,8BAqBF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mCAAmC,GAC9C,YAAY,kBAAkB,EAC9B,aAAa,oCAAoC,EAAE,EACnD,QAAQ,gCAAgC,KACvC,kBAwCF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-runner.d.ts","sourceRoot":"","sources":["../../src/workflow-runner.ts"],"names":[],"mappings":"AAMA,OAAO,EAIL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACtB,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"workflow-runner.d.ts","sourceRoot":"","sources":["../../src/workflow-runner.ts"],"names":[],"mappings":"AAMA,OAAO,EAIL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACtB,MAAM,WAAW,CAAC;AAYnB,OAAO,EAEL,KAAK,QAAQ,EAEd,MAAM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,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;IAsBzB;;;;;;;OAOG;YACW,WAAW;IAkBzB;;;;;;OAMG;YACW,iBAAiB;CAOhC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hexabot-ai/agentic",
|
|
3
|
-
"version": "3.1.2-alpha.
|
|
3
|
+
"version": "3.1.2-alpha.11",
|
|
4
4
|
"description": "Schemas and utilities for the Hexabot agentic workflow DSL.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"jsonata": "^2.1.0",
|
|
23
|
-
"yaml": "^2.
|
|
23
|
+
"yaml": "^2.8.3",
|
|
24
24
|
"zod": "^4.3.6"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
@@ -308,10 +308,15 @@ describe('rebuildSuspension', () => {
|
|
|
308
308
|
state,
|
|
309
309
|
stepId: '0.parallel.1:child_b',
|
|
310
310
|
});
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
311
|
+
const nextSuspension = {
|
|
312
|
+
step: {
|
|
313
|
+
id: '0.parallel.2:child_c',
|
|
314
|
+
name: 'child_c',
|
|
315
|
+
type: StepType.Task,
|
|
316
|
+
},
|
|
317
|
+
continue: jest.fn().mockResolvedValue(undefined),
|
|
318
|
+
};
|
|
319
|
+
mockedRunParallelExecutor.mockResolvedValue(nextSuspension);
|
|
315
320
|
|
|
316
321
|
const result = await suspension?.continue({ payload: true });
|
|
317
322
|
|
|
@@ -325,7 +330,17 @@ describe('rebuildSuspension', () => {
|
|
|
325
330
|
[0],
|
|
326
331
|
2,
|
|
327
332
|
);
|
|
328
|
-
expect(result).toBe(
|
|
333
|
+
expect(result?.step.id).toBe(nextSuspension.step.id);
|
|
334
|
+
|
|
335
|
+
await result?.continue({ done: true });
|
|
336
|
+
|
|
337
|
+
expect(nextSuspension.continue).toHaveBeenCalledWith({ done: true });
|
|
338
|
+
expect(deps.executeFlow).toHaveBeenLastCalledWith(
|
|
339
|
+
compiled.flow,
|
|
340
|
+
state,
|
|
341
|
+
[],
|
|
342
|
+
1,
|
|
343
|
+
);
|
|
329
344
|
});
|
|
330
345
|
|
|
331
346
|
it('resumes a loop suspension, updating accumulators and continuing execution', async () => {
|
|
@@ -367,9 +382,15 @@ describe('rebuildSuspension', () => {
|
|
|
367
382
|
|
|
368
383
|
mockedUpdateAccumulator.mockResolvedValue(5);
|
|
369
384
|
mockedShouldStopLoop.mockResolvedValue(false);
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
385
|
+
const nextSuspension = {
|
|
386
|
+
step: {
|
|
387
|
+
id: '0.collector.0:loop_task[2]',
|
|
388
|
+
name: 'loop_task',
|
|
389
|
+
type: StepType.Task,
|
|
390
|
+
},
|
|
391
|
+
continue: jest.fn().mockResolvedValue(undefined),
|
|
392
|
+
};
|
|
393
|
+
mockedRunLoopExecutor.mockResolvedValue(nextSuspension);
|
|
373
394
|
|
|
374
395
|
const suspension = rebuildSuspension(deps, {
|
|
375
396
|
state,
|
|
@@ -404,6 +425,19 @@ describe('rebuildSuspension', () => {
|
|
|
404
425
|
const loopState = mockedRunLoopExecutor.mock.calls[0]?.[2];
|
|
405
426
|
expect(loopState?.accumulator).toBe(5);
|
|
406
427
|
expect(loopState?.iterationStack).toEqual([]);
|
|
407
|
-
expect(result).toBe(
|
|
428
|
+
expect(result?.step.id).toBe(nextSuspension.step.id);
|
|
429
|
+
|
|
430
|
+
await result?.continue({ done: true });
|
|
431
|
+
|
|
432
|
+
expect(nextSuspension.continue).toHaveBeenCalledWith({ done: true });
|
|
433
|
+
expect(deps.executeFlow).toHaveBeenLastCalledWith(
|
|
434
|
+
compiled.flow,
|
|
435
|
+
expect.objectContaining({
|
|
436
|
+
accumulator: 5,
|
|
437
|
+
output: expect.objectContaining({ collector: { sum: 5 } }),
|
|
438
|
+
}),
|
|
439
|
+
[],
|
|
440
|
+
1,
|
|
441
|
+
);
|
|
408
442
|
});
|
|
409
443
|
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Hexabot — Fair Core License (FCL-1.0-ALv2)
|
|
3
|
+
* Copyright (c) 2026 Hexastack.
|
|
4
|
+
* Full terms: see LICENSE.md.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { WorkflowDefinition } from '../dsl.types';
|
|
8
|
+
import {
|
|
9
|
+
collectWorkflowDefinitionResourceRefs,
|
|
10
|
+
remapWorkflowDefinitionResourceRefs,
|
|
11
|
+
type WorkflowDefinitionResourceDescriptor,
|
|
12
|
+
} from '../utils/workflow-definition-resources';
|
|
13
|
+
|
|
14
|
+
const descriptors: WorkflowDefinitionResourceDescriptor[] = [
|
|
15
|
+
{ kind: 'memory', settingsKey: 'definition_id' },
|
|
16
|
+
{ kind: 'mcp', settingsKey: 'server_id' },
|
|
17
|
+
];
|
|
18
|
+
const definition: WorkflowDefinition = {
|
|
19
|
+
defs: {
|
|
20
|
+
profile_memory: {
|
|
21
|
+
kind: 'memory',
|
|
22
|
+
settings: {
|
|
23
|
+
definition_id: 'memory-1',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
duplicate_profile_memory: {
|
|
27
|
+
kind: 'memory',
|
|
28
|
+
settings: {
|
|
29
|
+
definition_id: 'memory-1',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
search_mcp: {
|
|
33
|
+
kind: 'mcp',
|
|
34
|
+
settings: {
|
|
35
|
+
server_id: 'mcp-1',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
greet: {
|
|
39
|
+
kind: 'task',
|
|
40
|
+
action: 'send_message',
|
|
41
|
+
bindings: {
|
|
42
|
+
memory: ['profile_memory'],
|
|
43
|
+
mcp: ['search_mcp'],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
flow: [{ do: 'greet' }],
|
|
48
|
+
outputs: { result: '=$output.greet' },
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
describe('workflow definition resource helpers', () => {
|
|
52
|
+
it('collects unique resource references by descriptor kind', () => {
|
|
53
|
+
expect(
|
|
54
|
+
collectWorkflowDefinitionResourceRefs(definition, descriptors),
|
|
55
|
+
).toEqual({
|
|
56
|
+
memory: ['memory-1'],
|
|
57
|
+
mcp: ['mcp-1'],
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('remaps resource references without mutating the original definition', () => {
|
|
62
|
+
const updated = remapWorkflowDefinitionResourceRefs(
|
|
63
|
+
definition,
|
|
64
|
+
descriptors,
|
|
65
|
+
{
|
|
66
|
+
memory: { 'memory-1': 'memory-local' },
|
|
67
|
+
mcp: { 'mcp-1': 'mcp-local' },
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
expect(updated).not.toBe(definition);
|
|
72
|
+
expect(updated.defs.profile_memory.settings).toEqual({
|
|
73
|
+
definition_id: 'memory-local',
|
|
74
|
+
});
|
|
75
|
+
expect(updated.defs.duplicate_profile_memory.settings).toEqual({
|
|
76
|
+
definition_id: 'memory-local',
|
|
77
|
+
});
|
|
78
|
+
expect(updated.defs.search_mcp.settings).toEqual({
|
|
79
|
+
server_id: 'mcp-local',
|
|
80
|
+
});
|
|
81
|
+
expect(definition.defs.profile_memory.settings).toEqual({
|
|
82
|
+
definition_id: 'memory-1',
|
|
83
|
+
});
|
|
84
|
+
expect(definition.defs.search_mcp.settings).toEqual({
|
|
85
|
+
server_id: 'mcp-1',
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('returns the original definition when no refs change', () => {
|
|
90
|
+
expect(
|
|
91
|
+
remapWorkflowDefinitionResourceRefs(definition, descriptors, {
|
|
92
|
+
memory: {},
|
|
93
|
+
mcp: {},
|
|
94
|
+
}),
|
|
95
|
+
).toBe(definition);
|
|
96
|
+
});
|
|
97
|
+
});
|