@workglow/task-graph 0.2.9 → 0.2.11
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.
- package/dist/browser.js +139 -114
- package/dist/browser.js.map +6 -6
- package/dist/bun.js +139 -114
- package/dist/bun.js.map +6 -6
- package/dist/node.js +139 -114
- package/dist/node.js.map +6 -6
- package/dist/task/FallbackTaskRunner.d.ts.map +1 -1
- package/dist/task/IteratorTaskRunner.d.ts.map +1 -1
- package/dist/task/WhileTask.d.ts.map +1 -1
- package/dist/task-graph/GraphFormatScanner.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/bun.js
CHANGED
|
@@ -5366,30 +5366,41 @@ class FallbackTaskRunner extends GraphAsTaskRunner {
|
|
|
5366
5366
|
}
|
|
5367
5367
|
const errors = [];
|
|
5368
5368
|
const totalAttempts = alternatives.length;
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
}
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
this.
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
});
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5369
|
+
let currentAttemptIndex = 0;
|
|
5370
|
+
const onSubgraphProgress = (innerProgress, message) => {
|
|
5371
|
+
const blended = Math.round((currentAttemptIndex + innerProgress / 100) / totalAttempts * 100);
|
|
5372
|
+
this.handleProgress(blended, message ?? `Data alternative ${currentAttemptIndex + 1}/${totalAttempts}`);
|
|
5373
|
+
};
|
|
5374
|
+
const unsubscribeSubgraphProgress = this.task.subGraph.subscribe("graph_progress", onSubgraphProgress);
|
|
5375
|
+
try {
|
|
5376
|
+
for (let i = 0;i < alternatives.length; i++) {
|
|
5377
|
+
if (this.abortController?.signal.aborted) {
|
|
5378
|
+
throw new TaskAbortedError("Fallback aborted");
|
|
5379
|
+
}
|
|
5380
|
+
currentAttemptIndex = i;
|
|
5381
|
+
const alternative = alternatives[i];
|
|
5382
|
+
const attemptNumber = i + 1;
|
|
5383
|
+
await this.handleProgress(Math.round((i + 0.5) / totalAttempts * 100), `Trying data alternative ${attemptNumber}/${totalAttempts}`);
|
|
5384
|
+
try {
|
|
5385
|
+
this.resetSubgraph();
|
|
5386
|
+
const mergedInput = { ...input, ...alternative };
|
|
5387
|
+
const results = await this.task.subGraph.run(mergedInput, {
|
|
5388
|
+
parentSignal: this.abortController?.signal,
|
|
5389
|
+
outputCache: this.outputCache,
|
|
5390
|
+
registry: this.registry
|
|
5391
|
+
});
|
|
5392
|
+
const mergedOutput = this.task.subGraph.mergeExecuteOutputsToRunOutput(results, this.task.compoundMerge);
|
|
5393
|
+
await this.handleProgress(100, `Data alternative ${attemptNumber}/${totalAttempts} succeeded`);
|
|
5394
|
+
return await this.executeTaskReactive(input, mergedOutput);
|
|
5395
|
+
} catch (error) {
|
|
5396
|
+
if (error instanceof TaskAbortedError && !(error instanceof TaskTimeoutError)) {
|
|
5397
|
+
throw error;
|
|
5398
|
+
}
|
|
5399
|
+
errors.push({ alternative, error });
|
|
5390
5400
|
}
|
|
5391
|
-
errors.push({ alternative, error });
|
|
5392
5401
|
}
|
|
5402
|
+
} finally {
|
|
5403
|
+
unsubscribeSubgraphProgress();
|
|
5393
5404
|
}
|
|
5394
5405
|
throw this.buildAggregateError(errors, "data");
|
|
5395
5406
|
}
|
|
@@ -5730,18 +5741,14 @@ class IteratorTaskRunner extends GraphAsTaskRunner {
|
|
|
5730
5741
|
}
|
|
5731
5742
|
const graphClone = this.cloneGraph(this.task.subGraph);
|
|
5732
5743
|
this.task.emit("iteration_start", index, iterationCount);
|
|
5733
|
-
const
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
this.
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
};
|
|
5742
|
-
t.events.on("progress", fn);
|
|
5743
|
-
taskProgressUnsubs.push({ task: t, fn });
|
|
5744
|
-
}
|
|
5744
|
+
const onGraphProgress = (p, message) => {
|
|
5745
|
+
this.task.emit("iteration_progress", index, iterationCount, p, message);
|
|
5746
|
+
if (this.aggregatingParentMapProgress && this.mapPartialIterationCount > 0) {
|
|
5747
|
+
this.mapPartialProgress[index] = Math.max(this.mapPartialProgress[index] ?? 0, p);
|
|
5748
|
+
this.emitMapParentProgressFromPartials(message);
|
|
5749
|
+
}
|
|
5750
|
+
};
|
|
5751
|
+
const unsubscribeGraphProgress = graphClone.subscribe("graph_progress", onGraphProgress);
|
|
5745
5752
|
try {
|
|
5746
5753
|
const results = await graphClone.run(input, {
|
|
5747
5754
|
parentSignal: this.abortController?.signal,
|
|
@@ -5754,9 +5761,7 @@ class IteratorTaskRunner extends GraphAsTaskRunner {
|
|
|
5754
5761
|
}
|
|
5755
5762
|
return graphClone.mergeExecuteOutputsToRunOutput(results, this.task.compoundMerge);
|
|
5756
5763
|
} finally {
|
|
5757
|
-
|
|
5758
|
-
task.events.off("progress", fn);
|
|
5759
|
-
}
|
|
5764
|
+
unsubscribeGraphProgress();
|
|
5760
5765
|
if (this.aggregatingParentMapProgress && this.mapPartialIterationCount > 0) {
|
|
5761
5766
|
this.mapPartialProgress[index] = 100;
|
|
5762
5767
|
this.emitMapParentProgressFromPartials();
|
|
@@ -6422,55 +6427,65 @@ class WhileTask extends GraphAsTask {
|
|
|
6422
6427
|
let currentInput = { ...input };
|
|
6423
6428
|
let currentOutput = {};
|
|
6424
6429
|
const effectiveMax = arrayAnalysis ? Math.min(this.maxIterations, arrayAnalysis.iterationCount) : this.maxIterations;
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
iterationInput
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
shouldContinue = condition(currentOutput, this._currentIteration);
|
|
6448
|
-
} catch (err) {
|
|
6449
|
-
if (err instanceof TaskFailedError) {
|
|
6450
|
-
throw err;
|
|
6430
|
+
const onInnerGraphProgress = (innerProgress, innerMessage) => {
|
|
6431
|
+
const blended = Math.min(Math.round((this._currentIteration + innerProgress / 100) / effectiveMax * 100), 99);
|
|
6432
|
+
const message = innerMessage ? `Iteration ${this._currentIteration + 1}/${effectiveMax}: ${innerMessage}` : `Iteration ${this._currentIteration + 1}/${effectiveMax}`;
|
|
6433
|
+
context.updateProgress(blended, message);
|
|
6434
|
+
};
|
|
6435
|
+
const unsubscribeInnerProgress = this.subGraph.subscribe("graph_progress", onInnerGraphProgress);
|
|
6436
|
+
try {
|
|
6437
|
+
while (this._currentIteration < effectiveMax) {
|
|
6438
|
+
if (context.signal?.aborted) {
|
|
6439
|
+
break;
|
|
6440
|
+
}
|
|
6441
|
+
let iterationInput;
|
|
6442
|
+
if (arrayAnalysis) {
|
|
6443
|
+
iterationInput = {
|
|
6444
|
+
...this.buildIterationInput(currentInput, arrayAnalysis, this._currentIteration),
|
|
6445
|
+
_iterationIndex: this._currentIteration
|
|
6446
|
+
};
|
|
6447
|
+
} else {
|
|
6448
|
+
iterationInput = {
|
|
6449
|
+
...currentInput,
|
|
6450
|
+
_iterationIndex: this._currentIteration
|
|
6451
|
+
};
|
|
6451
6452
|
}
|
|
6452
|
-
const
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6453
|
+
const results = await this.subGraph.run(iterationInput, {
|
|
6454
|
+
parentSignal: context.signal
|
|
6455
|
+
});
|
|
6456
|
+
currentOutput = this.subGraph.mergeExecuteOutputsToRunOutput(results, this.compoundMerge);
|
|
6457
|
+
let shouldContinue;
|
|
6458
|
+
try {
|
|
6459
|
+
shouldContinue = condition(currentOutput, this._currentIteration);
|
|
6460
|
+
} catch (err) {
|
|
6461
|
+
if (err instanceof TaskFailedError) {
|
|
6462
|
+
throw err;
|
|
6463
|
+
}
|
|
6464
|
+
const message = `${this.type}: Condition function threw at iteration ${this._currentIteration}: ${err instanceof Error ? err.message : String(err)}`;
|
|
6465
|
+
const wrappedError = new TaskFailedError(message);
|
|
6466
|
+
if (err instanceof Error && err.stack) {
|
|
6467
|
+
if (wrappedError.stack) {
|
|
6468
|
+
wrappedError.stack += `
|
|
6457
6469
|
Caused by original error:
|
|
6458
6470
|
${err.stack}`;
|
|
6459
|
-
|
|
6460
|
-
|
|
6471
|
+
} else {
|
|
6472
|
+
wrappedError.stack = err.stack;
|
|
6473
|
+
}
|
|
6461
6474
|
}
|
|
6475
|
+
throw wrappedError;
|
|
6462
6476
|
}
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6477
|
+
if (!shouldContinue) {
|
|
6478
|
+
break;
|
|
6479
|
+
}
|
|
6480
|
+
if (this.chainIterations) {
|
|
6481
|
+
currentInput = { ...currentInput, ...currentOutput };
|
|
6482
|
+
}
|
|
6483
|
+
this._currentIteration++;
|
|
6484
|
+
const progress = Math.min(Math.round(this._currentIteration / effectiveMax * 100), 99);
|
|
6485
|
+
await context.updateProgress(progress, `Completed ${this._currentIteration}/${effectiveMax} iterations`);
|
|
6470
6486
|
}
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
await context.updateProgress(progress, `Completed ${this._currentIteration}/${effectiveMax} iterations`);
|
|
6487
|
+
} finally {
|
|
6488
|
+
unsubscribeInnerProgress();
|
|
6474
6489
|
}
|
|
6475
6490
|
return currentOutput;
|
|
6476
6491
|
}
|
|
@@ -6487,40 +6502,50 @@ ${err.stack}`;
|
|
|
6487
6502
|
let currentInput = { ...input };
|
|
6488
6503
|
let currentOutput = {};
|
|
6489
6504
|
const effectiveMax = arrayAnalysis ? Math.min(this.maxIterations, arrayAnalysis.iterationCount) : this.maxIterations;
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
iterationInput
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6505
|
+
const onInnerGraphProgress = (innerProgress, innerMessage) => {
|
|
6506
|
+
const blended = Math.min(Math.round((this._currentIteration + innerProgress / 100) / effectiveMax * 100), 99);
|
|
6507
|
+
const message = innerMessage ? `Iteration ${this._currentIteration + 1}/${effectiveMax}: ${innerMessage}` : `Iteration ${this._currentIteration + 1}/${effectiveMax}`;
|
|
6508
|
+
context.updateProgress(blended, message);
|
|
6509
|
+
};
|
|
6510
|
+
const unsubscribeInnerProgress = this.subGraph.subscribe("graph_progress", onInnerGraphProgress);
|
|
6511
|
+
try {
|
|
6512
|
+
while (this._currentIteration < effectiveMax) {
|
|
6513
|
+
if (context.signal?.aborted)
|
|
6514
|
+
break;
|
|
6515
|
+
let iterationInput;
|
|
6516
|
+
if (arrayAnalysis) {
|
|
6517
|
+
iterationInput = {
|
|
6518
|
+
...this.buildIterationInput(currentInput, arrayAnalysis, this._currentIteration),
|
|
6519
|
+
_iterationIndex: this._currentIteration
|
|
6520
|
+
};
|
|
6521
|
+
} else {
|
|
6522
|
+
iterationInput = {
|
|
6523
|
+
...currentInput,
|
|
6524
|
+
_iterationIndex: this._currentIteration
|
|
6525
|
+
};
|
|
6526
|
+
}
|
|
6527
|
+
const results = await this.subGraph.run(iterationInput, {
|
|
6528
|
+
parentSignal: context.signal
|
|
6529
|
+
});
|
|
6530
|
+
currentOutput = this.subGraph.mergeExecuteOutputsToRunOutput(results, this.compoundMerge);
|
|
6531
|
+
let shouldContinue;
|
|
6532
|
+
try {
|
|
6533
|
+
shouldContinue = condition(currentOutput, this._currentIteration);
|
|
6534
|
+
} catch (err) {
|
|
6535
|
+
throw new TaskFailedError(`${this.type}: Condition function threw at iteration ${this._currentIteration}: ${err instanceof Error ? err.message : String(err)}`);
|
|
6536
|
+
}
|
|
6537
|
+
if (!shouldContinue) {
|
|
6538
|
+
break;
|
|
6539
|
+
}
|
|
6540
|
+
if (this.chainIterations) {
|
|
6541
|
+
currentInput = { ...currentInput, ...currentOutput };
|
|
6542
|
+
}
|
|
6543
|
+
this._currentIteration++;
|
|
6544
|
+
const progress = Math.min(Math.round(this._currentIteration / effectiveMax * 100), 99);
|
|
6545
|
+
await context.updateProgress(progress, `Completed ${this._currentIteration}/${effectiveMax} iterations`);
|
|
6520
6546
|
}
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
await context.updateProgress(progress, `Completed ${this._currentIteration}/${effectiveMax} iterations`);
|
|
6547
|
+
} finally {
|
|
6548
|
+
unsubscribeInnerProgress();
|
|
6524
6549
|
}
|
|
6525
6550
|
yield { type: "finish", data: currentOutput };
|
|
6526
6551
|
}
|
|
@@ -7606,4 +7631,4 @@ export {
|
|
|
7606
7631
|
BROWSER_GRANTS
|
|
7607
7632
|
};
|
|
7608
7633
|
|
|
7609
|
-
//# debugId=
|
|
7634
|
+
//# debugId=4EA2E25DBA8962FA64756E2164756E21
|