@workglow/task-graph 0.0.118 → 0.0.120
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 +65 -25
- package/dist/browser.js.map +9 -9
- package/dist/bun.js +65 -25
- package/dist/bun.js.map +9 -9
- package/dist/node.js +65 -25
- package/dist/node.js.map +9 -9
- package/dist/task/FallbackTaskRunner.d.ts +1 -1
- package/dist/task/FallbackTaskRunner.d.ts.map +1 -1
- package/dist/task/GraphAsTaskRunner.d.ts.map +1 -1
- package/dist/task/IteratorTaskRunner.d.ts.map +1 -1
- package/dist/task/JobQueueTask.d.ts +1 -1
- package/dist/task/JobQueueTask.d.ts.map +1 -1
- package/dist/task/Task.d.ts.map +1 -1
- package/dist/task-graph/TaskGraphRunner.d.ts.map +1 -1
- package/dist/task-graph/Workflow.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/bun.js
CHANGED
|
@@ -1719,18 +1719,35 @@ class Task {
|
|
|
1719
1719
|
return obj;
|
|
1720
1720
|
}
|
|
1721
1721
|
toJSON(_options) {
|
|
1722
|
-
const
|
|
1722
|
+
const ctor = this.constructor;
|
|
1723
|
+
const schema = ctor.configSchema();
|
|
1724
|
+
const schemaProperties = typeof schema !== "boolean" && schema?.properties ? schema.properties : {};
|
|
1725
|
+
const config = {};
|
|
1726
|
+
for (const [key, propSchema] of Object.entries(schemaProperties)) {
|
|
1727
|
+
if (key === "id")
|
|
1728
|
+
continue;
|
|
1729
|
+
if (propSchema?.["x-ui-hidden"] === true && key !== "inputSchema" && key !== "outputSchema" && key !== "extras") {
|
|
1730
|
+
continue;
|
|
1731
|
+
}
|
|
1732
|
+
const value = this.config[key];
|
|
1733
|
+
if (value === undefined)
|
|
1734
|
+
continue;
|
|
1735
|
+
if (typeof value === "function" || typeof value === "symbol")
|
|
1736
|
+
continue;
|
|
1737
|
+
config[key] = value;
|
|
1738
|
+
}
|
|
1739
|
+
if (config.title === ctor.title)
|
|
1740
|
+
delete config.title;
|
|
1741
|
+
if (config.description === ctor.description)
|
|
1742
|
+
delete config.description;
|
|
1743
|
+
const extras = config.extras;
|
|
1744
|
+
if (!extras || Object.keys(extras).length === 0)
|
|
1745
|
+
delete config.extras;
|
|
1723
1746
|
const json = this.stripSymbols({
|
|
1724
1747
|
id: this.id,
|
|
1725
1748
|
type: this.type,
|
|
1726
1749
|
defaults: this.defaults,
|
|
1727
|
-
config
|
|
1728
|
-
...this.config.title && this.config.title !== this.constructor.title ? { title: this.config.title } : {},
|
|
1729
|
-
...this.config.description && this.config.description !== this.constructor.description ? { description: this.config.description } : {},
|
|
1730
|
-
...this.config.inputSchema ? { inputSchema: this.config.inputSchema } : {},
|
|
1731
|
-
...this.config.outputSchema ? { outputSchema: this.config.outputSchema } : {},
|
|
1732
|
-
...extras && Object.keys(extras).length ? { extras } : {}
|
|
1733
|
-
}
|
|
1750
|
+
config
|
|
1734
1751
|
});
|
|
1735
1752
|
return json;
|
|
1736
1753
|
}
|
|
@@ -2395,11 +2412,14 @@ class TaskGraphRunner {
|
|
|
2395
2412
|
const narrowed = await task.narrowInput({ ...results }, this.registry);
|
|
2396
2413
|
dataflow.setPortData(narrowed);
|
|
2397
2414
|
} else {
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2415
|
+
const resultsKeys = Object.keys(results);
|
|
2416
|
+
if (resultsKeys.length > 0) {
|
|
2417
|
+
getLogger2().warn("pushOutputFromNodeToEdge not compatible, not setting port data", {
|
|
2418
|
+
dataflowId: dataflow.id,
|
|
2419
|
+
compatibility,
|
|
2420
|
+
resultsKeys
|
|
2421
|
+
});
|
|
2422
|
+
}
|
|
2403
2423
|
}
|
|
2404
2424
|
}
|
|
2405
2425
|
}
|
|
@@ -2759,7 +2779,7 @@ class TaskGraphRunner {
|
|
|
2759
2779
|
async handleError(error) {
|
|
2760
2780
|
await Promise.allSettled(this.graph.getTasks().map(async (task) => {
|
|
2761
2781
|
if (task.status === TaskStatus.PROCESSING || task.status === TaskStatus.STREAMING) {
|
|
2762
|
-
task.abort();
|
|
2782
|
+
return task.abort();
|
|
2763
2783
|
}
|
|
2764
2784
|
}));
|
|
2765
2785
|
this.running = false;
|
|
@@ -2775,11 +2795,11 @@ class TaskGraphRunner {
|
|
|
2775
2795
|
this.reactiveRunning = false;
|
|
2776
2796
|
}
|
|
2777
2797
|
async handleAbort() {
|
|
2778
|
-
this.graph.getTasks().map(async (task) => {
|
|
2798
|
+
await Promise.allSettled(this.graph.getTasks().map(async (task) => {
|
|
2779
2799
|
if (task.status === TaskStatus.PROCESSING || task.status === TaskStatus.STREAMING) {
|
|
2780
|
-
task.abort();
|
|
2800
|
+
return task.abort();
|
|
2781
2801
|
}
|
|
2782
|
-
});
|
|
2802
|
+
}));
|
|
2783
2803
|
this.running = false;
|
|
2784
2804
|
if (this.telemetrySpan) {
|
|
2785
2805
|
this.telemetrySpan.setStatus(SpanStatusCode2.ERROR, "aborted");
|
|
@@ -2808,7 +2828,9 @@ class TaskGraphRunner {
|
|
|
2808
2828
|
progress = Math.round(completed / total);
|
|
2809
2829
|
}
|
|
2810
2830
|
this.pushStatusFromNodeToEdges(this.graph, task);
|
|
2811
|
-
|
|
2831
|
+
if (task.runOutputData && Object.keys(task.runOutputData).length > 0) {
|
|
2832
|
+
await this.pushOutputFromNodeToEdges(task, task.runOutputData);
|
|
2833
|
+
}
|
|
2812
2834
|
this.graph.emit("graph_progress", progress, message, args);
|
|
2813
2835
|
}
|
|
2814
2836
|
}
|
|
@@ -2834,13 +2856,16 @@ var init_GraphAsTaskRunner = __esm(() => {
|
|
|
2834
2856
|
});
|
|
2835
2857
|
const results = await this.task.subGraph.run(input, {
|
|
2836
2858
|
parentSignal: this.abortController?.signal,
|
|
2837
|
-
outputCache: this.outputCache
|
|
2859
|
+
outputCache: this.outputCache,
|
|
2860
|
+
registry: this.registry
|
|
2838
2861
|
});
|
|
2839
2862
|
unsubscribe();
|
|
2840
2863
|
return results;
|
|
2841
2864
|
}
|
|
2842
2865
|
async executeTaskChildrenReactive() {
|
|
2843
|
-
return this.task.subGraph.runReactive(this.task.runInputData
|
|
2866
|
+
return this.task.subGraph.runReactive(this.task.runInputData, {
|
|
2867
|
+
registry: this.registry
|
|
2868
|
+
});
|
|
2844
2869
|
}
|
|
2845
2870
|
async handleDisable() {
|
|
2846
2871
|
if (this.task.hasChildren()) {
|
|
@@ -3957,6 +3982,11 @@ class Workflow {
|
|
|
3957
3982
|
const tasks = graph.getTasks();
|
|
3958
3983
|
for (const task of tasks) {
|
|
3959
3984
|
if (task.type === "InputTask") {
|
|
3985
|
+
const existingConfig = task.config;
|
|
3986
|
+
const existingSchema = existingConfig?.inputSchema ?? existingConfig?.outputSchema;
|
|
3987
|
+
if (existingSchema && typeof existingSchema === "object" && existingSchema["x-ui-manual"] === true) {
|
|
3988
|
+
continue;
|
|
3989
|
+
}
|
|
3960
3990
|
const outgoing = graph.getTargetDataflows(task.id);
|
|
3961
3991
|
if (outgoing.length === 0)
|
|
3962
3992
|
continue;
|
|
@@ -4171,9 +4201,15 @@ class Workflow {
|
|
|
4171
4201
|
const earlierTask = earlierTasks[i];
|
|
4172
4202
|
const earlierOutputSchema = earlierTask.outputSchema();
|
|
4173
4203
|
if (earlierTask.type === "InputTask") {
|
|
4204
|
+
const inputConfig = earlierTask.config;
|
|
4205
|
+
const inputSchema = inputConfig?.inputSchema ?? inputConfig?.outputSchema;
|
|
4206
|
+
const isManualSchema = inputSchema && typeof inputSchema === "object" && inputSchema["x-ui-manual"] === true;
|
|
4207
|
+
const inputProperties = isManualSchema && inputSchema && typeof inputSchema === "object" && "properties" in inputSchema && inputSchema.properties && typeof inputSchema.properties === "object" ? new Set(Object.keys(inputSchema.properties)) : undefined;
|
|
4174
4208
|
for (const requiredInputId of [...unmatchedRequired]) {
|
|
4175
4209
|
if (matches.has(requiredInputId))
|
|
4176
4210
|
continue;
|
|
4211
|
+
if (inputProperties && !inputProperties.has(requiredInputId))
|
|
4212
|
+
continue;
|
|
4177
4213
|
matches.set(requiredInputId, requiredInputId);
|
|
4178
4214
|
graph.addDataflow(new Dataflow(earlierTask.id, requiredInputId, targetTask.id, requiredInputId));
|
|
4179
4215
|
}
|
|
@@ -4647,7 +4683,8 @@ class FallbackTaskRunner extends GraphAsTaskRunner {
|
|
|
4647
4683
|
const mergedInput = { ...input, ...alternative };
|
|
4648
4684
|
const results = await this.task.subGraph.run(mergedInput, {
|
|
4649
4685
|
parentSignal: this.abortController?.signal,
|
|
4650
|
-
outputCache: this.outputCache
|
|
4686
|
+
outputCache: this.outputCache,
|
|
4687
|
+
registry: this.registry
|
|
4651
4688
|
});
|
|
4652
4689
|
const mergedOutput = this.task.subGraph.mergeExecuteOutputsToRunOutput(results, this.task.compoundMerge);
|
|
4653
4690
|
await this.handleProgress(100, `Data alternative ${attemptNumber}/${totalAttempts} succeeded`);
|
|
@@ -4915,7 +4952,8 @@ class IteratorTaskRunner extends GraphAsTaskRunner {
|
|
|
4915
4952
|
const graphClone = this.cloneGraph(this.task.subGraph);
|
|
4916
4953
|
const results = await graphClone.run(input, {
|
|
4917
4954
|
parentSignal: this.abortController?.signal,
|
|
4918
|
-
outputCache: this.outputCache
|
|
4955
|
+
outputCache: this.outputCache,
|
|
4956
|
+
registry: this.registry
|
|
4919
4957
|
});
|
|
4920
4958
|
if (results.length === 0) {
|
|
4921
4959
|
return;
|
|
@@ -6239,11 +6277,13 @@ class JobQueueTask extends GraphAsTask {
|
|
|
6239
6277
|
}
|
|
6240
6278
|
return registeredQueue;
|
|
6241
6279
|
}
|
|
6242
|
-
|
|
6280
|
+
abort() {
|
|
6243
6281
|
if (this.currentQueueName && this.currentJobId) {
|
|
6244
6282
|
const registeredQueue = getTaskQueueRegistry().getQueue(this.currentQueueName);
|
|
6245
6283
|
if (registeredQueue) {
|
|
6246
|
-
|
|
6284
|
+
registeredQueue.client.abort(this.currentJobId).catch((err) => {
|
|
6285
|
+
console.warn(`Failed to abort remote job ${this.currentJobId}`, err);
|
|
6286
|
+
});
|
|
6247
6287
|
}
|
|
6248
6288
|
}
|
|
6249
6289
|
super.abort();
|
|
@@ -6834,4 +6874,4 @@ export {
|
|
|
6834
6874
|
ConditionalTask
|
|
6835
6875
|
};
|
|
6836
6876
|
|
|
6837
|
-
//# debugId=
|
|
6877
|
+
//# debugId=9EEB6F11C7BDA7A964756E2164756E21
|