@exaudeus/workrail 0.6.1-beta.14 → 0.6.1-beta.15

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.
@@ -54,8 +54,38 @@ class DefaultWorkflowService {
54
54
  if (enhancedContext._currentLoop) {
55
55
  const { loopId, loopStep } = enhancedContext._currentLoop;
56
56
  const loopContext = new loop_execution_context_1.LoopExecutionContext(loopId, loopStep.loop, enhancedContext._loopState?.[loopId]);
57
+ const bodyStep = this.loopStepResolver.resolveLoopBody(workflow, loopStep.body, loopStep.id);
58
+ const bodyIsCompleted = Array.isArray(bodyStep)
59
+ ? bodyStep.every(step => completed.includes(step.id))
60
+ : completed.includes(bodyStep.id);
61
+ if (bodyIsCompleted) {
62
+ loopContext.incrementIteration();
63
+ if (!enhancedContext._loopState) {
64
+ enhancedContext._loopState = {};
65
+ }
66
+ enhancedContext._loopState[loopId] = loopContext.getCurrentState();
67
+ if (Array.isArray(bodyStep)) {
68
+ bodyStep.forEach(step => {
69
+ const index = completed.indexOf(step.id);
70
+ if (index > -1) {
71
+ completed.splice(index, 1);
72
+ }
73
+ });
74
+ }
75
+ else {
76
+ const index = completed.indexOf(bodyStep.id);
77
+ if (index > -1) {
78
+ completed.splice(index, 1);
79
+ }
80
+ }
81
+ if (!loopContext.shouldContinue(context)) {
82
+ completed.push(loopId);
83
+ delete enhancedContext._currentLoop;
84
+ const nextStep = await this.getNextStep(workflow.id, completed, enhancedContext);
85
+ return nextStep;
86
+ }
87
+ }
57
88
  if (loopContext.shouldContinue(context)) {
58
- const bodyStep = this.loopStepResolver.resolveLoopBody(workflow, loopStep.body, loopStep.id);
59
89
  if (!Array.isArray(bodyStep)) {
60
90
  const isFirst = loopContext.isFirstIteration();
61
91
  if (isFirst && loopContext.isEmpty(context)) {
@@ -83,25 +113,25 @@ class DefaultWorkflowService {
83
113
  };
84
114
  }
85
115
  else {
116
+ const isFirst = loopContext.isFirstIteration();
117
+ if (isFirst && loopContext.isEmpty(context)) {
118
+ const skipContext = context_optimizer_1.ContextOptimizer.createEnhancedContext(context, completed);
119
+ delete skipContext._currentLoop;
120
+ const nextStep = await this.getNextStep(workflow.id, completed, skipContext);
121
+ return nextStep;
122
+ }
123
+ const useMinimal = !isFirst && !!this.loopContextOptimizer;
124
+ const loopEnhancedContext = loopContext.injectVariables(context, useMinimal);
86
125
  const uncompletedBodyStep = bodyStep.find(step => {
87
126
  if (completed.includes(step.id)) {
88
127
  return false;
89
128
  }
90
129
  if (step.runCondition) {
91
- return (0, condition_evaluator_1.evaluateCondition)(step.runCondition, context);
130
+ return (0, condition_evaluator_1.evaluateCondition)(step.runCondition, loopEnhancedContext);
92
131
  }
93
132
  return true;
94
133
  });
95
134
  if (uncompletedBodyStep) {
96
- const isFirst = loopContext.isFirstIteration();
97
- if (isFirst && loopContext.isEmpty(context)) {
98
- const skipContext = context_optimizer_1.ContextOptimizer.createEnhancedContext(context, completed);
99
- delete skipContext._currentLoop;
100
- const nextStep = await this.getNextStep(workflow.id, completed, skipContext);
101
- return nextStep;
102
- }
103
- const useMinimal = !isFirst && !!this.loopContextOptimizer;
104
- const loopEnhancedContext = loopContext.injectVariables(context, useMinimal);
105
135
  const optimizedContext = useMinimal && this.loopContextOptimizer
106
136
  ? this.loopContextOptimizer.stripLoopMetadata(loopEnhancedContext)
107
137
  : loopEnhancedContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exaudeus/workrail",
3
- "version": "0.6.1-beta.14",
3
+ "version": "0.6.1-beta.15",
4
4
  "description": "MCP server for structured workflow orchestration and step-by-step task guidance",
5
5
  "license": "MIT",
6
6
  "bin": {