@parcha/agentrun-dsl 0.1.0-beta.222 → 0.1.0-beta.223

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/workflow.js +18 -3
  2. package/package.json +1 -1
package/dist/workflow.js CHANGED
@@ -2944,12 +2944,27 @@ function uncertainEffects(error, found = new Set(), seen = new Set()) {
2944
2944
  uncertainEffects(nested, found, seen);
2945
2945
  return found;
2946
2946
  }
2947
+ /** The AggregateErrors withSiblingUncertainty made: one a structure fails with again (a map's inside a parallel) is said
2948
+ * by its own failure, its sibling effects counted with the new ones. */
2949
+ const siblingFailures = new WeakSet();
2950
+ /** `primary`, or with sibling effects whose outcome is unknown beside it, an AggregateError of it and them (its cause
2951
+ * `primary`) for recovery and reconcile to read. Its message leads with the failure's own words, so a run that failed on
2952
+ * one says why, then counts the uncertain sibling effects. */
2947
2953
  function withSiblingUncertainty(primary, uncertainties) {
2948
2954
  const retained = uncertainEffects(primary);
2949
2955
  const additional = [...uncertainties].filter(error => !retained.has(error));
2950
- return additional.length
2951
- ? new AggregateError([primary, ...additional], "Workflow branches failed with uncertain effects; reconcile each effect before retrying", { cause: primary })
2952
- : primary;
2956
+ if (!additional.length)
2957
+ return primary;
2958
+ let failure = primary, siblings = additional.length;
2959
+ while (failure instanceof AggregateError && siblingFailures.has(failure)) {
2960
+ siblings += failure.errors.length - 1;
2961
+ failure = failure.cause;
2962
+ }
2963
+ const why = (failure instanceof Error ? failure.message : String(failure)) || "A workflow branch failed";
2964
+ const count = siblings === 1 ? "1 sibling effect is" : `${siblings} sibling effects are`;
2965
+ const aggregate = new AggregateError([primary, ...additional], `${why} (${count} uncertain; reconcile each effect before retrying)`, { cause: primary });
2966
+ siblingFailures.add(aggregate);
2967
+ return aggregate;
2953
2968
  }
2954
2969
  async function runNodeBody(node, state, workflow, deps) {
2955
2970
  switch (node.node) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-dsl",
3
- "version": "0.1.0-beta.222",
3
+ "version": "0.1.0-beta.223",
4
4
  "description": "Composable, typed workflows for agents",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",