@hexabot-ai/agentic 3.4.0 → 3.5.0-beta.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
@@ -1,65 +1,77 @@
1
- import type { SuspensionOptions, WorkflowRunStatus, WorkflowRuntimeControl } from './context';
2
- import type { Deferred } from './utils/deferred';
3
- import type { WorkflowRunner } from './workflow-runner';
1
+ import type { SuspensionOptions, WorkflowRuntimeControl } from './context';
2
+ import type { StepInfo } from './workflow-event-emitter';
3
+ /** A `suspend()` call the step executor has to turn into a wait. */
4
4
  export type RuntimeSuspensionRequest = {
5
- stepId: string;
6
- stepExecId: string;
7
- suspendIndex: number;
8
5
  suspendKey: string;
9
6
  reason?: string;
10
7
  data?: unknown;
8
+ /** Relaxed JSON Schema of the payload the wait accepts. */
9
+ accepts?: Record<string, unknown>;
10
+ /** Set when the `accepts` schema also accepts a resume without payload. */
11
+ payloadOptional?: boolean;
12
+ /** Suspend results already resolved for this step, keyed by suspend key. */
11
13
  awaitResults: Record<string, unknown>;
12
- resume: Deferred<unknown>;
13
14
  };
14
- export type RuntimeStepReplaySeed = {
15
- stepId: string;
16
- stepExecId: string;
17
- awaitResults?: Record<string, unknown>;
18
- activeSuspension?: {
19
- suspendIndex?: number;
20
- suspendKey?: string;
15
+ /** Seed for a task body that re-runs after its wait was resolved. */
16
+ export type StepReplaySeed = {
17
+ awaitResults: Record<string, unknown>;
18
+ /** Suspension the re-run body is expected to reach again. */
19
+ expected: {
20
+ suspendKey: string;
21
21
  reason?: string;
22
22
  };
23
23
  };
24
- export type RuntimeResolvedSuspension = {
25
- stepId: string;
26
- resumeData: unknown;
27
- stepExecId?: string;
28
- suspendIndex?: number;
29
- suspendKey?: string;
30
- };
31
- export declare class NonDeterministicWorkflowError extends Error {
32
- constructor(message: string);
33
- }
34
- /** Minimal wrapper that exposes runner controls to actions via the context. */
24
+ /**
25
+ * Suspension control for one concurrency scope of a run.
26
+ *
27
+ * Steps inside a scope run one at a time, so the scope tracks a single active
28
+ * step. The root flow owns one scope and every parallel branch forks its own,
29
+ * which is what lets concurrent branches suspend independently.
30
+ */
35
31
  export declare class RunnerRuntimeControl implements WorkflowRuntimeControl {
36
- private readonly runner;
37
- private readonly pendingSuspensions;
38
- private readonly suspensionWaiters;
39
- private readonly primedResumeData;
40
- private readonly stepAttempts;
41
- private readonly activeStepExecutions;
42
- private readonly replaySeeds;
43
- constructor(runner: WorkflowRunner);
44
- get status(): WorkflowRunStatus;
45
- get resumeData(): unknown;
46
- suspend<T = unknown>(options?: SuspensionOptions): Promise<T>;
32
+ private active?;
33
+ /**
34
+ * Create the scope of a concurrent region such as a parallel branch.
35
+ *
36
+ * @returns A new, independent scope.
37
+ */
38
+ fork(): RunnerRuntimeControl;
39
+ /**
40
+ * Mark a task step as running in this scope.
41
+ *
42
+ * @param step Instance step that is about to run its action.
43
+ * @param options.seed Previously resolved suspend results when the body re-runs.
44
+ */
45
+ beginStep(step: StepInfo, options?: {
46
+ seed?: StepReplaySeed;
47
+ }): void;
48
+ /**
49
+ * Release the active step.
50
+ *
51
+ * @param options.completed True when the action body returned successfully.
52
+ * @throws {NonDeterministicWorkflowError} When a re-run body completed
53
+ * without reaching the suspension it was resumed from.
54
+ */
55
+ endStep(options?: {
56
+ completed?: boolean;
57
+ }): void;
58
+ /**
59
+ * Wait for the active step's next `suspend()` call.
60
+ *
61
+ * @returns The next suspension request.
62
+ */
63
+ waitForSuspension(): Promise<RuntimeSuspensionRequest>;
64
+ suspend<T = unknown>(options?: SuspensionOptions<T>): Promise<T>;
65
+ /**
66
+ * Report whether the active step, re-run to resolve a wait, has reached
67
+ * that wait's `suspend()` call. Only from then on has it read the payload,
68
+ * and can it refuse it.
69
+ *
70
+ * @returns True once the resolved suspension was reached.
71
+ */
72
+ hasReachedResolvedSuspension(): boolean;
47
73
  hasRecordedResult(key?: string): boolean;
48
- resume(data?: unknown): void;
49
- waitForStepSuspension(stepId: string): Promise<RuntimeSuspensionRequest>;
50
- beginStepExecution(stepId: string): string;
51
- prepareStepReplay(seed: RuntimeStepReplaySeed): void;
52
- recordStepSuspendResult(params: RuntimeResolvedSuspension): void;
53
- clearStepSuspensions(stepId: string, error?: unknown): void;
54
- primeStepResumeData(stepId: string, resumeData: unknown): void;
55
- getSnapshot(): import("./context").WorkflowSnapshot;
56
- private enqueueSuspension;
57
- private dequeueStepSuspension;
58
- private dequeuePrimedResumeData;
59
- private ensureStepExecution;
74
+ markSuspendCursor(): () => void;
60
75
  private assertReplayExpectation;
61
- private normalizeAwaitResults;
62
- private serializeAwaitResults;
63
- private bumpStepAttemptCounter;
64
76
  }
65
77
  //# sourceMappingURL=runner-runtime-control.d.ts.map
@@ -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,MAA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,CAAC,CAAC;IA2DhE;;;;;;OAMG;IACH,4BAA4B,IAAI,OAAO;IAIvC,iBAAiB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO;IASxC,iBAAiB,IAAI,MAAM,IAAI;IAkB/B,OAAO,CAAC,uBAAuB;CAgChC"}
@@ -1,4 +1,5 @@
1
- import type { ConditionalStep, ExecutionState, Suspension } from '../workflow-types';
1
+ import type { ConditionalFrame } from '../checkpoint';
2
+ import type { ConditionalStep, ExecutionState } from '../workflow-types';
2
3
  import type { StepExecutorEnv } from './types';
3
4
  /**
4
5
  * Evaluate a conditional step by checking branches in order and executing the first match.
@@ -7,7 +8,9 @@ import type { StepExecutorEnv } from './types';
7
8
  * @param step The conditional step definition.
8
9
  * @param state Mutable workflow execution state.
9
10
  * @param path Path tokens locating this step within the workflow tree.
10
- * @returns A suspension if a branch pauses execution, otherwise void.
11
+ * @param frame Frame returned when the chosen branch previously suspended; its
12
+ * branch is re-entered without evaluating conditions again.
13
+ * @returns A frame if the chosen branch suspends, otherwise void.
11
14
  */
12
- export declare function executeConditional(env: StepExecutorEnv, step: ConditionalStep, state: ExecutionState, path: Array<number | string>): Promise<Suspension | void>;
15
+ export declare function executeConditional(env: StepExecutorEnv, step: ConditionalStep, state: ExecutionState, path: Array<number | string>, frame?: ConditionalFrame): Promise<ConditionalFrame | void>;
13
16
  //# sourceMappingURL=conditional-executor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"conditional-executor.d.ts","sourceRoot":"","sources":["../../../src/step-executors/conditional-executor.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,UAAU,EACX,MAAM,mBAAmB,CAAC;AAI3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,eAAe,EACrB,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAC3B,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAoD5B"}
1
+ {"version":3,"file":"conditional-executor.d.ts","sourceRoot":"","sources":["../../../src/step-executors/conditional-executor.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAIzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;;;;;GAUG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,eAAe,EACrB,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,EAC5B,KAAK,CAAC,EAAE,gBAAgB,GACvB,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAgClC"}
@@ -1,4 +1,5 @@
1
- import type { EvaluationScope, ExecutionState, LoopStep, Suspension } from '../workflow-types';
1
+ import type { LoopFrame } from '../checkpoint';
2
+ import type { EvaluationScope, ExecutionState, LoopStep } from '../workflow-types';
2
3
  import type { StepExecutorEnv } from './types';
3
4
  type LoopScope = EvaluationScope;
4
5
  /**
@@ -8,10 +9,11 @@ type LoopScope = EvaluationScope;
8
9
  * @param step The loop step configuration.
9
10
  * @param state Mutable workflow execution state.
10
11
  * @param path Path tokens locating this loop within the workflow.
11
- * @param startIndex Index to resume iteration from when continuing.
12
- * @returns A suspension if a child step pauses execution, otherwise void.
12
+ * @param frame Frame returned when an iteration previously suspended; the
13
+ * loop resumes that iteration with the items and accumulator it recorded.
14
+ * @returns A frame if an iteration suspends, otherwise void.
13
15
  */
14
- export declare function executeLoop(env: StepExecutorEnv, step: LoopStep, state: ExecutionState, path: Array<number | string>, startIndex?: number): Promise<Suspension | void>;
16
+ export declare function executeLoop(env: StepExecutorEnv, step: LoopStep, state: ExecutionState, path: Array<number | string>, frame?: LoopFrame): Promise<LoopFrame | void>;
15
17
  /**
16
18
  * Update the loop accumulator using the configured merge expression.
17
19
  *
@@ -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;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
+ {"version":3,"file":"loop-executor.d.ts","sourceRoot":"","sources":["../../../src/step-executors/loop-executor.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EAEd,QAAQ,EAET,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,KAAK,SAAS,GAAG,eAAe,CAAC;AAEjC;;;;;;;;;;GAUG;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,KAAK,CAAC,EAAE,SAAS,GAChB,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAM3B;AA8JD;;;;;;;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,13 +1,21 @@
1
- import type { ExecutionState, ParallelStep, Suspension } from '../workflow-types';
1
+ import { type ParallelFrame } from '../checkpoint';
2
+ import type { ExecutionState, ParallelStep } from '../workflow-types';
2
3
  import type { StepExecutorEnv } from './types';
3
4
  /**
4
5
  * Execute a set of child steps concurrently and resolve according to the configured strategy.
5
6
  *
7
+ * A branch may suspend. The block then waits until every branch has settled
8
+ * (fulfilled, suspended, or failed) before suspending itself, so a sibling that
9
+ * was still running finishes exactly once instead of being re-run on resume.
10
+ *
6
11
  * @param env Executor environment providing helpers and workflow context.
7
12
  * @param step The parallel step definition including strategy and children.
8
13
  * @param state Mutable workflow execution state.
9
14
  * @param path Path tokens locating this parallel block in the workflow.
10
- * @returns Always undefined; suspensions are rejected inside parallel blocks.
15
+ * @param frame Frame returned when the block previously suspended: fulfilled
16
+ * branches are not launched again, parked ones stay parked unless this pass
17
+ * resolves one of their waits, and those resume from their frame.
18
+ * @returns A frame if any branch is left suspended, otherwise void.
11
19
  */
12
- export declare function executeParallel(env: StepExecutorEnv, step: ParallelStep, state: ExecutionState, path: Array<number | string>): Promise<Suspension | void>;
20
+ export declare function executeParallel(env: StepExecutorEnv, step: ParallelStep, state: ExecutionState, path: Array<number | string>, frame?: ParallelFrame): Promise<ParallelFrame | void>;
13
21
  //# sourceMappingURL=parallel-executor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parallel-executor.d.ts","sourceRoot":"","sources":["../../../src/step-executors/parallel-executor.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAEV,cAAc,EACd,YAAY,EACZ,UAAU,EACX,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAoB/C;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAC3B,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CA0B5B"}
1
+ {"version":3,"file":"parallel-executor.d.ts","sourceRoot":"","sources":["../../../src/step-executors/parallel-executor.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,eAAe,CAAC;AAUvB,OAAO,KAAK,EAEV,cAAc,EACd,YAAY,EACb,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AA0B/C;;;;;;;;;;;;;;;GAeG;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,KAAK,CAAC,EAAE,aAAa,GACpB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CA2C/B"}
@@ -1,13 +1,20 @@
1
- import type { ExecutionState, Suspension, TaskStep } from '../workflow-types';
1
+ import { type TaskFrame } from '../checkpoint';
2
+ import type { ExecutionState, TaskStep } from '../workflow-types';
2
3
  import type { StepExecutorEnv } from './types';
3
4
  /**
4
- * Execute a task step by running its task and handling suspension or output mapping.
5
+ * Execute a task step, returning a frame when its action suspends.
6
+ *
7
+ * Given a frame, the step either stays parked (its wait is not resolved by
8
+ * this pass) or re-runs its action body: earlier `suspend()` calls resolve
9
+ * from the frame, including the one this pass resolved. A body that refuses
10
+ * that payload returns the frame unchanged, so the wait stays open.
5
11
  *
6
12
  * @param env Executor environment with compiled workflow and helpers.
7
13
  * @param step The compiled task step to execute.
8
14
  * @param state Mutable workflow execution state.
9
15
  * @param _path Location of the step within the workflow (unused in this executor).
10
- * @returns A suspension if the task pauses execution, otherwise void.
16
+ * @param frame Frame returned when this step previously suspended.
17
+ * @returns A frame if the task suspends, otherwise void.
11
18
  */
12
- export declare function executeTaskStep(env: StepExecutorEnv, step: TaskStep, state: ExecutionState, _path: Array<number | string>): Promise<Suspension | void>;
19
+ export declare function executeTaskStep(env: StepExecutorEnv, step: TaskStep, state: ExecutionState, _path: Array<number | string>, frame?: TaskFrame): Promise<TaskFrame | void>;
13
20
  //# sourceMappingURL=task-executor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"task-executor.d.ts","sourceRoot":"","sources":["../../../src/step-executors/task-executor.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAGV,cAAc,EACd,UAAU,EACV,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAQ/C;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAC5B,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CA+F5B"}
1
+ {"version":3,"file":"task-executor.d.ts","sourceRoot":"","sources":["../../../src/step-executors/task-executor.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,SAAS,EAEf,MAAM,eAAe,CAAC;AAgBvB,OAAO,KAAK,EAGV,cAAc,EACd,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAQ/C;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,EAC7B,KAAK,CAAC,EAAE,SAAS,GAChB,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CA6I3B"}
@@ -1,32 +1,40 @@
1
+ import type { SequenceFrame, StepFrame } from '../checkpoint';
1
2
  import type { ActionSnapshot, BaseWorkflowContext, StepExecutionRecord } from '../context';
2
- import type { RuntimeResolvedSuspension, RuntimeStepReplaySeed, RuntimeSuspensionRequest } from '../runner-runtime-control';
3
+ import type { RunnerRuntimeControl } from '../runner-runtime-control';
3
4
  import type { StepInfo, WorkflowEventMap } from '../workflow-event-emitter';
4
- import type { CompiledStep, CompiledTask, CompiledWorkflow, ExecutionState, Suspension } from '../workflow-types';
5
+ import type { CompiledStep, CompiledTask, CompiledWorkflow, ExecutionState, ResumeRejection } from '../workflow-types';
5
6
  export type StepExecutorEnvForkOverrides = {
6
7
  context?: BaseWorkflowContext;
7
8
  signal?: AbortSignal;
8
- setCurrentStep?: (step?: StepInfo) => void;
9
- captureTaskOutput?: (task: CompiledTask, state: ExecutionState, result: unknown) => Promise<void>;
9
+ runtime?: RunnerRuntimeControl;
10
10
  };
11
+ /**
12
+ * Everything a step executor needs from the runner.
13
+ *
14
+ * Executors return a frame when the step suspends and `undefined` when it
15
+ * completes. Passing that frame back in resumes the step where it stopped.
16
+ */
11
17
  export type StepExecutorEnv = {
12
18
  compiled: CompiledWorkflow;
13
19
  context: BaseWorkflowContext;
14
20
  signal: AbortSignal;
15
21
  runId?: string;
22
+ /** Suspension control of the concurrency scope this env runs in. */
23
+ runtime: RunnerRuntimeControl;
24
+ /** Resume payloads for the waits this execution pass satisfies, by wait id. */
25
+ resolutions: ReadonlyMap<string, unknown>;
26
+ /**
27
+ * Report that a resumed step refused its payload. The runner then leaves
28
+ * the run exactly as it was before this pass.
29
+ */
30
+ rejectResume: (rejection: ResumeRejection) => void;
16
31
  buildInstanceStepInfo: (step: CompiledStep, iterationStack: number[]) => StepInfo;
17
32
  markSnapshot: (step: StepInfo, status: ActionSnapshot['status'], reason?: string) => void;
18
33
  recordStepExecution: (step: StepInfo, update: Partial<StepExecutionRecord>) => StepExecutionRecord;
19
34
  emit: <K extends keyof WorkflowEventMap>(event: K, payload: WorkflowEventMap[K]) => void;
20
- setCurrentStep: (step?: StepInfo) => void;
21
- beginStepExecution?: (stepId: string) => string;
22
- waitForStepSuspension: (stepId: string) => Promise<RuntimeSuspensionRequest>;
23
- clearStepSuspensions: (stepId: string, error?: unknown) => void;
24
- primeStepResumeData: (stepId: string, resumeData: unknown) => void;
25
- prepareStepReplay?: (seed: RuntimeStepReplaySeed) => void;
26
- recordStepSuspendResult?: (params: RuntimeResolvedSuspension) => void;
27
35
  captureTaskOutput: (task: CompiledTask, state: ExecutionState, result: unknown) => Promise<void>;
28
- executeFlow: (steps: CompiledStep[], state: ExecutionState, path: Array<number | string>, startIndex?: number) => Promise<Suspension | void>;
29
- executeStep: (step: CompiledStep, state: ExecutionState, path: Array<number | string>) => Promise<Suspension | void>;
36
+ executeFlow: (steps: CompiledStep[], state: ExecutionState, path: Array<number | string>, frame?: SequenceFrame) => Promise<SequenceFrame | void>;
37
+ executeStep: (step: CompiledStep, state: ExecutionState, path: Array<number | string>, frame?: StepFrame) => Promise<StepFrame | void>;
30
38
  fork: (overrides: StepExecutorEnvForkOverrides) => StepExecutorEnv;
31
39
  };
32
40
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/step-executors/types.ts"],"names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EAAE,QAAQ,EACd,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,KACjC,mBAAmB,CAAC;IACzB,IAAI,EAAE,CAAC,CAAC,SAAS,MAAM,gBAAgB,EACrC,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,KACzB,IAAI,CAAC;IACV,iBAAiB,EAAE,CACjB,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,cAAc,EACrB,MAAM,EAAE,OAAO,KACZ,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,WAAW,EAAE,CACX,KAAK,EAAE,YAAY,EAAE,EACrB,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,EAC5B,KAAK,CAAC,EAAE,aAAa,KAClB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IACnC,WAAW,EAAE,CACX,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,EAC5B,KAAK,CAAC,EAAE,SAAS,KACd,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IAC/B,IAAI,EAAE,CAAC,SAAS,EAAE,4BAA4B,KAAK,eAAe,CAAC;CACpE,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Deep-clone a value, preferring `structuredClone` and falling back to a JSON
3
+ * round trip, then to a shallow copy for values neither can handle.
4
+ *
5
+ * @param value The value to clone.
6
+ * @returns A detached copy of the value.
7
+ */
8
+ export declare function cloneValue<T>(value: T): T;
9
+ /**
10
+ * Copy a value through a JSON round trip, exactly as a host persisting it
11
+ * would: dates become ISO strings, and `undefined` values and functions are
12
+ * dropped.
13
+ *
14
+ * @param value The value to copy.
15
+ * @returns A detached, JSON-only copy of the value.
16
+ * @throws {TypeError} When JSON cannot encode the value (BigInt, cycles).
17
+ */
18
+ export declare function cloneAsJson<T>(value: T): T;
19
+ /**
20
+ * Deep-clone a record.
21
+ *
22
+ * @param value The record to clone.
23
+ * @returns A detached copy of the record.
24
+ */
25
+ export declare function cloneRecord(value: Record<string, unknown>): Record<string, unknown>;
26
+ /**
27
+ * Report whether a value is a plain (non-array) object.
28
+ *
29
+ * @param value The value to check.
30
+ * @returns True when the value is a non-null, non-array object.
31
+ */
32
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
33
+ //# sourceMappingURL=clone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../../src/utils/clone.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CA0BzC;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAE1C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE"}
@@ -1,4 +1,6 @@
1
+ import type { WaitInfo } from './checkpoint';
1
2
  import type { StepExecutionRecord } from './context';
3
+ import type { WorkflowResumeRejectedError } from './errors';
2
4
  export declare enum StepType {
3
5
  Task = "task",
4
6
  Parallel = "parallel",
@@ -29,21 +31,43 @@ export type WorkflowEventMap = {
29
31
  };
30
32
  'hook:workflow:suspended': {
31
33
  runId?: string;
32
- step: StepInfo;
33
- reason?: string;
34
- data?: unknown;
34
+ /** Every open wait of the run, in flow order. */
35
+ waits: WaitInfo[];
36
+ };
37
+ /** A resume payload was refused; the run is unchanged and the wait stays open. */
38
+ 'hook:workflow:resume_rejected': {
39
+ runId?: string;
40
+ /** The wait the payload was meant for. */
41
+ wait: WaitInfo;
42
+ /** The payload as passed to `resume()`. */
43
+ resumeData: unknown;
44
+ error: WorkflowResumeRejectedError;
35
45
  };
36
46
  'hook:step:start': StepWorkflowEventPayload;
47
+ /** A suspended step whose wait was resolved re-runs its action body. */
48
+ 'hook:step:resumed': StepWorkflowEventPayload & {
49
+ /** The wait this resume resolved. */
50
+ wait: WaitInfo;
51
+ /** The payload recorded for the wait, after its JSON round trip. */
52
+ resumeData: unknown;
53
+ };
54
+ /** A resumed step refused its payload and is suspended again on the same wait. */
55
+ 'hook:step:resume_rejected': StepWorkflowEventPayload & {
56
+ wait: WaitInfo;
57
+ error: WorkflowResumeRejectedError;
58
+ };
37
59
  'hook:step:success': StepWorkflowEventPayload;
38
60
  'hook:step:error': StepWorkflowEventPayload & {
39
61
  error: unknown;
40
62
  };
41
63
  'hook:step:cancelled': StepWorkflowEventPayload & {
42
64
  error: unknown;
65
+ /** The wait the step was suspended on, which is now dropped. */
66
+ wait?: WaitInfo;
43
67
  };
44
68
  'hook:step:suspended': StepWorkflowEventPayload & {
45
- reason?: string;
46
- data?: unknown;
69
+ /** The wait this suspension opened. */
70
+ wait: WaitInfo;
47
71
  };
48
72
  'hook:step:skipped': {
49
73
  runId?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-event-emitter.d.ts","sourceRoot":"","sources":["../../src/workflow-event-emitter.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAErD,oBAAY,QAAQ;IAClB,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,WAAW,gBAAgB;IAC3B,IAAI,SAAS;CACd;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,CA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;IACF,qBAAqB,EAAE,wBAAwB,GAAG;QAChD,uCAAuC;QACvC,IAAI,EAAE,QAAQ,CAAC;KAChB,CAAC;IACF,mBAAmB,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,QAAQ,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1E,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACtD,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC;CACzE,CAAC;AAEF,MAAM,MAAM,wBAAwB,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,GAAG,gBAAgB,CAAC;AAKzE;;;;GAIG;AACH,qBAAa,oBACX,YAAW,wBAAwB,CAAC,oBAAoB,CAAC;IAEzD,OAAO,CAAC,SAAS,CAAyC;IAE1D,IAAI,CAAC,CAAC,SAAS,MAAM,gBAAgB,EACnC,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAC3B,OAAO;IAWV,EAAE,CAAC,CAAC,SAAS,MAAM,gBAAgB,EACjC,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,IAAI,GAC/C,IAAI;CAOR"}
@@ -0,0 +1,14 @@
1
+ import type { CompiledWorkflow } from './workflow-types';
2
+ /**
3
+ * Fingerprint the parts of a compiled workflow that a checkpoint depends on.
4
+ *
5
+ * Hashing step ids alone is not enough: a changed `until`, `while`, branch
6
+ * condition or `inputs` mapping keeps every id stable while changing what the
7
+ * resumed run actually does. Labels are included because `buildStepId`
8
+ * embeds them, so renaming a task changes every downstream step id.
9
+ *
10
+ * @param compiled The compiled workflow to fingerprint.
11
+ * @returns A short, stable hash of the resume-relevant definition surface.
12
+ */
13
+ export declare const fingerprintWorkflow: (compiled: CompiledWorkflow) => string;
14
+ //# sourceMappingURL=workflow-fingerprint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-fingerprint.d.ts","sourceRoot":"","sources":["../../src/workflow-fingerprint.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAIV,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAO1B;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,GAAI,UAAU,gBAAgB,KAAG,MAehE,CAAC"}