@clearideas/agent-runtime-step-loop 0.6.3 → 0.7.1

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 (2) hide show
  1. package/dist/index.js +9 -2
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -122,6 +122,8 @@ export class LoopStepExecutor {
122
122
  let goalMetAtIteration = restored?.goalMetAtIteration ?? null;
123
123
  const transcript = clone(context.resume?.transcript ?? []);
124
124
  const artifacts = clone(context.resume?.artifacts ?? []);
125
+ /** A child asked to end the run (for example a rejected approval with onReject: complete). */
126
+ let endRun = false;
125
127
  if (!restored?.finished) {
126
128
  for (let iteration = startIteration; iteration < iterationLimit; iteration += 1) {
127
129
  const resumingIteration = iteration === startIteration && startChild > 0;
@@ -185,6 +187,10 @@ export class LoopStepExecutor {
185
187
  artifacts.push(...(result.artifacts ?? []));
186
188
  if (result.output !== undefined)
187
189
  lastOutput = clone(result.output);
190
+ if (result.endRun === true) {
191
+ endRun = true;
192
+ break;
193
+ }
188
194
  const nextChildIndex = childIndex + 1;
189
195
  const nextChild = context.step.steps[nextChildIndex];
190
196
  await checkpoint({
@@ -242,7 +248,7 @@ export class LoopStepExecutor {
242
248
  iteration: iteration + 1,
243
249
  sourceIndex: iteration,
244
250
  });
245
- const finished = goalMet || iteration + 1 >= iterationLimit;
251
+ const finished = endRun || goalMet || iteration + 1 >= iterationLimit;
246
252
  await checkpoint({
247
253
  state,
248
254
  cursor: {
@@ -266,7 +272,7 @@ export class LoopStepExecutor {
266
272
  artifacts,
267
273
  });
268
274
  startChild = 0;
269
- if (goalMet)
275
+ if (goalMet || endRun)
270
276
  break;
271
277
  }
272
278
  }
@@ -289,6 +295,7 @@ export class LoopStepExecutor {
289
295
  statePatch: { set: state },
290
296
  transcript,
291
297
  artifacts,
298
+ ...(endRun ? { endRun: true } : {}),
292
299
  metadata: {
293
300
  iterations: outputs.length,
294
301
  outputMode: config.outputMode ?? "array",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clearideas/agent-runtime-step-loop",
3
- "version": "0.6.3",
3
+ "version": "0.7.1",
4
4
  "description": "Sequential condition and goal loop executor for Clear Ideas Agent Runtime.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Clear Ideas Incorporated",
@@ -36,11 +36,11 @@
36
36
  "postpack": "node ../../scripts/cleanup-package-license.mjs"
37
37
  },
38
38
  "dependencies": {
39
- "@clearideas/agent-runtime-contracts": "0.6.3",
40
- "@clearideas/agent-runtime-core": "0.6.3"
39
+ "@clearideas/agent-runtime-contracts": "0.7.1",
40
+ "@clearideas/agent-runtime-core": "0.7.1"
41
41
  },
42
42
  "devDependencies": {
43
- "@clearideas/agent-runtime-condition-jexl": "0.6.3",
43
+ "@clearideas/agent-runtime-condition-jexl": "0.7.1",
44
44
  "typescript": "^7.0.2",
45
45
  "vitest": "^5.1.0"
46
46
  },