@calmo/task-runner 3.8.1 → 3.8.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/coverage/coverage-final.json +4 -3
  3. package/coverage/index.html +7 -7
  4. package/coverage/lcov-report/index.html +7 -7
  5. package/coverage/lcov-report/src/EventBus.ts.html +70 -34
  6. package/coverage/lcov-report/src/ExecutionConstants.ts.html +121 -0
  7. package/coverage/lcov-report/src/TaskGraphValidationError.ts.html +1 -1
  8. package/coverage/lcov-report/src/TaskGraphValidator.ts.html +1 -1
  9. package/coverage/lcov-report/src/TaskRunner.ts.html +1 -1
  10. package/coverage/lcov-report/src/TaskRunnerBuilder.ts.html +1 -1
  11. package/coverage/lcov-report/src/TaskRunnerExecutionConfig.ts.html +1 -1
  12. package/coverage/lcov-report/src/TaskStateManager.ts.html +34 -34
  13. package/coverage/lcov-report/src/WorkflowExecutor.ts.html +151 -97
  14. package/coverage/lcov-report/src/contracts/ErrorTypes.ts.html +1 -1
  15. package/coverage/lcov-report/src/contracts/RunnerEvents.ts.html +1 -1
  16. package/coverage/lcov-report/src/contracts/index.html +1 -1
  17. package/coverage/lcov-report/src/index.html +26 -11
  18. package/coverage/lcov-report/src/strategies/DryRunExecutionStrategy.ts.html +1 -1
  19. package/coverage/lcov-report/src/strategies/RetryingExecutionStrategy.ts.html +1 -1
  20. package/coverage/lcov-report/src/strategies/StandardExecutionStrategy.ts.html +1 -1
  21. package/coverage/lcov-report/src/strategies/index.html +1 -1
  22. package/coverage/lcov.info +216 -200
  23. package/coverage/src/EventBus.ts.html +70 -34
  24. package/coverage/src/ExecutionConstants.ts.html +121 -0
  25. package/coverage/src/TaskGraphValidationError.ts.html +1 -1
  26. package/coverage/src/TaskGraphValidator.ts.html +1 -1
  27. package/coverage/src/TaskRunner.ts.html +1 -1
  28. package/coverage/src/TaskRunnerBuilder.ts.html +1 -1
  29. package/coverage/src/TaskRunnerExecutionConfig.ts.html +1 -1
  30. package/coverage/src/TaskStateManager.ts.html +34 -34
  31. package/coverage/src/WorkflowExecutor.ts.html +151 -97
  32. package/coverage/src/contracts/ErrorTypes.ts.html +1 -1
  33. package/coverage/src/contracts/RunnerEvents.ts.html +1 -1
  34. package/coverage/src/contracts/index.html +1 -1
  35. package/coverage/src/index.html +26 -11
  36. package/coverage/src/strategies/DryRunExecutionStrategy.ts.html +1 -1
  37. package/coverage/src/strategies/RetryingExecutionStrategy.ts.html +1 -1
  38. package/coverage/src/strategies/StandardExecutionStrategy.ts.html +1 -1
  39. package/coverage/src/strategies/index.html +1 -1
  40. package/dist/EventBus.js +11 -2
  41. package/dist/EventBus.js.map +1 -1
  42. package/dist/ExecutionConstants.d.ts +12 -0
  43. package/dist/ExecutionConstants.js +13 -0
  44. package/dist/ExecutionConstants.js.map +1 -0
  45. package/dist/WorkflowExecutor.d.ts +4 -0
  46. package/dist/WorkflowExecutor.js +62 -49
  47. package/dist/WorkflowExecutor.js.map +1 -1
  48. package/package.json +1 -1
  49. package/src/EventBus.ts +27 -15
  50. package/src/ExecutionConstants.ts +12 -0
  51. package/src/WorkflowExecutor.ts +69 -51
  52. package/test-report.xml +155 -131
@@ -1 +1 @@
1
- {"version":3,"file":"EventBus.js","sourceRoot":"","sources":["../src/EventBus.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,OAAO,QAAQ;IACX,SAAS,GAA0B,EAAE,CAAC;IAE9C;;;;OAIG;IACI,EAAE,CACP,KAAQ,EACR,QAA0C;QAE1C,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3B,4EAA4E;YAC5E,iEAAiE;YACjE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,EAAyC,CAAC;QAC3E,CAAC;QACD,oFAAoF;QACnF,IAAI,CAAC,SAAS,CAAC,KAAK,CAA2C,CAAC,GAAG,CAClE,QAAQ,CACT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AG,EAC/C,KAAK,CACN,CAAC;oBACJ,CAAC;gBACH,CAAC,CAAC;qBACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;oBACf,iDAAiD;oBACjD,OAAO,CAAC,KAAK,CACX,+CAA+C,MAAM,CAAC,KAAK,CAAC,GAAG,EAC/D,KAAK,CACN,CAAC;gBACJ,CAAC,CAAC,CAAC;YACP,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Constants used in the execution engine.
3
+ */
4
+ export declare const ExecutionConstants: {
5
+ CANCELLED_BEFORE_START: string;
6
+ TASK_CANCELLED_BEFORE_START: string;
7
+ CANCELLED_DURING_CONDITION: string;
8
+ CONDITION_EVALUATION_FAILED: string;
9
+ SKIPPED_BY_CONDITION: string;
10
+ EXECUTION_STRATEGY_FAILED: string;
11
+ WORKFLOW_CANCELLED: string;
12
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Constants used in the execution engine.
3
+ */
4
+ export const ExecutionConstants = {
5
+ CANCELLED_BEFORE_START: "Workflow cancelled before execution started.",
6
+ TASK_CANCELLED_BEFORE_START: "Cancelled before execution started.",
7
+ CANCELLED_DURING_CONDITION: "Cancelled during condition evaluation.",
8
+ CONDITION_EVALUATION_FAILED: "Condition evaluation failed",
9
+ SKIPPED_BY_CONDITION: "Skipped by condition evaluation.",
10
+ EXECUTION_STRATEGY_FAILED: "Execution strategy failed.",
11
+ WORKFLOW_CANCELLED: "Workflow cancelled.",
12
+ };
13
+ //# sourceMappingURL=ExecutionConstants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExecutionConstants.js","sourceRoot":"","sources":["../src/ExecutionConstants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,sBAAsB,EAAE,8CAA8C;IACtE,2BAA2B,EAAE,qCAAqC;IAClE,0BAA0B,EAAE,wCAAwC;IACpE,2BAA2B,EAAE,6BAA6B;IAC1D,oBAAoB,EAAE,kCAAkC;IACxD,yBAAyB,EAAE,4BAA4B;IACvD,kBAAkB,EAAE,qBAAqB;CAC1C,CAAC"}
@@ -33,4 +33,8 @@ export declare class WorkflowExecutor<TContext> {
33
33
  * Logic to identify tasks that can be started and run them.
34
34
  */
35
35
  private processLoop;
36
+ /**
37
+ * Executes a single task step, handling conditions and status updates.
38
+ */
39
+ private executeTaskStep;
36
40
  }
@@ -1,3 +1,4 @@
1
+ import { ExecutionConstants } from "./ExecutionConstants.js";
1
2
  /**
2
3
  * Handles the execution of the workflow steps.
3
4
  * @template TContext The shape of the shared context object.
@@ -34,7 +35,7 @@ export class WorkflowExecutor {
34
35
  this.stateManager.initialize(steps);
35
36
  // Check if already aborted
36
37
  if (signal?.aborted) {
37
- this.stateManager.cancelAllPending("Workflow cancelled before execution started.");
38
+ this.stateManager.cancelAllPending(ExecutionConstants.CANCELLED_BEFORE_START);
38
39
  const results = this.stateManager.getResults();
39
40
  this.eventBus.emit("workflowEnd", { context: this.context, results });
40
41
  return results;
@@ -42,7 +43,7 @@ export class WorkflowExecutor {
42
43
  const executingPromises = new Set();
43
44
  const onAbort = () => {
44
45
  // Mark all pending tasks as cancelled
45
- this.stateManager.cancelAllPending("Workflow cancelled.");
46
+ this.stateManager.cancelAllPending(ExecutionConstants.WORKFLOW_CANCELLED);
46
47
  };
47
48
  if (signal) {
48
49
  signal.addEventListener("abort", onAbort);
@@ -64,7 +65,7 @@ export class WorkflowExecutor {
64
65
  await Promise.race(executingPromises);
65
66
  }
66
67
  if (signal?.aborted) {
67
- this.stateManager.cancelAllPending("Workflow cancelled.");
68
+ this.stateManager.cancelAllPending(ExecutionConstants.WORKFLOW_CANCELLED);
68
69
  }
69
70
  else {
70
71
  // After a task finishes, check for new work
@@ -72,7 +73,7 @@ export class WorkflowExecutor {
72
73
  }
73
74
  }
74
75
  // Ensure everything is accounted for (e.g. if loop exited early)
75
- this.stateManager.cancelAllPending("Workflow cancelled.");
76
+ this.stateManager.cancelAllPending(ExecutionConstants.WORKFLOW_CANCELLED);
76
77
  const results = this.stateManager.getResults();
77
78
  this.eventBus.emit("workflowEnd", { context: this.context, results });
78
79
  return results;
@@ -101,58 +102,70 @@ export class WorkflowExecutor {
101
102
  break;
102
103
  }
103
104
  const step = this.readyQueue.shift();
104
- const taskPromise = (async () => {
105
- try {
106
- if (step.condition) {
107
- const check = step.condition(this.context);
108
- const shouldRun = check instanceof Promise ? await check : check;
109
- if (signal?.aborted) {
110
- this.stateManager.markCompleted(step, {
111
- status: "cancelled",
112
- message: "Cancelled during condition evaluation.",
113
- });
114
- return;
115
- }
116
- if (!shouldRun) {
117
- const result = {
118
- status: "skipped",
119
- message: "Skipped by condition evaluation.",
120
- };
121
- this.stateManager.markSkipped(step, result);
122
- return;
123
- }
124
- }
125
- }
126
- catch (error) {
127
- const result = {
128
- status: "failure",
129
- message: error instanceof Error
130
- ? error.message
131
- : "Condition evaluation failed",
132
- error: error instanceof Error ? error.message : String(error),
133
- };
134
- this.stateManager.markCompleted(step, result);
135
- return;
136
- }
105
+ const taskPromise = this.executeTaskStep(step, signal)
106
+ .finally(() => {
107
+ executingPromises.delete(taskPromise);
108
+ // When a task finishes, we try to run more
109
+ this.processLoop(executingPromises, signal);
110
+ });
111
+ executingPromises.add(taskPromise);
112
+ }
113
+ }
114
+ /**
115
+ * Executes a single task step, handling conditions and status updates.
116
+ */
117
+ async executeTaskStep(step, signal) {
118
+ try {
119
+ if (step.condition) {
120
+ const check = step.condition(this.context);
121
+ const shouldRun = check instanceof Promise ? await check : check;
137
122
  if (signal?.aborted) {
138
123
  this.stateManager.markCompleted(step, {
139
124
  status: "cancelled",
140
- message: "Cancelled before execution started.",
125
+ message: ExecutionConstants.CANCELLED_DURING_CONDITION,
141
126
  });
142
127
  return;
143
128
  }
144
- this.stateManager.markRunning(step);
145
- await this.strategy
146
- .execute(step, this.context, signal)
147
- .then((result) => {
148
- this.stateManager.markCompleted(step, result);
149
- });
150
- })().finally(() => {
151
- executingPromises.delete(taskPromise);
152
- // When a task finishes, we try to run more
153
- this.processLoop(executingPromises, signal);
129
+ if (!shouldRun) {
130
+ const result = {
131
+ status: "skipped",
132
+ message: ExecutionConstants.SKIPPED_BY_CONDITION,
133
+ };
134
+ this.stateManager.markSkipped(step, result);
135
+ return;
136
+ }
137
+ }
138
+ }
139
+ catch (error) {
140
+ const result = {
141
+ status: "failure",
142
+ message: error instanceof Error
143
+ ? error.message
144
+ : ExecutionConstants.CONDITION_EVALUATION_FAILED,
145
+ error: error instanceof Error ? error.message : String(error),
146
+ };
147
+ this.stateManager.markCompleted(step, result);
148
+ return;
149
+ }
150
+ if (signal?.aborted) {
151
+ this.stateManager.markCompleted(step, {
152
+ status: "cancelled",
153
+ message: ExecutionConstants.TASK_CANCELLED_BEFORE_START,
154
154
  });
155
- executingPromises.add(taskPromise);
155
+ return;
156
+ }
157
+ this.stateManager.markRunning(step);
158
+ try {
159
+ const result = await this.strategy.execute(step, this.context, signal);
160
+ this.stateManager.markCompleted(step, result);
161
+ }
162
+ catch (error) {
163
+ const result = {
164
+ status: "failure",
165
+ message: ExecutionConstants.EXECUTION_STRATEGY_FAILED,
166
+ error: error instanceof Error ? error.message : String(error),
167
+ };
168
+ this.stateManager.markCompleted(step, result);
156
169
  }
157
170
  }
158
171
  }
@@ -1 +1 @@
1
- {"version":3,"file":"WorkflowExecutor.js","sourceRoot":"","sources":["../src/WorkflowExecutor.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAWjB;IACA;IACA;IACA;IACA;IAdF,UAAU,GAAyB,EAAE,CAAC;IAE9C;;;;;;OAMG;IACH,YACU,OAAiB,EACjB,QAA4B,EAC5B,YAAwC,EACxC,QAAsC,EACtC,WAAoB;QAJpB,YAAO,GAAP,OAAO,CAAU;QACjB,aAAQ,GAAR,QAAQ,CAAoB;QAC5B,iBAAY,GAAZ,YAAY,CAA4B;QACxC,aAAQ,GAAR,QAAQ,CAA8B;QACtC,gBAA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,IAAI,CAAC,CAAC;QAEpC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACvE,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,MAAM,GAAe;gBACzB,MAAM,EAAE,SAAS;gBACjB,OAAO,EAAE,kBAAkB,CAAC,yBAAyB;gBACrD,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,CAAC;YACF,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calmo/task-runner",
3
- "version": "3.8.1",
3
+ "version": "3.8.3",
4
4
  "description": "A lightweight, type-safe, and domain-agnostic task orchestration engine. It resolves a Directed Acyclic Graph (DAG) of steps, executes independent tasks in parallel, and manages a shared context across the pipeline.",
5
5
  "repository": {
6
6
  "type": "git",
package/src/EventBus.ts CHANGED
@@ -61,25 +61,37 @@ export class EventBus<TContext> {
61
61
  | undefined;
62
62
  if (listeners) {
63
63
  for (const listener of listeners) {
64
- Promise.resolve().then(() => {
65
- try {
66
- const result = listener(data);
67
- if (result instanceof Promise) {
68
- result.catch((error) => {
69
- console.error(
70
- `Error in event listener for ${String(event)}:`,
71
- error
72
- );
73
- });
64
+ // We use Promise.resolve().then() to schedule the listener on the microtask queue,
65
+ // ensuring the emit method remains non-blocking.
66
+ // The final .catch() ensures that any errors in the promise infrastructure itself are logged.
67
+ Promise.resolve()
68
+ .then(() => {
69
+ try {
70
+ const result = listener(data);
71
+ if (result instanceof Promise) {
72
+ // Handle async listener rejections
73
+ result.catch((error) => {
74
+ console.error(
75
+ `Error in event listener for ${String(event)}:`,
76
+ error
77
+ );
78
+ });
79
+ }
80
+ } catch (error) {
81
+ // Handle sync listener errors
82
+ console.error(
83
+ `Error in event listener for ${String(event)}:`,
84
+ error
85
+ );
74
86
  }
75
- } catch (error) {
76
- // Prevent listener errors from bubbling up
87
+ })
88
+ .catch((error) => {
89
+ // detailed handling for the promise chain itself
77
90
  console.error(
78
- `Error in event listener for ${String(event)}:`,
91
+ `Unexpected error in event bus execution for ${String(event)}:`,
79
92
  error
80
93
  );
81
- }
82
- });
94
+ });
83
95
  }
84
96
  }
85
97
  }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Constants used in the execution engine.
3
+ */
4
+ export const ExecutionConstants = {
5
+ CANCELLED_BEFORE_START: "Workflow cancelled before execution started.",
6
+ TASK_CANCELLED_BEFORE_START: "Cancelled before execution started.",
7
+ CANCELLED_DURING_CONDITION: "Cancelled during condition evaluation.",
8
+ CONDITION_EVALUATION_FAILED: "Condition evaluation failed",
9
+ SKIPPED_BY_CONDITION: "Skipped by condition evaluation.",
10
+ EXECUTION_STRATEGY_FAILED: "Execution strategy failed.",
11
+ WORKFLOW_CANCELLED: "Workflow cancelled.",
12
+ };
@@ -3,6 +3,7 @@ import { TaskResult } from "./TaskResult.js";
3
3
  import { EventBus } from "./EventBus.js";
4
4
  import { TaskStateManager } from "./TaskStateManager.js";
5
5
  import { IExecutionStrategy } from "./strategies/IExecutionStrategy.js";
6
+ import { ExecutionConstants } from "./ExecutionConstants.js";
6
7
 
7
8
  /**
8
9
  * Handles the execution of the workflow steps.
@@ -42,7 +43,7 @@ export class WorkflowExecutor<TContext> {
42
43
  // Check if already aborted
43
44
  if (signal?.aborted) {
44
45
  this.stateManager.cancelAllPending(
45
- "Workflow cancelled before execution started."
46
+ ExecutionConstants.CANCELLED_BEFORE_START
46
47
  );
47
48
  const results = this.stateManager.getResults();
48
49
  this.eventBus.emit("workflowEnd", { context: this.context, results });
@@ -53,7 +54,7 @@ export class WorkflowExecutor<TContext> {
53
54
 
54
55
  const onAbort = () => {
55
56
  // Mark all pending tasks as cancelled
56
- this.stateManager.cancelAllPending("Workflow cancelled.");
57
+ this.stateManager.cancelAllPending(ExecutionConstants.WORKFLOW_CANCELLED);
57
58
  };
58
59
 
59
60
  if (signal) {
@@ -80,7 +81,9 @@ export class WorkflowExecutor<TContext> {
80
81
  }
81
82
 
82
83
  if (signal?.aborted) {
83
- this.stateManager.cancelAllPending("Workflow cancelled.");
84
+ this.stateManager.cancelAllPending(
85
+ ExecutionConstants.WORKFLOW_CANCELLED
86
+ );
84
87
  } else {
85
88
  // After a task finishes, check for new work
86
89
  this.processLoop(executingPromises, signal);
@@ -88,7 +91,7 @@ export class WorkflowExecutor<TContext> {
88
91
  }
89
92
 
90
93
  // Ensure everything is accounted for (e.g. if loop exited early)
91
- this.stateManager.cancelAllPending("Workflow cancelled.");
94
+ this.stateManager.cancelAllPending(ExecutionConstants.WORKFLOW_CANCELLED);
92
95
 
93
96
  const results = this.stateManager.getResults();
94
97
  this.eventBus.emit("workflowEnd", { context: this.context, results });
@@ -128,64 +131,79 @@ export class WorkflowExecutor<TContext> {
128
131
 
129
132
  const step = this.readyQueue.shift()!;
130
133
 
131
- const taskPromise = (async () => {
132
- try {
133
- if (step.condition) {
134
- const check = step.condition(this.context);
135
- const shouldRun = check instanceof Promise ? await check : check;
136
-
137
- if (signal?.aborted) {
138
- this.stateManager.markCompleted(step, {
139
- status: "cancelled",
140
- message: "Cancelled during condition evaluation.",
141
- });
142
- return;
143
- }
144
-
145
- if (!shouldRun) {
146
- const result: TaskResult = {
147
- status: "skipped",
148
- message: "Skipped by condition evaluation.",
149
- };
150
- this.stateManager.markSkipped(step, result);
151
- return;
152
- }
153
- }
154
- } catch (error) {
155
- const result: TaskResult = {
156
- status: "failure",
157
- message:
158
- error instanceof Error
159
- ? error.message
160
- : "Condition evaluation failed",
161
- error: error instanceof Error ? error.message : String(error),
162
- };
163
- this.stateManager.markCompleted(step, result);
164
- return;
165
- }
134
+ const taskPromise = this.executeTaskStep(step, signal)
135
+ .finally(() => {
136
+ executingPromises.delete(taskPromise);
137
+ // When a task finishes, we try to run more
138
+ this.processLoop(executingPromises, signal);
139
+ });
140
+
141
+ executingPromises.add(taskPromise);
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Executes a single task step, handling conditions and status updates.
147
+ */
148
+ private async executeTaskStep(
149
+ step: TaskStep<TContext>,
150
+ signal?: AbortSignal
151
+ ): Promise<void> {
152
+ try {
153
+ if (step.condition) {
154
+ const check = step.condition(this.context);
155
+ const shouldRun = check instanceof Promise ? await check : check;
166
156
 
167
157
  if (signal?.aborted) {
168
158
  this.stateManager.markCompleted(step, {
169
159
  status: "cancelled",
170
- message: "Cancelled before execution started.",
160
+ message: ExecutionConstants.CANCELLED_DURING_CONDITION,
171
161
  });
172
162
  return;
173
163
  }
174
164
 
175
- this.stateManager.markRunning(step);
165
+ if (!shouldRun) {
166
+ const result: TaskResult = {
167
+ status: "skipped",
168
+ message: ExecutionConstants.SKIPPED_BY_CONDITION,
169
+ };
170
+ this.stateManager.markSkipped(step, result);
171
+ return;
172
+ }
173
+ }
174
+ } catch (error) {
175
+ const result: TaskResult = {
176
+ status: "failure",
177
+ message:
178
+ error instanceof Error
179
+ ? error.message
180
+ : ExecutionConstants.CONDITION_EVALUATION_FAILED,
181
+ error: error instanceof Error ? error.message : String(error),
182
+ };
183
+ this.stateManager.markCompleted(step, result);
184
+ return;
185
+ }
176
186
 
177
- await this.strategy
178
- .execute(step, this.context, signal)
179
- .then((result) => {
180
- this.stateManager.markCompleted(step, result);
181
- });
182
- })().finally(() => {
183
- executingPromises.delete(taskPromise);
184
- // When a task finishes, we try to run more
185
- this.processLoop(executingPromises, signal);
187
+ if (signal?.aborted) {
188
+ this.stateManager.markCompleted(step, {
189
+ status: "cancelled",
190
+ message: ExecutionConstants.TASK_CANCELLED_BEFORE_START,
186
191
  });
192
+ return;
193
+ }
187
194
 
188
- executingPromises.add(taskPromise);
195
+ this.stateManager.markRunning(step);
196
+
197
+ try {
198
+ const result = await this.strategy.execute(step, this.context, signal);
199
+ this.stateManager.markCompleted(step, result);
200
+ } catch (error) {
201
+ const result: TaskResult = {
202
+ status: "failure",
203
+ message: ExecutionConstants.EXECUTION_STRATEGY_FAILED,
204
+ error: error instanceof Error ? error.message : String(error),
205
+ };
206
+ this.stateManager.markCompleted(step, result);
189
207
  }
190
208
  }
191
209
  }