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