@hexabot-ai/agentic 3.2.1 → 3.2.3

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.
@@ -67,6 +67,18 @@ class RunnerRuntimeControl {
67
67
  this.enqueueSuspension(request);
68
68
  return request.resume.promise;
69
69
  }
70
+ hasRecordedResult(key) {
71
+ const currentStep = this.runner.getCurrentStep();
72
+ if (!currentStep) {
73
+ return false;
74
+ }
75
+ const execution = this.ensureStepExecution(currentStep.id);
76
+ const suspendKey = buildSuspendKey(execution.suspendCursor + 1, key);
77
+ if (execution.awaitResults.has(suspendKey)) {
78
+ return true;
79
+ }
80
+ return (this.primedResumeData.get(currentStep.id)?.length ?? 0) > 0;
81
+ }
70
82
  resume(data) {
71
83
  void this.runner.resume({ resumeData: data });
72
84
  }
@@ -191,6 +191,11 @@ class ParallelWorkflowRuntimeControl {
191
191
  suspend() {
192
192
  return Promise.reject(new errors_1.ParallelSuspensionError());
193
193
  }
194
+ hasRecordedResult() {
195
+ // Suspension is not supported inside parallel blocks, so no resume
196
+ // result can ever be recorded for them.
197
+ return false;
198
+ }
194
199
  resume(data) {
195
200
  this.getParent().resume(data);
196
201
  }
@@ -12,16 +12,16 @@ exports.mergeSettings = exports.evaluateMapping = exports.evaluateValue = export
12
12
  const jsonata_1 = __importDefault(require("jsonata"));
13
13
  /** Basic object guard that rejects arrays and null. */
14
14
  const isPlainObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
15
- const resolveNestedExpressions = async (value, scope, seen = new WeakSet()) => {
15
+ const resolveNestedExpressions = async (value, scope, jsonataFunctions, seen = new WeakSet()) => {
16
16
  if (typeof value === 'string' && value.startsWith('=')) {
17
- return (0, exports.evaluateValue)((0, exports.compileValue)(value), scope);
17
+ return (0, exports.evaluateValue)((0, exports.compileValue)(value, { jsonataFunctions }), scope);
18
18
  }
19
19
  if (Array.isArray(value)) {
20
20
  if (seen.has(value)) {
21
21
  return value;
22
22
  }
23
23
  seen.add(value);
24
- return Promise.all(value.map((entry) => resolveNestedExpressions(entry, scope, seen)));
24
+ return Promise.all(value.map((entry) => resolveNestedExpressions(entry, scope, jsonataFunctions, seen)));
25
25
  }
26
26
  if (isPlainObject(value)) {
27
27
  if (seen.has(value)) {
@@ -30,7 +30,7 @@ const resolveNestedExpressions = async (value, scope, seen = new WeakSet()) => {
30
30
  seen.add(value);
31
31
  const entries = await Promise.all(Object.entries(value).map(async ([key, entry]) => [
32
32
  key,
33
- await resolveNestedExpressions(entry, scope, seen),
33
+ await resolveNestedExpressions(entry, scope, jsonataFunctions, seen),
34
34
  ]));
35
35
  return Object.fromEntries(entries);
36
36
  }
@@ -57,12 +57,13 @@ const registerJsonataFunctions = (expression, registry) => {
57
57
  * Strings prefixed with `=` are treated as JSONata expressions; everything else is a literal.
58
58
  */
59
59
  const compileValue = (value, options) => {
60
+ const jsonataFunctions = options?.jsonataFunctions;
60
61
  if (typeof value === 'string' && value.startsWith('=')) {
61
62
  const expression = (0, jsonata_1.default)(value.slice(1));
62
- registerJsonataFunctions(expression, options?.jsonataFunctions);
63
- return { kind: 'expression', source: value, expression };
63
+ registerJsonataFunctions(expression, jsonataFunctions);
64
+ return { kind: 'expression', source: value, expression, jsonataFunctions };
64
65
  }
65
- return { kind: 'literal', value };
66
+ return { kind: 'literal', value, jsonataFunctions };
66
67
  };
67
68
  exports.compileValue = compileValue;
68
69
  /**
@@ -94,7 +95,7 @@ const evaluateMapping = async (mapping, scope) => {
94
95
  }
95
96
  const entries = await Promise.all(Object.entries(mapping).map(async ([key, compiled]) => [
96
97
  key,
97
- await resolveNestedExpressions(await (0, exports.evaluateValue)(compiled, scope), scope),
98
+ await resolveNestedExpressions(await (0, exports.evaluateValue)(compiled, scope), scope, compiled.jsonataFunctions),
98
99
  ]));
99
100
  const result = Object.fromEntries(entries);
100
101
  return result;
@@ -63,6 +63,18 @@ export class RunnerRuntimeControl {
63
63
  this.enqueueSuspension(request);
64
64
  return request.resume.promise;
65
65
  }
66
+ hasRecordedResult(key) {
67
+ const currentStep = this.runner.getCurrentStep();
68
+ if (!currentStep) {
69
+ return false;
70
+ }
71
+ const execution = this.ensureStepExecution(currentStep.id);
72
+ const suspendKey = buildSuspendKey(execution.suspendCursor + 1, key);
73
+ if (execution.awaitResults.has(suspendKey)) {
74
+ return true;
75
+ }
76
+ return (this.primedResumeData.get(currentStep.id)?.length ?? 0) > 0;
77
+ }
66
78
  resume(data) {
67
79
  void this.runner.resume({ resumeData: data });
68
80
  }
@@ -188,6 +188,11 @@ class ParallelWorkflowRuntimeControl {
188
188
  suspend() {
189
189
  return Promise.reject(new ParallelSuspensionError());
190
190
  }
191
+ hasRecordedResult() {
192
+ // Suspension is not supported inside parallel blocks, so no resume
193
+ // result can ever be recorded for them.
194
+ return false;
195
+ }
191
196
  resume(data) {
192
197
  this.getParent().resume(data);
193
198
  }
@@ -6,16 +6,16 @@
6
6
  import jsonata from 'jsonata';
7
7
  /** Basic object guard that rejects arrays and null. */
8
8
  const isPlainObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
9
- const resolveNestedExpressions = async (value, scope, seen = new WeakSet()) => {
9
+ const resolveNestedExpressions = async (value, scope, jsonataFunctions, seen = new WeakSet()) => {
10
10
  if (typeof value === 'string' && value.startsWith('=')) {
11
- return evaluateValue(compileValue(value), scope);
11
+ return evaluateValue(compileValue(value, { jsonataFunctions }), scope);
12
12
  }
13
13
  if (Array.isArray(value)) {
14
14
  if (seen.has(value)) {
15
15
  return value;
16
16
  }
17
17
  seen.add(value);
18
- return Promise.all(value.map((entry) => resolveNestedExpressions(entry, scope, seen)));
18
+ return Promise.all(value.map((entry) => resolveNestedExpressions(entry, scope, jsonataFunctions, seen)));
19
19
  }
20
20
  if (isPlainObject(value)) {
21
21
  if (seen.has(value)) {
@@ -24,7 +24,7 @@ const resolveNestedExpressions = async (value, scope, seen = new WeakSet()) => {
24
24
  seen.add(value);
25
25
  const entries = await Promise.all(Object.entries(value).map(async ([key, entry]) => [
26
26
  key,
27
- await resolveNestedExpressions(entry, scope, seen),
27
+ await resolveNestedExpressions(entry, scope, jsonataFunctions, seen),
28
28
  ]));
29
29
  return Object.fromEntries(entries);
30
30
  }
@@ -51,12 +51,13 @@ const registerJsonataFunctions = (expression, registry) => {
51
51
  * Strings prefixed with `=` are treated as JSONata expressions; everything else is a literal.
52
52
  */
53
53
  export const compileValue = (value, options) => {
54
+ const jsonataFunctions = options?.jsonataFunctions;
54
55
  if (typeof value === 'string' && value.startsWith('=')) {
55
56
  const expression = jsonata(value.slice(1));
56
- registerJsonataFunctions(expression, options?.jsonataFunctions);
57
- return { kind: 'expression', source: value, expression };
57
+ registerJsonataFunctions(expression, jsonataFunctions);
58
+ return { kind: 'expression', source: value, expression, jsonataFunctions };
58
59
  }
59
- return { kind: 'literal', value };
60
+ return { kind: 'literal', value, jsonataFunctions };
60
61
  };
61
62
  /**
62
63
  * Evaluate a compiled value against the current workflow scope.
@@ -86,7 +87,7 @@ export const evaluateMapping = async (mapping, scope) => {
86
87
  }
87
88
  const entries = await Promise.all(Object.entries(mapping).map(async ([key, compiled]) => [
88
89
  key,
89
- await resolveNestedExpressions(await evaluateValue(compiled, scope), scope),
90
+ await resolveNestedExpressions(await evaluateValue(compiled, scope), scope, compiled.jsonataFunctions),
90
91
  ]));
91
92
  const result = Object.fromEntries(entries);
92
93
  return result;
@@ -71,6 +71,18 @@ export interface WorkflowRuntimeControl {
71
71
  * @returns Promise resolved with the data supplied to {@link resume}.
72
72
  */
73
73
  suspend<T = unknown>(options?: SuspensionOptions): Promise<T>;
74
+ /**
75
+ * 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
79
+ * perform side effects before suspending must skip those side effects when
80
+ * this returns `true`, otherwise they run once per resume.
81
+ *
82
+ * @param key - Optional user key matching the `key` passed to `suspend`.
83
+ * @returns `true` when the upcoming suspension resolves from a recorded result.
84
+ */
85
+ hasRecordedResult(key?: string): boolean;
74
86
  resume(data?: unknown): void;
75
87
  getSnapshot(): WorkflowSnapshot;
76
88
  }
@@ -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,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CA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;;;;;OAKG;IACH,IAAI,QAAQ,IAAI,sBAAsB,CAMrC;IAED;;;;;OAKG;IACH,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,SAAS,GAAG,IAAI;CAGzE"}
@@ -44,6 +44,7 @@ export declare class RunnerRuntimeControl implements WorkflowRuntimeControl {
44
44
  get status(): WorkflowRunStatus;
45
45
  get resumeData(): unknown;
46
46
  suspend<T = unknown>(options?: SuspensionOptions): Promise<T>;
47
+ hasRecordedResult(key?: string): boolean;
47
48
  resume(data?: unknown): void;
48
49
  waitForStepSuspension(stepId: string): Promise<RuntimeSuspensionRequest>;
49
50
  beginStepExecution(stepId: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"runner-runtime-control.d.ts","sourceRoot":"","sources":["../../src/runner-runtime-control.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA8BxD,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,gBAAgB,CAAC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AkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IA+C1C,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI;IAsBpD,uBAAuB,CAAC,MAAM,EAAE,yBAAyB,GAAG,IAAI;IA6ChE,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;IA6B3D,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI;IAO9D,WAAW;IAIX,OAAO,CAAC,iBAAiB;IAyBzB,OAAO,CAAC,qBAAqB;IAkB7B,OAAO,CAAC,uBAAuB;IAmB/B,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,uBAAuB;IAqC/B,OAAO,CAAC,qBAAqB;IAa7B,OAAO,CAAC,qBAAqB;IAM7B,OAAO,CAAC,sBAAsB;CAW/B"}
@@ -1,4 +1,4 @@
1
- import type { Expression } from 'jsonata';
1
+ import type { Expression, Focus } from 'jsonata';
2
2
  import type { ZodType } from 'zod';
3
3
  import type { Action } from './action/action.types';
4
4
  import type { CompiledTaskBindings } from './bindings/base-binding';
@@ -6,14 +6,29 @@ import type { BaseWorkflowContext, WorkflowSnapshot } from './context';
6
6
  import type { Settings, TaskDefinition, WorkflowDefinition } from './dsl.types';
7
7
  import { StepType, type StepInfo } from './workflow-event-emitter';
8
8
  export type { CompiledTaskBindings } from './bindings/base-binding';
9
- /** Value representation used by the runtime after compilation. */
9
+ /** Custom function callable from JSONata expressions. */
10
+ export type JsonataFunctionImplementation = (this: Focus, ...args: any[]) => unknown;
11
+ /** Function implementation, optionally paired with a JSONata type signature. */
12
+ export type JsonataFunctionConfig = JsonataFunctionImplementation | {
13
+ implementation: JsonataFunctionImplementation;
14
+ signature?: string;
15
+ };
16
+ /** Map of function names to implementations, registered on compiled expressions. */
17
+ export type JsonataFunctionRegistry = Record<string, JsonataFunctionConfig>;
18
+ /**
19
+ * Value representation used by the runtime after compilation.
20
+ * The function registry is kept so nested `=` expressions discovered at
21
+ * evaluation time can be compiled with the same custom functions.
22
+ */
10
23
  export type CompiledValue = {
11
24
  kind: 'literal';
12
25
  value: unknown;
26
+ jsonataFunctions?: JsonataFunctionRegistry;
13
27
  } | {
14
28
  kind: 'expression';
15
29
  source: string;
16
30
  expression: Expression;
31
+ jsonataFunctions?: JsonataFunctionRegistry;
17
32
  };
18
33
  /** Map of variable names to compiled values. */
19
34
  export type CompiledMapping = Record<string, CompiledValue>;
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-types.d.ts","sourceRoot":"","sources":["../../src/workflow-types.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEnE,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAEpE,kEAAkE;AAClE,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CAAC;AAEnE,gDAAgD;AAChD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAE5D,yEAAyE;AACzE,M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AAC;AAEF,oDAAoD;AACpD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC"}
@@ -1,12 +1,6 @@
1
- import type { Focus } from 'jsonata';
2
1
  import type { Settings } from './dsl.types';
3
- import type { CompiledMapping, CompiledValue, EvaluationScope } from './workflow-types';
4
- export type JsonataFunctionImplementation = (this: Focus, ...args: any[]) => unknown;
5
- export type JsonataFunctionConfig = JsonataFunctionImplementation | {
6
- implementation: JsonataFunctionImplementation;
7
- signature?: string;
8
- };
9
- export type JsonataFunctionRegistry = Record<string, JsonataFunctionConfig>;
2
+ import type { CompiledMapping, CompiledValue, EvaluationScope, JsonataFunctionRegistry } from './workflow-types';
3
+ export type { JsonataFunctionConfig, JsonataFunctionImplementation, JsonataFunctionRegistry, } from './workflow-types';
10
4
  export type CompileValueOptions = {
11
5
  jsonataFunctions?: JsonataFunctionRegistry;
12
6
  };
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-values.d.ts","sourceRoot":"","sources":["../../src/workflow-values.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAc,KAAK,EAAE,MAAM,SAAS,CAAC;AAGjD,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACb,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,6BAA6B,GAAG,CAC1C,IAAI,EAAE,KAAK,EACX,GAAG,IAAI,EAAE,GAAG,EAAE,KACX,OAAO,CAAC;AAEb,MAAM,MAAM,qBAAqB,GAC7B,6BAA6B,GAC7B;IACE,cAAc,EAAE,6BAA6B,CAAC;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEN,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;AAE5E,MAAM,MAAM,mBAAmB,GAAG;IAChC,gBAAgB,CAAC,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AAe,KACrB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAkBjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO,OAAO,CAAC,QAAQ,CAAC,EACxB,WAAW,OAAO,CAAC,QAAQ,CAAC,KAC3B,OAAO,CAAC,QAAQ,CAsBlB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hexabot-ai/agentic",
3
- "version": "3.2.1",
3
+ "version": "3.2.3",
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",
@@ -1341,6 +1341,191 @@ describe('WorkflowRunner', () => {
1341
1341
  }
1342
1342
  });
1343
1343
 
1344
+ it('lets actions skip side effects via hasRecordedResult when replaying a resumed step', async () => {
1345
+ const sideEffects: string[] = [];
1346
+ const spawnAction = defineAction<
1347
+ unknown,
1348
+ { reply: string },
1349
+ TestContext,
1350
+ Settings
1351
+ >({
1352
+ name: 'spawn_then_wait_action',
1353
+ inputSchema: z.any(),
1354
+ outputSchema: z.object({ reply: z.string() }),
1355
+ execute: async ({ context }) => {
1356
+ // Deterministic replay re-runs this body; the guard must prevent the
1357
+ // side effect from executing a second time.
1358
+ if (!context.workflow.hasRecordedResult()) {
1359
+ sideEffects.push('spawn');
1360
+ }
1361
+
1362
+ const resumeData = (await context.workflow.suspend({
1363
+ reason: 'awaiting_child_workflow',
1364
+ })) as { reply: string };
1365
+
1366
+ return { reply: resumeData.reply };
1367
+ },
1368
+ });
1369
+ const definition: WorkflowDefinition = {
1370
+ defs: createTaskDefs({
1371
+ wait_step: {
1372
+ action: 'spawn_then_wait_action',
1373
+ inputs: {},
1374
+ },
1375
+ }),
1376
+ flow: [{ do: 'wait_step' }],
1377
+ outputs: { reply: '=$output.wait_step.reply' },
1378
+ };
1379
+ const compiled = compileWorkflow(definition, {
1380
+ actions: { spawn_then_wait_action: spawnAction },
1381
+ });
1382
+ const runner = new WorkflowRunner(compiled);
1383
+ const startResult = await runner.start({
1384
+ inputData: {},
1385
+ context: new TestContext({}),
1386
+ });
1387
+
1388
+ expect(startResult.status).toBe('suspended');
1389
+ if (startResult.status !== 'suspended') {
1390
+ throw new Error('Workflow did not suspend as expected');
1391
+ }
1392
+
1393
+ expect(sideEffects).toEqual(['spawn']);
1394
+
1395
+ const runtimeState = runner.getState() as ExecutionState;
1396
+ const rebuilt = await WorkflowRunner.fromPersistedState(compiled, {
1397
+ state: {
1398
+ input: { ...runtimeState.input },
1399
+ output: { ...runtimeState.output },
1400
+ iteration: runtimeState.iteration,
1401
+ accumulator: runtimeState.accumulator,
1402
+ iterationStack: [...runtimeState.iterationStack],
1403
+ },
1404
+ context: new TestContext({}),
1405
+ snapshot: startResult.snapshot,
1406
+ suspension: {
1407
+ stepId: startResult.step.id,
1408
+ reason: startResult.reason ?? null,
1409
+ data: startResult.data,
1410
+ stepExecId: startResult.stepExecId,
1411
+ suspendIndex: startResult.suspendIndex,
1412
+ suspendKey: startResult.suspendKey,
1413
+ awaitResults: startResult.awaitResults,
1414
+ },
1415
+ });
1416
+ const resumeResult = await rebuilt.resume({
1417
+ resumeData: { reply: 'child-finished' },
1418
+ });
1419
+
1420
+ expect(resumeResult.status).toBe('finished');
1421
+ if (resumeResult.status === 'finished') {
1422
+ expect(resumeResult.output.reply).toBe('child-finished');
1423
+ }
1424
+
1425
+ // The side effect must not run a second time during deterministic replay.
1426
+ expect(sideEffects).toEqual(['spawn']);
1427
+ });
1428
+
1429
+ it('reports recorded results only for suspensions that will replay immediately', async () => {
1430
+ const observed: boolean[] = [];
1431
+ const multiSuspendAction = defineAction<
1432
+ unknown,
1433
+ { firstReply: string; secondReply: string },
1434
+ TestContext,
1435
+ Settings
1436
+ >({
1437
+ name: 'observing_multi_suspend_action',
1438
+ inputSchema: z.any(),
1439
+ outputSchema: z.object({
1440
+ firstReply: z.string(),
1441
+ secondReply: z.string(),
1442
+ }),
1443
+ execute: async ({ context }) => {
1444
+ observed.push(context.workflow.hasRecordedResult());
1445
+ const first = (await context.workflow.suspend({
1446
+ reason: 'first_pause',
1447
+ })) as { reply: string };
1448
+
1449
+ observed.push(context.workflow.hasRecordedResult());
1450
+ const second = (await context.workflow.suspend({
1451
+ reason: 'second_pause',
1452
+ })) as { reply: string };
1453
+
1454
+ return {
1455
+ firstReply: first.reply,
1456
+ secondReply: second.reply,
1457
+ };
1458
+ },
1459
+ });
1460
+ const definition: WorkflowDefinition = {
1461
+ defs: createTaskDefs({
1462
+ wait_step: {
1463
+ action: 'observing_multi_suspend_action',
1464
+ inputs: {},
1465
+ },
1466
+ }),
1467
+ flow: [{ do: 'wait_step' }],
1468
+ outputs: {
1469
+ firstReply: '=$output.wait_step.firstReply',
1470
+ secondReply: '=$output.wait_step.secondReply',
1471
+ },
1472
+ };
1473
+ const compiled = compileWorkflow(definition, {
1474
+ actions: { observing_multi_suspend_action: multiSuspendAction },
1475
+ });
1476
+ const runner = new WorkflowRunner(compiled);
1477
+ const firstSuspension = await runner.start({
1478
+ inputData: {},
1479
+ context: new TestContext({}),
1480
+ });
1481
+ expect(firstSuspension.status).toBe('suspended');
1482
+
1483
+ const secondSuspension = await runner.resume({
1484
+ resumeData: { reply: 'first-answer' },
1485
+ });
1486
+ expect(secondSuspension.status).toBe('suspended');
1487
+ if (secondSuspension.status !== 'suspended') {
1488
+ throw new Error('Workflow did not suspend on second await point');
1489
+ }
1490
+
1491
+ // In-memory execution never sees pre-recorded results.
1492
+ expect(observed).toEqual([false, false]);
1493
+
1494
+ const runtimeState = runner.getState() as ExecutionState;
1495
+ const rebuilt = await WorkflowRunner.fromPersistedState(compiled, {
1496
+ state: {
1497
+ input: { ...runtimeState.input },
1498
+ output: { ...runtimeState.output },
1499
+ iteration: runtimeState.iteration,
1500
+ accumulator: runtimeState.accumulator,
1501
+ iterationStack: [...runtimeState.iterationStack],
1502
+ },
1503
+ context: new TestContext({}),
1504
+ snapshot: secondSuspension.snapshot,
1505
+ suspension: {
1506
+ stepId: secondSuspension.step.id,
1507
+ reason: secondSuspension.reason ?? null,
1508
+ data: secondSuspension.data,
1509
+ stepExecId: secondSuspension.stepExecId,
1510
+ suspendIndex: secondSuspension.suspendIndex,
1511
+ suspendKey: secondSuspension.suspendKey,
1512
+ awaitResults: secondSuspension.awaitResults,
1513
+ },
1514
+ });
1515
+ const finalResult = await rebuilt.resume({
1516
+ resumeData: { reply: 'second-answer' },
1517
+ });
1518
+
1519
+ expect(finalResult.status).toBe('finished');
1520
+ if (finalResult.status === 'finished') {
1521
+ expect(finalResult.output.firstReply).toBe('first-answer');
1522
+ expect(finalResult.output.secondReply).toBe('second-answer');
1523
+ }
1524
+
1525
+ // During replay both suspensions have recorded results awaiting them.
1526
+ expect(observed).toEqual([false, false, true, true]);
1527
+ });
1528
+
1344
1529
  it('fails resume when replay suspension metadata does not match the workflow code path', async () => {
1345
1530
  const suspendAction = defineAction<
1346
1531
  unknown,
@@ -92,6 +92,32 @@ describe('workflow values', () => {
92
92
  });
93
93
  });
94
94
 
95
+ it('registers custom functions on nested expressions inside literal values', async () => {
96
+ const translate = jest.fn((key: string) => `translated:${key}`);
97
+ const mapping = {
98
+ payload: compileValue(
99
+ {
100
+ title: "=$t('Title')",
101
+ actions: ['=$t("Confirm")', { label: "=$t('Cancel')" }],
102
+ },
103
+ { jsonataFunctions: { t: translate } },
104
+ ),
105
+ };
106
+ const values = await evaluateMapping(mapping, {
107
+ input: {},
108
+ context: new TestContext().state,
109
+ output: {},
110
+ });
111
+
112
+ expect(values).toEqual({
113
+ payload: {
114
+ title: 'translated:Title',
115
+ actions: ['translated:Confirm', { label: 'translated:Cancel' }],
116
+ },
117
+ });
118
+ expect(translate).toHaveBeenCalledTimes(3);
119
+ });
120
+
95
121
  it('handles missing mappings and deep merges settings', async () => {
96
122
  await expect(
97
123
  evaluateMapping(undefined, {
package/src/context.ts CHANGED
@@ -99,6 +99,18 @@ export interface WorkflowRuntimeControl {
99
99
  * @returns Promise resolved with the data supplied to {@link resume}.
100
100
  */
101
101
  suspend<T = unknown>(options?: SuspensionOptions): Promise<T>;
102
+ /**
103
+ * Reports whether the next {@link suspend} call in the currently running
104
+ * action already has a recorded resume result. This happens during
105
+ * deterministic replay of a resumed step: the action body re-executes and
106
+ * `suspend()` resolves immediately with the recorded payload. Actions that
107
+ * perform side effects before suspending must skip those side effects when
108
+ * this returns `true`, otherwise they run once per resume.
109
+ *
110
+ * @param key - Optional user key matching the `key` passed to `suspend`.
111
+ * @returns `true` when the upcoming suspension resolves from a recorded result.
112
+ */
113
+ hasRecordedResult(key?: string): boolean;
102
114
  resume(data?: unknown): void;
103
115
  getSnapshot(): WorkflowSnapshot;
104
116
  }
@@ -157,6 +157,21 @@ export class RunnerRuntimeControl implements WorkflowRuntimeControl {
157
157
  return request.resume.promise as Promise<T>;
158
158
  }
159
159
 
160
+ hasRecordedResult(key?: string): boolean {
161
+ const currentStep = this.runner.getCurrentStep();
162
+ if (!currentStep) {
163
+ return false;
164
+ }
165
+
166
+ const execution = this.ensureStepExecution(currentStep.id);
167
+ const suspendKey = buildSuspendKey(execution.suspendCursor + 1, key);
168
+ if (execution.awaitResults.has(suspendKey)) {
169
+ return true;
170
+ }
171
+
172
+ return (this.primedResumeData.get(currentStep.id)?.length ?? 0) > 0;
173
+ }
174
+
160
175
  resume(data?: unknown): void {
161
176
  void this.runner.resume({ resumeData: data });
162
177
  }
@@ -353,6 +353,12 @@ class ParallelWorkflowRuntimeControl implements WorkflowRuntimeControl {
353
353
  return Promise.reject(new ParallelSuspensionError());
354
354
  }
355
355
 
356
+ hasRecordedResult(): boolean {
357
+ // Suspension is not supported inside parallel blocks, so no resume
358
+ // result can ever be recorded for them.
359
+ return false;
360
+ }
361
+
356
362
  resume(data?: unknown): void {
357
363
  this.getParent().resume(data);
358
364
  }
@@ -4,7 +4,7 @@
4
4
  * Full terms: see LICENSE.md.
5
5
  */
6
6
 
7
- import type { Expression } from 'jsonata';
7
+ import type { Expression, Focus } from 'jsonata';
8
8
  import type { ZodType } from 'zod';
9
9
 
10
10
  import type { Action } from './action/action.types';
@@ -15,10 +15,40 @@ import { StepType, type StepInfo } from './workflow-event-emitter';
15
15
 
16
16
  export type { CompiledTaskBindings } from './bindings/base-binding';
17
17
 
18
- /** Value representation used by the runtime after compilation. */
18
+ /** Custom function callable from JSONata expressions. */
19
+ export type JsonataFunctionImplementation = (
20
+ this: Focus,
21
+ ...args: any[]
22
+ ) => unknown;
23
+
24
+ /** Function implementation, optionally paired with a JSONata type signature. */
25
+ export type JsonataFunctionConfig =
26
+ | JsonataFunctionImplementation
27
+ | {
28
+ implementation: JsonataFunctionImplementation;
29
+ signature?: string;
30
+ };
31
+
32
+ /** Map of function names to implementations, registered on compiled expressions. */
33
+ export type JsonataFunctionRegistry = Record<string, JsonataFunctionConfig>;
34
+
35
+ /**
36
+ * Value representation used by the runtime after compilation.
37
+ * The function registry is kept so nested `=` expressions discovered at
38
+ * evaluation time can be compiled with the same custom functions.
39
+ */
19
40
  export type CompiledValue =
20
- | { kind: 'literal'; value: unknown }
21
- | { kind: 'expression'; source: string; expression: Expression };
41
+ | {
42
+ kind: 'literal';
43
+ value: unknown;
44
+ jsonataFunctions?: JsonataFunctionRegistry;
45
+ }
46
+ | {
47
+ kind: 'expression';
48
+ source: string;
49
+ expression: Expression;
50
+ jsonataFunctions?: JsonataFunctionRegistry;
51
+ };
22
52
 
23
53
  /** Map of variable names to compiled values. */
24
54
  export type CompiledMapping = Record<string, CompiledValue>;
@@ -4,7 +4,7 @@
4
4
  * Full terms: see LICENSE.md.
5
5
  */
6
6
 
7
- import type { Expression, Focus } from 'jsonata';
7
+ import type { Expression } from 'jsonata';
8
8
  import jsonata from 'jsonata';
9
9
 
10
10
  import type { JsonValue, Settings } from './dsl.types';
@@ -12,21 +12,14 @@ import type {
12
12
  CompiledMapping,
13
13
  CompiledValue,
14
14
  EvaluationScope,
15
+ JsonataFunctionRegistry,
15
16
  } from './workflow-types';
16
17
 
17
- export type JsonataFunctionImplementation = (
18
- this: Focus,
19
- ...args: any[]
20
- ) => unknown;
21
-
22
- export type JsonataFunctionConfig =
23
- | JsonataFunctionImplementation
24
- | {
25
- implementation: JsonataFunctionImplementation;
26
- signature?: string;
27
- };
28
-
29
- export type JsonataFunctionRegistry = Record<string, JsonataFunctionConfig>;
18
+ export type {
19
+ JsonataFunctionConfig,
20
+ JsonataFunctionImplementation,
21
+ JsonataFunctionRegistry,
22
+ } from './workflow-types';
30
23
 
31
24
  export type CompileValueOptions = {
32
25
  jsonataFunctions?: JsonataFunctionRegistry;
@@ -38,10 +31,11 @@ const isPlainObject = (value: unknown): value is Record<string, unknown> =>
38
31
  const resolveNestedExpressions = async (
39
32
  value: unknown,
40
33
  scope: EvaluationScope,
34
+ jsonataFunctions?: JsonataFunctionRegistry,
41
35
  seen: WeakSet<object> = new WeakSet(),
42
36
  ): Promise<unknown> => {
43
37
  if (typeof value === 'string' && value.startsWith('=')) {
44
- return evaluateValue(compileValue(value), scope);
38
+ return evaluateValue(compileValue(value, { jsonataFunctions }), scope);
45
39
  }
46
40
 
47
41
  if (Array.isArray(value)) {
@@ -51,7 +45,9 @@ const resolveNestedExpressions = async (
51
45
  seen.add(value);
52
46
 
53
47
  return Promise.all(
54
- value.map((entry) => resolveNestedExpressions(entry, scope, seen)),
48
+ value.map((entry) =>
49
+ resolveNestedExpressions(entry, scope, jsonataFunctions, seen),
50
+ ),
55
51
  );
56
52
  }
57
53
 
@@ -64,7 +60,7 @@ const resolveNestedExpressions = async (
64
60
  const entries = await Promise.all(
65
61
  Object.entries(value).map(async ([key, entry]) => [
66
62
  key,
67
- await resolveNestedExpressions(entry, scope, seen),
63
+ await resolveNestedExpressions(entry, scope, jsonataFunctions, seen),
68
64
  ]),
69
65
  );
70
66
 
@@ -108,14 +104,16 @@ export const compileValue = (
108
104
  value: unknown,
109
105
  options?: CompileValueOptions,
110
106
  ): CompiledValue => {
107
+ const jsonataFunctions = options?.jsonataFunctions;
108
+
111
109
  if (typeof value === 'string' && value.startsWith('=')) {
112
110
  const expression = jsonata(value.slice(1));
113
- registerJsonataFunctions(expression, options?.jsonataFunctions);
111
+ registerJsonataFunctions(expression, jsonataFunctions);
114
112
 
115
- return { kind: 'expression', source: value, expression };
113
+ return { kind: 'expression', source: value, expression, jsonataFunctions };
116
114
  }
117
115
 
118
- return { kind: 'literal', value };
116
+ return { kind: 'literal', value, jsonataFunctions };
119
117
  };
120
118
 
121
119
  /**
@@ -162,6 +160,7 @@ export const evaluateMapping = async (
162
160
  await resolveNestedExpressions(
163
161
  await evaluateValue(compiled, scope),
164
162
  scope,
163
+ compiled.jsonataFunctions,
165
164
  ),
166
165
  ]),
167
166
  );