@workglow/task-graph 0.0.125 → 0.0.126

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/bun.js CHANGED
@@ -1,90 +1,52 @@
1
1
  // @bun
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- function __accessProp(key) {
7
- return this[key];
8
- }
9
- var __toCommonJS = (from) => {
10
- var entry = (__moduleCache ??= new WeakMap).get(from), desc;
11
- if (entry)
12
- return entry;
13
- entry = __defProp({}, "__esModule", { value: true });
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (var key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(entry, key))
17
- __defProp(entry, key, {
18
- get: __accessProp.bind(from, key),
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- }
22
- __moduleCache.set(from, entry);
23
- return entry;
24
- };
25
- var __moduleCache;
26
- var __returnValue = (v) => v;
27
- function __exportSetter(name, newValue) {
28
- this[name] = __returnValue.bind(null, newValue);
29
- }
30
- var __export = (target, all) => {
31
- for (var name in all)
32
- __defProp(target, name, {
33
- get: all[name],
34
- enumerable: true,
35
- configurable: true,
36
- set: __exportSetter.bind(all, name)
37
- });
38
- };
39
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
2
+ // src/task-graph/Dataflow.ts
3
+ import { areSemanticallyCompatible } from "@workglow/util/schema";
4
+ import { EventEmitter } from "@workglow/util";
40
5
 
41
6
  // src/task/TaskTypes.ts
42
- var TaskStatus, TaskConfigSchema;
43
- var init_TaskTypes = __esm(() => {
44
- TaskStatus = {
45
- PENDING: "PENDING",
46
- DISABLED: "DISABLED",
47
- PROCESSING: "PROCESSING",
48
- STREAMING: "STREAMING",
49
- COMPLETED: "COMPLETED",
50
- ABORTING: "ABORTING",
51
- FAILED: "FAILED"
52
- };
53
- TaskConfigSchema = {
54
- type: "object",
55
- properties: {
56
- id: {
57
- "x-ui-hidden": true
58
- },
59
- title: { type: "string" },
60
- description: { type: "string" },
61
- cacheable: { type: "boolean" },
62
- timeout: { type: "number", description: "Max execution time in milliseconds" },
63
- inputSchema: {
64
- type: "object",
65
- properties: {},
66
- additionalProperties: true,
67
- "x-ui-hidden": true
68
- },
69
- outputSchema: {
70
- type: "object",
71
- properties: {},
72
- additionalProperties: true,
73
- "x-ui-hidden": true
74
- },
75
- extras: {
76
- type: "object",
77
- additionalProperties: true,
78
- "x-ui-hidden": true
79
- }
7
+ var TaskStatus = {
8
+ PENDING: "PENDING",
9
+ DISABLED: "DISABLED",
10
+ PROCESSING: "PROCESSING",
11
+ STREAMING: "STREAMING",
12
+ COMPLETED: "COMPLETED",
13
+ ABORTING: "ABORTING",
14
+ FAILED: "FAILED"
15
+ };
16
+ var TaskConfigSchema = {
17
+ type: "object",
18
+ properties: {
19
+ id: {
20
+ "x-ui-hidden": true
80
21
  },
81
- additionalProperties: false
82
- };
83
- });
22
+ title: { type: "string" },
23
+ description: { type: "string" },
24
+ cacheable: { type: "boolean" },
25
+ timeout: { type: "number", description: "Max execution time in milliseconds" },
26
+ inputSchema: {
27
+ type: "object",
28
+ properties: {},
29
+ additionalProperties: true,
30
+ "x-ui-hidden": true
31
+ },
32
+ outputSchema: {
33
+ type: "object",
34
+ properties: {},
35
+ additionalProperties: true,
36
+ "x-ui-hidden": true
37
+ },
38
+ extras: {
39
+ type: "object",
40
+ additionalProperties: true,
41
+ "x-ui-hidden": true
42
+ }
43
+ },
44
+ additionalProperties: false
45
+ };
84
46
 
85
47
  // src/task-graph/Dataflow.ts
86
- import { areSemanticallyCompatible } from "@workglow/util/schema";
87
- import { EventEmitter } from "@workglow/util";
48
+ var DATAFLOW_ALL_PORTS = "*";
49
+ var DATAFLOW_ERROR_PORT = "[error]";
88
50
 
89
51
  class Dataflow {
90
52
  sourceTaskId;
@@ -269,22 +231,18 @@ class Dataflow {
269
231
  this._events?.emit(name, ...args);
270
232
  }
271
233
  }
272
- var DATAFLOW_ALL_PORTS = "*", DATAFLOW_ERROR_PORT = "[error]", DataflowArrow;
273
- var init_Dataflow = __esm(() => {
274
- init_TaskTypes();
275
- DataflowArrow = class DataflowArrow extends Dataflow {
276
- constructor(dataflow) {
277
- const pattern = /^([a-zA-Z0-9-]+?)\[([a-zA-Z0-9-]+?)\] ==> ([a-zA-Z0-9-]+?)\[([a-zA-Z0-9-]+?)\]$/;
278
- const match = dataflow.match(pattern);
279
- if (!match) {
280
- throw new Error(`Invalid dataflow format: ${dataflow}`);
281
- }
282
- const [, sourceTaskId, sourceTaskPortId, targetTaskId, targetTaskPortId] = match;
283
- super(sourceTaskId, sourceTaskPortId, targetTaskId, targetTaskPortId);
284
- }
285
- };
286
- });
287
234
 
235
+ class DataflowArrow extends Dataflow {
236
+ constructor(dataflow) {
237
+ const pattern = /^([a-zA-Z0-9-]+?)\[([a-zA-Z0-9-]+?)\] ==> ([a-zA-Z0-9-]+?)\[([a-zA-Z0-9-]+?)\]$/;
238
+ const match = dataflow.match(pattern);
239
+ if (!match) {
240
+ throw new Error(`Invalid dataflow format: ${dataflow}`);
241
+ }
242
+ const [, sourceTaskId, sourceTaskPortId, targetTaskId, targetTaskPortId] = match;
243
+ super(sourceTaskId, sourceTaskPortId, targetTaskId, targetTaskPortId);
244
+ }
245
+ }
288
246
  // src/task-graph/GraphSchemaUtils.ts
289
247
  import { uuid4 } from "@workglow/util";
290
248
  function calculateNodeDepths(graph) {
@@ -633,74 +591,27 @@ function addBoundaryNodesToDependencyJson(items, graph) {
633
591
  }
634
592
  return [...prependItems, ...items, ...appendItems];
635
593
  }
636
- var init_GraphSchemaUtils = __esm(() => {
637
- init_Dataflow();
638
- });
594
+ // src/task-graph/TaskGraph.ts
595
+ import { DirectedAcyclicGraph } from "@workglow/util/graph";
596
+ import { EventEmitter as EventEmitter4, uuid4 as uuid44 } from "@workglow/util";
639
597
 
640
- // src/task/TaskError.ts
641
- import { BaseError } from "@workglow/util";
642
- var TaskError, TaskConfigurationError, WorkflowError, TaskAbortedError, TaskTimeoutError, TaskFailedError, JobTaskFailedError, TaskJSONError, TaskInvalidInputError;
643
- var init_TaskError = __esm(() => {
644
- TaskError = class TaskError extends BaseError {
645
- static type = "TaskError";
646
- constructor(message) {
647
- super(message);
648
- }
649
- };
650
- TaskConfigurationError = class TaskConfigurationError extends TaskError {
651
- static type = "TaskConfigurationError";
652
- constructor(message) {
653
- super(message);
654
- }
655
- };
656
- WorkflowError = class WorkflowError extends TaskError {
657
- static type = "WorkflowError";
658
- constructor(message) {
659
- super(message);
660
- }
661
- };
662
- TaskAbortedError = class TaskAbortedError extends TaskError {
663
- static type = "TaskAbortedError";
664
- constructor(message = "Task aborted") {
665
- super(message);
666
- }
667
- };
668
- TaskTimeoutError = class TaskTimeoutError extends TaskAbortedError {
669
- static type = "TaskTimeoutError";
670
- constructor(timeoutMs) {
671
- super(timeoutMs ? `Task timed out after ${timeoutMs}ms` : "Task timed out");
672
- }
673
- };
674
- TaskFailedError = class TaskFailedError extends TaskError {
675
- static type = "TaskFailedError";
676
- constructor(message = "Task failed") {
677
- super(message);
678
- }
679
- };
680
- JobTaskFailedError = class JobTaskFailedError extends TaskFailedError {
681
- static type = "JobTaskFailedError";
682
- jobError;
683
- constructor(err) {
684
- super(String(err));
685
- this.jobError = err;
686
- }
687
- };
688
- TaskJSONError = class TaskJSONError extends TaskError {
689
- static type = "TaskJSONError";
690
- constructor(message = "Error converting JSON to a Task") {
691
- super(message);
692
- }
693
- };
694
- TaskInvalidInputError = class TaskInvalidInputError extends TaskError {
695
- static type = "TaskInvalidInputError";
696
- constructor(message = "Invalid input data") {
697
- super(message);
698
- }
699
- };
700
- });
598
+ // src/task/GraphAsTask.ts
599
+ import { compileSchema as compileSchema2 } from "@workglow/util/schema";
600
+
601
+ // src/task-graph/TaskGraphRunner.ts
602
+ import {
603
+ collectPropertyValues,
604
+ getLogger as getLogger2,
605
+ getTelemetryProvider as getTelemetryProvider2,
606
+ globalServiceRegistry as globalServiceRegistry2,
607
+ ServiceRegistry as ServiceRegistry2,
608
+ SpanStatusCode as SpanStatusCode2,
609
+ uuid4 as uuid43
610
+ } from "@workglow/util";
701
611
 
702
612
  // src/storage/TaskOutputRepository.ts
703
613
  import { createServiceToken, EventEmitter as EventEmitter2 } from "@workglow/util";
614
+ var TASK_OUTPUT_REPOSITORY = createServiceToken("taskgraph.taskOutputRepository");
704
615
 
705
616
  class TaskOutputRepository {
706
617
  outputCompression;
@@ -727,10 +638,155 @@ class TaskOutputRepository {
727
638
  this._events?.emit(name, ...args);
728
639
  }
729
640
  }
730
- var TASK_OUTPUT_REPOSITORY;
731
- var init_TaskOutputRepository = __esm(() => {
732
- TASK_OUTPUT_REPOSITORY = createServiceToken("taskgraph.taskOutputRepository");
733
- });
641
+
642
+ // src/task/ConditionalTask.ts
643
+ import { getLogger } from "@workglow/util";
644
+
645
+ // src/task/ConditionUtils.ts
646
+ function evaluateCondition(fieldValue, operator, compareValue) {
647
+ if (fieldValue === null || fieldValue === undefined) {
648
+ switch (operator) {
649
+ case "is_empty":
650
+ return true;
651
+ case "is_not_empty":
652
+ return false;
653
+ case "is_true":
654
+ return false;
655
+ case "is_false":
656
+ return true;
657
+ default:
658
+ return false;
659
+ }
660
+ }
661
+ const strValue = String(fieldValue);
662
+ const numValue = Number(fieldValue);
663
+ switch (operator) {
664
+ case "equals":
665
+ if (!isNaN(numValue) && !isNaN(Number(compareValue))) {
666
+ return numValue === Number(compareValue);
667
+ }
668
+ return strValue === compareValue;
669
+ case "not_equals":
670
+ if (!isNaN(numValue) && !isNaN(Number(compareValue))) {
671
+ return numValue !== Number(compareValue);
672
+ }
673
+ return strValue !== compareValue;
674
+ case "greater_than":
675
+ return numValue > Number(compareValue);
676
+ case "greater_or_equal":
677
+ return numValue >= Number(compareValue);
678
+ case "less_than":
679
+ return numValue < Number(compareValue);
680
+ case "less_or_equal":
681
+ return numValue <= Number(compareValue);
682
+ case "contains":
683
+ return strValue.toLowerCase().includes(compareValue.toLowerCase());
684
+ case "starts_with":
685
+ return strValue.toLowerCase().startsWith(compareValue.toLowerCase());
686
+ case "ends_with":
687
+ return strValue.toLowerCase().endsWith(compareValue.toLowerCase());
688
+ case "is_empty":
689
+ return strValue === "" || Array.isArray(fieldValue) && fieldValue.length === 0;
690
+ case "is_not_empty":
691
+ return strValue !== "" && !(Array.isArray(fieldValue) && fieldValue.length === 0);
692
+ case "is_true":
693
+ return Boolean(fieldValue) === true;
694
+ case "is_false":
695
+ return Boolean(fieldValue) === false;
696
+ default:
697
+ return false;
698
+ }
699
+ }
700
+ function getNestedValue(obj, path) {
701
+ const parts = path.split(".");
702
+ let current = obj;
703
+ for (const part of parts) {
704
+ if (current === null || current === undefined || typeof current !== "object") {
705
+ return;
706
+ }
707
+ current = current[part];
708
+ }
709
+ return current;
710
+ }
711
+
712
+ // src/task/Task.ts
713
+ import { compileSchema } from "@workglow/util/schema";
714
+ import { deepEqual, EventEmitter as EventEmitter3, uuid4 as uuid42 } from "@workglow/util";
715
+
716
+ // src/task/TaskError.ts
717
+ import { BaseError } from "@workglow/util";
718
+
719
+ class TaskError extends BaseError {
720
+ static type = "TaskError";
721
+ constructor(message) {
722
+ super(message);
723
+ }
724
+ }
725
+
726
+ class TaskConfigurationError extends TaskError {
727
+ static type = "TaskConfigurationError";
728
+ constructor(message) {
729
+ super(message);
730
+ }
731
+ }
732
+
733
+ class WorkflowError extends TaskError {
734
+ static type = "WorkflowError";
735
+ constructor(message) {
736
+ super(message);
737
+ }
738
+ }
739
+
740
+ class TaskAbortedError extends TaskError {
741
+ static type = "TaskAbortedError";
742
+ constructor(message = "Task aborted") {
743
+ super(message);
744
+ }
745
+ }
746
+
747
+ class TaskTimeoutError extends TaskAbortedError {
748
+ static type = "TaskTimeoutError";
749
+ constructor(timeoutMs) {
750
+ super(timeoutMs ? `Task timed out after ${timeoutMs}ms` : "Task timed out");
751
+ }
752
+ }
753
+
754
+ class TaskFailedError extends TaskError {
755
+ static type = "TaskFailedError";
756
+ constructor(message = "Task failed") {
757
+ super(message);
758
+ }
759
+ }
760
+
761
+ class JobTaskFailedError extends TaskFailedError {
762
+ static type = "JobTaskFailedError";
763
+ jobError;
764
+ constructor(err) {
765
+ super(String(err));
766
+ this.jobError = err;
767
+ }
768
+ }
769
+
770
+ class TaskJSONError extends TaskError {
771
+ static type = "TaskJSONError";
772
+ constructor(message = "Error converting JSON to a Task") {
773
+ super(message);
774
+ }
775
+ }
776
+
777
+ class TaskInvalidInputError extends TaskError {
778
+ static type = "TaskInvalidInputError";
779
+ constructor(message = "Invalid input data") {
780
+ super(message);
781
+ }
782
+ }
783
+
784
+ // src/task/TaskRunner.ts
785
+ import {
786
+ getTelemetryProvider,
787
+ globalServiceRegistry,
788
+ SpanStatusCode
789
+ } from "@workglow/util";
734
790
 
735
791
  // src/task/InputResolver.ts
736
792
  import { getInputResolvers } from "@workglow/util";
@@ -813,7 +869,6 @@ async function resolveSchemaInputs(input, schema, config) {
813
869
  }
814
870
  return resolved;
815
871
  }
816
- var init_InputResolver = () => {};
817
872
 
818
873
  // src/task/StreamTypes.ts
819
874
  function getPortStreamMode(schema, portId) {
@@ -917,11 +972,6 @@ function hasStructuredOutput(schema) {
917
972
  }
918
973
 
919
974
  // src/task/TaskRunner.ts
920
- import {
921
- getTelemetryProvider,
922
- globalServiceRegistry,
923
- SpanStatusCode
924
- } from "@workglow/util";
925
975
  function hasRunConfig(i) {
926
976
  return i !== null && typeof i === "object" && "runConfig" in i;
927
977
  }
@@ -1298,18 +1348,8 @@ class TaskRunner {
1298
1348
  await this.updateProgress(this.task, progress, message, ...args);
1299
1349
  }
1300
1350
  }
1301
- var init_TaskRunner = __esm(() => {
1302
- init_TaskOutputRepository();
1303
- init_Conversions();
1304
- init_InputResolver();
1305
- init_TaskError();
1306
- init_TaskTypes();
1307
- });
1308
1351
 
1309
1352
  // src/task/Task.ts
1310
- import { compileSchema } from "@workglow/util/schema";
1311
- import { deepEqual, EventEmitter as EventEmitter3, uuid4 as uuid42 } from "@workglow/util";
1312
-
1313
1353
  class Task {
1314
1354
  static type = "Task";
1315
1355
  static category = "Hidden";
@@ -1789,146 +1829,52 @@ class Task {
1789
1829
  this.events.emit("regenerate");
1790
1830
  }
1791
1831
  }
1792
- var init_Task = __esm(() => {
1793
- init_Dataflow();
1794
- init_TaskGraph();
1795
- init_TaskError();
1796
- init_TaskRunner();
1797
- init_TaskTypes();
1798
- });
1799
-
1800
- // src/task/ConditionUtils.ts
1801
- function evaluateCondition(fieldValue, operator, compareValue) {
1802
- if (fieldValue === null || fieldValue === undefined) {
1803
- switch (operator) {
1804
- case "is_empty":
1805
- return true;
1806
- case "is_not_empty":
1807
- return false;
1808
- case "is_true":
1809
- return false;
1810
- case "is_false":
1811
- return true;
1812
- default:
1813
- return false;
1814
- }
1815
- }
1816
- const strValue = String(fieldValue);
1817
- const numValue = Number(fieldValue);
1818
- switch (operator) {
1819
- case "equals":
1820
- if (!isNaN(numValue) && !isNaN(Number(compareValue))) {
1821
- return numValue === Number(compareValue);
1822
- }
1823
- return strValue === compareValue;
1824
- case "not_equals":
1825
- if (!isNaN(numValue) && !isNaN(Number(compareValue))) {
1826
- return numValue !== Number(compareValue);
1827
- }
1828
- return strValue !== compareValue;
1829
- case "greater_than":
1830
- return numValue > Number(compareValue);
1831
- case "greater_or_equal":
1832
- return numValue >= Number(compareValue);
1833
- case "less_than":
1834
- return numValue < Number(compareValue);
1835
- case "less_or_equal":
1836
- return numValue <= Number(compareValue);
1837
- case "contains":
1838
- return strValue.toLowerCase().includes(compareValue.toLowerCase());
1839
- case "starts_with":
1840
- return strValue.toLowerCase().startsWith(compareValue.toLowerCase());
1841
- case "ends_with":
1842
- return strValue.toLowerCase().endsWith(compareValue.toLowerCase());
1843
- case "is_empty":
1844
- return strValue === "" || Array.isArray(fieldValue) && fieldValue.length === 0;
1845
- case "is_not_empty":
1846
- return strValue !== "" && !(Array.isArray(fieldValue) && fieldValue.length === 0);
1847
- case "is_true":
1848
- return Boolean(fieldValue) === true;
1849
- case "is_false":
1850
- return Boolean(fieldValue) === false;
1851
- default:
1852
- return false;
1853
- }
1854
- }
1855
- function getNestedValue(obj, path) {
1856
- const parts = path.split(".");
1857
- let current = obj;
1858
- for (const part of parts) {
1859
- if (current === null || current === undefined || typeof current !== "object") {
1860
- return;
1861
- }
1862
- current = current[part];
1863
- }
1864
- return current;
1865
- }
1866
1832
 
1867
1833
  // src/task/ConditionalTask.ts
1868
- import { getLogger } from "@workglow/util";
1869
- var conditionalTaskConfigSchema, ConditionalTask;
1870
- var init_ConditionalTask = __esm(() => {
1871
- init_Task();
1872
- init_TaskTypes();
1873
- conditionalTaskConfigSchema = {
1874
- type: "object",
1875
- properties: {
1876
- ...TaskConfigSchema["properties"],
1877
- branches: { type: "array", items: {} },
1878
- defaultBranch: { type: "string" },
1879
- exclusive: { type: "boolean" },
1880
- conditionConfig: { type: "object", additionalProperties: true }
1881
- },
1882
- additionalProperties: false
1883
- };
1884
- ConditionalTask = class ConditionalTask extends Task {
1885
- static type = "ConditionalTask";
1886
- static category = "Flow Control";
1887
- static title = "Condition";
1888
- static description = "Route data based on conditions";
1889
- static hasDynamicSchemas = true;
1890
- static configSchema() {
1891
- return conditionalTaskConfigSchema;
1892
- }
1893
- activeBranches = new Set;
1894
- buildBranchesFromConditionConfig(conditionConfig) {
1895
- if (!conditionConfig?.branches || conditionConfig.branches.length === 0) {
1896
- return [
1897
- {
1898
- id: "default",
1899
- condition: () => true,
1900
- outputPort: "1"
1901
- }
1902
- ];
1903
- }
1904
- return conditionConfig.branches.map((branch, index) => ({
1905
- id: branch.id,
1906
- outputPort: String(index + 1),
1907
- condition: (inputData) => {
1908
- const fieldValue = getNestedValue(inputData, branch.field);
1909
- return evaluateCondition(fieldValue, branch.operator, branch.value);
1834
+ var conditionalTaskConfigSchema = {
1835
+ type: "object",
1836
+ properties: {
1837
+ ...TaskConfigSchema["properties"],
1838
+ branches: { type: "array", items: {} },
1839
+ defaultBranch: { type: "string" },
1840
+ exclusive: { type: "boolean" },
1841
+ conditionConfig: { type: "object", additionalProperties: true }
1842
+ },
1843
+ additionalProperties: false
1844
+ };
1845
+
1846
+ class ConditionalTask extends Task {
1847
+ static type = "ConditionalTask";
1848
+ static category = "Flow Control";
1849
+ static title = "Condition";
1850
+ static description = "Route data based on conditions";
1851
+ static hasDynamicSchemas = true;
1852
+ static configSchema() {
1853
+ return conditionalTaskConfigSchema;
1854
+ }
1855
+ activeBranches = new Set;
1856
+ buildBranchesFromConditionConfig(conditionConfig) {
1857
+ if (!conditionConfig?.branches || conditionConfig.branches.length === 0) {
1858
+ return [
1859
+ {
1860
+ id: "default",
1861
+ condition: () => true,
1862
+ outputPort: "1"
1910
1863
  }
1911
- }));
1864
+ ];
1912
1865
  }
1913
- resolveBranches(input) {
1914
- const configBranches = this.config.branches ?? [];
1915
- if (configBranches.length > 0 && typeof configBranches[0].condition === "function") {
1916
- return {
1917
- branches: configBranches,
1918
- isExclusive: this.config.exclusive ?? true,
1919
- defaultBranch: this.config.defaultBranch,
1920
- fromConditionConfig: false
1921
- };
1922
- }
1923
- const conditionConfig = input.conditionConfig ?? this.config.conditionConfig;
1924
- if (conditionConfig) {
1925
- return {
1926
- branches: this.buildBranchesFromConditionConfig(conditionConfig),
1927
- isExclusive: conditionConfig.exclusive ?? true,
1928
- defaultBranch: conditionConfig.defaultBranch,
1929
- fromConditionConfig: true
1930
- };
1866
+ return conditionConfig.branches.map((branch, index) => ({
1867
+ id: branch.id,
1868
+ outputPort: String(index + 1),
1869
+ condition: (inputData) => {
1870
+ const fieldValue = getNestedValue(inputData, branch.field);
1871
+ return evaluateCondition(fieldValue, branch.operator, branch.value);
1931
1872
  }
1873
+ }));
1874
+ }
1875
+ resolveBranches(input) {
1876
+ const configBranches = this.config.branches ?? [];
1877
+ if (configBranches.length > 0 && typeof configBranches[0].condition === "function") {
1932
1878
  return {
1933
1879
  branches: configBranches,
1934
1880
  isExclusive: this.config.exclusive ?? true,
@@ -1936,146 +1882,161 @@ var init_ConditionalTask = __esm(() => {
1936
1882
  fromConditionConfig: false
1937
1883
  };
1938
1884
  }
1939
- async execute(input, context) {
1940
- if (context.signal?.aborted) {
1941
- return;
1942
- }
1943
- this.activeBranches.clear();
1944
- const { branches, isExclusive, defaultBranch, fromConditionConfig } = this.resolveBranches(input);
1945
- for (const branch of branches) {
1946
- try {
1947
- const isActive = branch.condition(input);
1948
- if (isActive) {
1949
- this.activeBranches.add(branch.id);
1950
- if (isExclusive) {
1951
- break;
1952
- }
1885
+ const conditionConfig = input.conditionConfig ?? this.config.conditionConfig;
1886
+ if (conditionConfig) {
1887
+ return {
1888
+ branches: this.buildBranchesFromConditionConfig(conditionConfig),
1889
+ isExclusive: conditionConfig.exclusive ?? true,
1890
+ defaultBranch: conditionConfig.defaultBranch,
1891
+ fromConditionConfig: true
1892
+ };
1893
+ }
1894
+ return {
1895
+ branches: configBranches,
1896
+ isExclusive: this.config.exclusive ?? true,
1897
+ defaultBranch: this.config.defaultBranch,
1898
+ fromConditionConfig: false
1899
+ };
1900
+ }
1901
+ async execute(input, context) {
1902
+ if (context.signal?.aborted) {
1903
+ return;
1904
+ }
1905
+ this.activeBranches.clear();
1906
+ const { branches, isExclusive, defaultBranch, fromConditionConfig } = this.resolveBranches(input);
1907
+ for (const branch of branches) {
1908
+ try {
1909
+ const isActive = branch.condition(input);
1910
+ if (isActive) {
1911
+ this.activeBranches.add(branch.id);
1912
+ if (isExclusive) {
1913
+ break;
1953
1914
  }
1954
- } catch (error) {
1955
- getLogger().warn(`Condition evaluation failed for branch "${branch.id}":`, { error });
1956
- }
1957
- }
1958
- if (this.activeBranches.size === 0 && defaultBranch) {
1959
- const defaultBranchExists = branches.some((b) => b.id === defaultBranch);
1960
- if (defaultBranchExists) {
1961
- this.activeBranches.add(defaultBranch);
1962
1915
  }
1916
+ } catch (error) {
1917
+ getLogger().warn(`Condition evaluation failed for branch "${branch.id}":`, { error });
1963
1918
  }
1964
- if (fromConditionConfig) {
1965
- return this.buildConditionConfigOutput(input, branches, isExclusive);
1919
+ }
1920
+ if (this.activeBranches.size === 0 && defaultBranch) {
1921
+ const defaultBranchExists = branches.some((b) => b.id === defaultBranch);
1922
+ if (defaultBranchExists) {
1923
+ this.activeBranches.add(defaultBranch);
1966
1924
  }
1967
- return this.buildOutput(input);
1968
1925
  }
1969
- buildConditionConfigOutput(input, branches, isExclusive) {
1970
- const output = {};
1971
- const { conditionConfig, ...passThrough } = input;
1972
- const inputKeys = Object.keys(passThrough);
1973
- let matchedBranchNumber = null;
1974
- for (let i = 0;i < branches.length; i++) {
1975
- if (this.activeBranches.has(branches[i].id)) {
1976
- if (matchedBranchNumber === null) {
1977
- matchedBranchNumber = i + 1;
1978
- }
1926
+ if (fromConditionConfig) {
1927
+ return this.buildConditionConfigOutput(input, branches, isExclusive);
1928
+ }
1929
+ return this.buildOutput(input);
1930
+ }
1931
+ buildConditionConfigOutput(input, branches, isExclusive) {
1932
+ const output = {};
1933
+ const { conditionConfig, ...passThrough } = input;
1934
+ const inputKeys = Object.keys(passThrough);
1935
+ let matchedBranchNumber = null;
1936
+ for (let i = 0;i < branches.length; i++) {
1937
+ if (this.activeBranches.has(branches[i].id)) {
1938
+ if (matchedBranchNumber === null) {
1939
+ matchedBranchNumber = i + 1;
1979
1940
  }
1980
1941
  }
1981
- if (isExclusive) {
1982
- if (matchedBranchNumber !== null) {
1983
- for (const key of inputKeys) {
1984
- output[`${key}_${matchedBranchNumber}`] = passThrough[key];
1985
- }
1986
- } else {
1987
- for (const key of inputKeys) {
1988
- output[`${key}_else`] = passThrough[key];
1989
- }
1942
+ }
1943
+ if (isExclusive) {
1944
+ if (matchedBranchNumber !== null) {
1945
+ for (const key of inputKeys) {
1946
+ output[`${key}_${matchedBranchNumber}`] = passThrough[key];
1990
1947
  }
1991
1948
  } else {
1992
- for (let i = 0;i < branches.length; i++) {
1993
- if (this.activeBranches.has(branches[i].id)) {
1994
- for (const key of inputKeys) {
1995
- output[`${key}_${i + 1}`] = passThrough[key];
1996
- }
1997
- }
1949
+ for (const key of inputKeys) {
1950
+ output[`${key}_else`] = passThrough[key];
1998
1951
  }
1999
1952
  }
2000
- return output;
2001
- }
2002
- buildOutput(input) {
2003
- const output = {
2004
- _activeBranches: Array.from(this.activeBranches)
2005
- };
2006
- const branches = this.config.branches ?? [];
2007
- for (const branch of branches) {
2008
- if (this.activeBranches.has(branch.id)) {
2009
- output[branch.outputPort] = { ...input };
1953
+ } else {
1954
+ for (let i = 0;i < branches.length; i++) {
1955
+ if (this.activeBranches.has(branches[i].id)) {
1956
+ for (const key of inputKeys) {
1957
+ output[`${key}_${i + 1}`] = passThrough[key];
1958
+ }
2010
1959
  }
2011
1960
  }
2012
- return output;
2013
- }
2014
- isBranchActive(branchId) {
2015
- return this.activeBranches.has(branchId);
2016
- }
2017
- getActiveBranches() {
2018
- return new Set(this.activeBranches);
2019
1961
  }
2020
- getPortActiveStatus() {
2021
- const status = new Map;
2022
- const branches = this.config.branches ?? [];
2023
- for (const branch of branches) {
2024
- status.set(branch.outputPort, this.activeBranches.has(branch.id));
1962
+ return output;
1963
+ }
1964
+ buildOutput(input) {
1965
+ const output = {
1966
+ _activeBranches: Array.from(this.activeBranches)
1967
+ };
1968
+ const branches = this.config.branches ?? [];
1969
+ for (const branch of branches) {
1970
+ if (this.activeBranches.has(branch.id)) {
1971
+ output[branch.outputPort] = { ...input };
2025
1972
  }
2026
- return status;
2027
1973
  }
2028
- static outputSchema() {
2029
- return {
2030
- type: "object",
2031
- properties: {
2032
- _activeBranches: {
2033
- type: "array",
2034
- items: { type: "string" },
2035
- description: "List of active branch IDs after condition evaluation"
2036
- }
2037
- },
2038
- additionalProperties: true
2039
- };
1974
+ return output;
1975
+ }
1976
+ isBranchActive(branchId) {
1977
+ return this.activeBranches.has(branchId);
1978
+ }
1979
+ getActiveBranches() {
1980
+ return new Set(this.activeBranches);
1981
+ }
1982
+ getPortActiveStatus() {
1983
+ const status = new Map;
1984
+ const branches = this.config.branches ?? [];
1985
+ for (const branch of branches) {
1986
+ status.set(branch.outputPort, this.activeBranches.has(branch.id));
2040
1987
  }
2041
- outputSchema() {
2042
- const branches = this.config?.branches ?? [];
2043
- const properties = {
1988
+ return status;
1989
+ }
1990
+ static outputSchema() {
1991
+ return {
1992
+ type: "object",
1993
+ properties: {
2044
1994
  _activeBranches: {
2045
1995
  type: "array",
2046
1996
  items: { type: "string" },
2047
1997
  description: "List of active branch IDs after condition evaluation"
2048
1998
  }
2049
- };
2050
- for (const branch of branches) {
2051
- properties[branch.outputPort] = {
2052
- type: "object",
2053
- description: `Output for branch "${branch.id}" when active`,
2054
- additionalProperties: true
2055
- };
1999
+ },
2000
+ additionalProperties: true
2001
+ };
2002
+ }
2003
+ outputSchema() {
2004
+ const branches = this.config?.branches ?? [];
2005
+ const properties = {
2006
+ _activeBranches: {
2007
+ type: "array",
2008
+ items: { type: "string" },
2009
+ description: "List of active branch IDs after condition evaluation"
2056
2010
  }
2057
- return {
2058
- type: "object",
2059
- properties,
2060
- additionalProperties: false
2061
- };
2062
- }
2063
- static inputSchema() {
2064
- return {
2065
- type: "object",
2066
- properties: {},
2067
- additionalProperties: true
2068
- };
2069
- }
2070
- inputSchema() {
2071
- return {
2011
+ };
2012
+ for (const branch of branches) {
2013
+ properties[branch.outputPort] = {
2072
2014
  type: "object",
2073
- properties: {},
2015
+ description: `Output for branch "${branch.id}" when active`,
2074
2016
  additionalProperties: true
2075
2017
  };
2076
2018
  }
2077
- };
2078
- });
2019
+ return {
2020
+ type: "object",
2021
+ properties,
2022
+ additionalProperties: false
2023
+ };
2024
+ }
2025
+ static inputSchema() {
2026
+ return {
2027
+ type: "object",
2028
+ properties: {},
2029
+ additionalProperties: true
2030
+ };
2031
+ }
2032
+ inputSchema() {
2033
+ return {
2034
+ type: "object",
2035
+ properties: {},
2036
+ additionalProperties: true
2037
+ };
2038
+ }
2039
+ }
2079
2040
 
2080
2041
  // src/task-graph/TaskGraphScheduler.ts
2081
2042
  class TopologicalScheduler {
@@ -2220,24 +2181,14 @@ class DependencyBasedScheduler {
2220
2181
  this.nextResolver = null;
2221
2182
  }
2222
2183
  }
2223
- var init_TaskGraphScheduler = __esm(() => {
2224
- init_TaskTypes();
2225
- });
2226
2184
 
2227
2185
  // src/task-graph/TaskGraphRunner.ts
2228
- import {
2229
- collectPropertyValues,
2230
- getLogger as getLogger2,
2231
- getTelemetryProvider as getTelemetryProvider2,
2232
- globalServiceRegistry as globalServiceRegistry2,
2233
- ServiceRegistry as ServiceRegistry2,
2234
- SpanStatusCode as SpanStatusCode2,
2235
- uuid4 as uuid43
2236
- } from "@workglow/util";
2237
2186
  function taskPrototypeHasOwnExecute(task) {
2238
2187
  const Ctor = task.constructor;
2239
2188
  return Object.hasOwn(Ctor.prototype, "execute");
2240
2189
  }
2190
+ var PROPERTY_ARRAY = "PROPERTY_ARRAY";
2191
+ var GRAPH_RESULT_ARRAY = "GRAPH_RESULT_ARRAY";
2241
2192
 
2242
2193
  class TaskGraphRunner {
2243
2194
  processScheduler;
@@ -2839,254 +2790,231 @@ class TaskGraphRunner {
2839
2790
  }
2840
2791
  }
2841
2792
  }
2842
- var PROPERTY_ARRAY = "PROPERTY_ARRAY", GRAPH_RESULT_ARRAY = "GRAPH_RESULT_ARRAY";
2843
- var init_TaskGraphRunner = __esm(() => {
2844
- init_TaskOutputRepository();
2845
- init_ConditionalTask();
2846
- init_TaskError();
2847
- init_TaskTypes();
2848
- init_Dataflow();
2849
- init_TaskGraphScheduler();
2850
- });
2851
2793
 
2852
2794
  // src/task/GraphAsTaskRunner.ts
2853
- var GraphAsTaskRunner;
2854
- var init_GraphAsTaskRunner = __esm(() => {
2855
- init_TaskRunner();
2856
- GraphAsTaskRunner = class GraphAsTaskRunner extends TaskRunner {
2857
- async executeTaskChildren(input) {
2858
- const unsubscribe = this.task.subGraph.subscribe("graph_progress", (progress, message, ...args) => {
2859
- this.task.emit("progress", progress, message, ...args);
2860
- });
2861
- const results = await this.task.subGraph.run(input, {
2862
- parentSignal: this.abortController?.signal,
2863
- outputCache: this.outputCache,
2864
- registry: this.registry
2865
- });
2866
- unsubscribe();
2867
- return results;
2868
- }
2869
- async executeTaskChildrenReactive() {
2870
- return this.task.subGraph.runReactive(this.task.runInputData, {
2871
- registry: this.registry
2872
- });
2873
- }
2874
- async handleDisable() {
2875
- if (this.task.hasChildren()) {
2876
- await this.task.subGraph.disable();
2877
- }
2878
- super.handleDisable();
2795
+ class GraphAsTaskRunner extends TaskRunner {
2796
+ async executeTaskChildren(input) {
2797
+ const unsubscribe = this.task.subGraph.subscribe("graph_progress", (progress, message, ...args) => {
2798
+ this.task.emit("progress", progress, message, ...args);
2799
+ });
2800
+ const results = await this.task.subGraph.run(input, {
2801
+ parentSignal: this.abortController?.signal,
2802
+ outputCache: this.outputCache,
2803
+ registry: this.registry
2804
+ });
2805
+ unsubscribe();
2806
+ return results;
2807
+ }
2808
+ async executeTaskChildrenReactive() {
2809
+ return this.task.subGraph.runReactive(this.task.runInputData, {
2810
+ registry: this.registry
2811
+ });
2812
+ }
2813
+ async handleDisable() {
2814
+ if (this.task.hasChildren()) {
2815
+ await this.task.subGraph.disable();
2879
2816
  }
2880
- async executeTask(input) {
2881
- if (this.task.hasChildren()) {
2882
- const runExecuteOutputData = await this.executeTaskChildren(input);
2883
- this.task.runOutputData = this.task.subGraph.mergeExecuteOutputsToRunOutput(runExecuteOutputData, this.task.compoundMerge);
2884
- } else {
2885
- const result = await super.executeTask(input);
2886
- this.task.runOutputData = result ?? {};
2887
- }
2888
- return this.task.runOutputData;
2817
+ super.handleDisable();
2818
+ }
2819
+ async executeTask(input) {
2820
+ if (this.task.hasChildren()) {
2821
+ const runExecuteOutputData = await this.executeTaskChildren(input);
2822
+ this.task.runOutputData = this.task.subGraph.mergeExecuteOutputsToRunOutput(runExecuteOutputData, this.task.compoundMerge);
2823
+ } else {
2824
+ const result = await super.executeTask(input);
2825
+ this.task.runOutputData = result ?? {};
2889
2826
  }
2890
- async executeTaskReactive(input, output) {
2891
- if (this.task.hasChildren()) {
2892
- const reactiveResults = await this.executeTaskChildrenReactive();
2893
- this.task.runOutputData = this.task.subGraph.mergeExecuteOutputsToRunOutput(reactiveResults, this.task.compoundMerge);
2894
- } else {
2895
- const reactiveResults = await super.executeTaskReactive(input, output);
2896
- this.task.runOutputData = Object.assign({}, output, reactiveResults ?? {});
2897
- }
2898
- return this.task.runOutputData;
2827
+ return this.task.runOutputData;
2828
+ }
2829
+ async executeTaskReactive(input, output) {
2830
+ if (this.task.hasChildren()) {
2831
+ const reactiveResults = await this.executeTaskChildrenReactive();
2832
+ this.task.runOutputData = this.task.subGraph.mergeExecuteOutputsToRunOutput(reactiveResults, this.task.compoundMerge);
2833
+ } else {
2834
+ const reactiveResults = await super.executeTaskReactive(input, output);
2835
+ this.task.runOutputData = Object.assign({}, output, reactiveResults ?? {});
2899
2836
  }
2900
- };
2901
- });
2837
+ return this.task.runOutputData;
2838
+ }
2839
+ }
2902
2840
 
2903
2841
  // src/task/GraphAsTask.ts
2904
- var exports_GraphAsTask = {};
2905
- __export(exports_GraphAsTask, {
2906
- graphAsTaskConfigSchema: () => graphAsTaskConfigSchema,
2907
- GraphAsTask: () => GraphAsTask
2908
- });
2909
- import { compileSchema as compileSchema2 } from "@workglow/util/schema";
2910
- var graphAsTaskConfigSchema, GraphAsTask;
2911
- var init_GraphAsTask = __esm(() => {
2912
- init_GraphSchemaUtils();
2913
- init_TaskGraphRunner();
2914
- init_GraphAsTaskRunner();
2915
- init_Task();
2916
- init_TaskTypes();
2917
- graphAsTaskConfigSchema = {
2918
- type: "object",
2919
- properties: {
2920
- ...TaskConfigSchema["properties"],
2921
- compoundMerge: { type: "string", "x-ui-hidden": true }
2922
- },
2923
- additionalProperties: false
2924
- };
2925
- GraphAsTask = class GraphAsTask extends Task {
2926
- static type = "GraphAsTask";
2927
- static title = "Group";
2928
- static description = "A group of tasks that are executed together";
2929
- static category = "Flow Control";
2930
- static compoundMerge = PROPERTY_ARRAY;
2931
- static hasDynamicSchemas = true;
2932
- constructor(input = {}, config = {}) {
2933
- const { subGraph, ...rest } = config;
2934
- super(input, rest);
2935
- if (subGraph) {
2936
- this.subGraph = subGraph;
2937
- }
2938
- this.regenerateGraph();
2842
+ var graphAsTaskConfigSchema = {
2843
+ type: "object",
2844
+ properties: {
2845
+ ...TaskConfigSchema["properties"],
2846
+ compoundMerge: { type: "string", "x-ui-hidden": true }
2847
+ },
2848
+ additionalProperties: false
2849
+ };
2850
+
2851
+ class GraphAsTask extends Task {
2852
+ static type = "GraphAsTask";
2853
+ static title = "Group";
2854
+ static description = "A group of tasks that are executed together";
2855
+ static category = "Flow Control";
2856
+ static compoundMerge = PROPERTY_ARRAY;
2857
+ static hasDynamicSchemas = true;
2858
+ constructor(input = {}, config = {}) {
2859
+ const { subGraph, ...rest } = config;
2860
+ super(input, rest);
2861
+ if (subGraph) {
2862
+ this.subGraph = subGraph;
2939
2863
  }
2940
- get runner() {
2941
- if (!this._runner) {
2942
- this._runner = new GraphAsTaskRunner(this);
2943
- }
2944
- return this._runner;
2864
+ this.regenerateGraph();
2865
+ }
2866
+ get runner() {
2867
+ if (!this._runner) {
2868
+ this._runner = new GraphAsTaskRunner(this);
2945
2869
  }
2946
- static configSchema() {
2947
- return graphAsTaskConfigSchema;
2870
+ return this._runner;
2871
+ }
2872
+ static configSchema() {
2873
+ return graphAsTaskConfigSchema;
2874
+ }
2875
+ get compoundMerge() {
2876
+ return this.config?.compoundMerge || this.constructor.compoundMerge;
2877
+ }
2878
+ get cacheable() {
2879
+ return this.runConfig?.cacheable ?? this.config?.cacheable ?? (this.constructor.cacheable && !this.hasChildren());
2880
+ }
2881
+ inputSchema() {
2882
+ if (!this.hasChildren()) {
2883
+ return this.constructor.inputSchema();
2948
2884
  }
2949
- get compoundMerge() {
2950
- return this.config?.compoundMerge || this.constructor.compoundMerge;
2885
+ return computeGraphInputSchema(this.subGraph);
2886
+ }
2887
+ _inputSchemaNode;
2888
+ getInputSchemaNode() {
2889
+ if (!this._inputSchemaNode) {
2890
+ try {
2891
+ const dataPortSchema = this.inputSchema();
2892
+ const schemaNode = Task.generateInputSchemaNode(dataPortSchema);
2893
+ this._inputSchemaNode = schemaNode;
2894
+ } catch (error) {
2895
+ console.warn(`Failed to compile input schema for ${this.type}, falling back to permissive validation:`, error);
2896
+ this._inputSchemaNode = compileSchema2({});
2897
+ }
2951
2898
  }
2952
- get cacheable() {
2953
- return this.runConfig?.cacheable ?? this.config?.cacheable ?? (this.constructor.cacheable && !this.hasChildren());
2899
+ return this._inputSchemaNode;
2900
+ }
2901
+ outputSchema() {
2902
+ if (!this.hasChildren()) {
2903
+ return this.constructor.outputSchema();
2954
2904
  }
2955
- inputSchema() {
2956
- if (!this.hasChildren()) {
2957
- return this.constructor.inputSchema();
2958
- }
2959
- return computeGraphInputSchema(this.subGraph);
2905
+ return computeGraphOutputSchema(this.subGraph);
2906
+ }
2907
+ resetInputData() {
2908
+ super.resetInputData();
2909
+ if (this.hasChildren()) {
2910
+ this.subGraph.getTasks().forEach((node) => {
2911
+ node.resetInputData();
2912
+ });
2913
+ this.subGraph.getDataflows().forEach((dataflow) => {
2914
+ dataflow.reset();
2915
+ });
2960
2916
  }
2961
- _inputSchemaNode;
2962
- getInputSchemaNode() {
2963
- if (!this._inputSchemaNode) {
2917
+ }
2918
+ async* executeStream(input, context) {
2919
+ if (context.inputStreams) {
2920
+ for (const [, stream] of context.inputStreams) {
2921
+ const reader = stream.getReader();
2964
2922
  try {
2965
- const dataPortSchema = this.inputSchema();
2966
- const schemaNode = Task.generateInputSchemaNode(dataPortSchema);
2967
- this._inputSchemaNode = schemaNode;
2968
- } catch (error) {
2969
- console.warn(`Failed to compile input schema for ${this.type}, falling back to permissive validation:`, error);
2970
- this._inputSchemaNode = compileSchema2({});
2923
+ while (true) {
2924
+ const { done, value } = await reader.read();
2925
+ if (done)
2926
+ break;
2927
+ if (value.type === "finish")
2928
+ continue;
2929
+ yield value;
2930
+ }
2931
+ } finally {
2932
+ reader.releaseLock();
2971
2933
  }
2972
2934
  }
2973
- return this._inputSchemaNode;
2974
- }
2975
- outputSchema() {
2976
- if (!this.hasChildren()) {
2977
- return this.constructor.outputSchema();
2978
- }
2979
- return computeGraphOutputSchema(this.subGraph);
2980
- }
2981
- resetInputData() {
2982
- super.resetInputData();
2983
- if (this.hasChildren()) {
2984
- this.subGraph.getTasks().forEach((node) => {
2985
- node.resetInputData();
2986
- });
2987
- this.subGraph.getDataflows().forEach((dataflow) => {
2988
- dataflow.reset();
2989
- });
2990
- }
2991
2935
  }
2992
- async* executeStream(input, context) {
2993
- if (context.inputStreams) {
2994
- for (const [, stream] of context.inputStreams) {
2995
- const reader = stream.getReader();
2996
- try {
2997
- while (true) {
2998
- const { done, value } = await reader.read();
2999
- if (done)
3000
- break;
3001
- if (value.type === "finish")
3002
- continue;
3003
- yield value;
3004
- }
3005
- } finally {
3006
- reader.releaseLock();
3007
- }
2936
+ if (this.hasChildren()) {
2937
+ const endingNodeIds = new Set;
2938
+ const tasks = this.subGraph.getTasks();
2939
+ for (const task of tasks) {
2940
+ if (this.subGraph.getTargetDataflows(task.id).length === 0) {
2941
+ endingNodeIds.add(task.id);
3008
2942
  }
3009
2943
  }
3010
- if (this.hasChildren()) {
3011
- const endingNodeIds = new Set;
3012
- const tasks = this.subGraph.getTasks();
3013
- for (const task of tasks) {
3014
- if (this.subGraph.getTargetDataflows(task.id).length === 0) {
3015
- endingNodeIds.add(task.id);
2944
+ const eventQueue = [];
2945
+ let resolveWaiting;
2946
+ let subgraphDone = false;
2947
+ const unsub = this.subGraph.subscribeToTaskStreaming({
2948
+ onStreamChunk: (taskId, event) => {
2949
+ if (endingNodeIds.has(taskId) && event.type !== "finish") {
2950
+ eventQueue.push(event);
2951
+ resolveWaiting?.();
3016
2952
  }
3017
2953
  }
3018
- const eventQueue = [];
3019
- let resolveWaiting;
3020
- let subgraphDone = false;
3021
- const unsub = this.subGraph.subscribeToTaskStreaming({
3022
- onStreamChunk: (taskId, event) => {
3023
- if (endingNodeIds.has(taskId) && event.type !== "finish") {
3024
- eventQueue.push(event);
3025
- resolveWaiting?.();
3026
- }
3027
- }
3028
- });
3029
- const runPromise = this.subGraph.run(input, { parentSignal: context.signal, accumulateLeafOutputs: false }).then((results2) => {
3030
- subgraphDone = true;
3031
- resolveWaiting?.();
3032
- return results2;
3033
- });
3034
- while (!subgraphDone) {
3035
- if (eventQueue.length === 0) {
3036
- await new Promise((resolve) => {
3037
- resolveWaiting = resolve;
3038
- });
3039
- }
3040
- while (eventQueue.length > 0) {
3041
- yield eventQueue.shift();
3042
- }
2954
+ });
2955
+ const runPromise = this.subGraph.run(input, { parentSignal: context.signal, accumulateLeafOutputs: false }).then((results2) => {
2956
+ subgraphDone = true;
2957
+ resolveWaiting?.();
2958
+ return results2;
2959
+ });
2960
+ while (!subgraphDone) {
2961
+ if (eventQueue.length === 0) {
2962
+ await new Promise((resolve) => {
2963
+ resolveWaiting = resolve;
2964
+ });
3043
2965
  }
3044
2966
  while (eventQueue.length > 0) {
3045
2967
  yield eventQueue.shift();
3046
2968
  }
3047
- unsub();
3048
- const results = await runPromise;
3049
- const mergedOutput = this.subGraph.mergeExecuteOutputsToRunOutput(results, this.compoundMerge);
3050
- yield { type: "finish", data: mergedOutput };
3051
- } else {
3052
- yield { type: "finish", data: input };
3053
2969
  }
3054
- }
3055
- regenerateGraph() {
3056
- this._inputSchemaNode = undefined;
3057
- this.events.emit("regenerate");
3058
- }
3059
- toJSON(options) {
3060
- let json = super.toJSON(options);
3061
- const hasChildren = this.hasChildren();
3062
- if (hasChildren) {
3063
- json = {
3064
- ...json,
3065
- merge: this.compoundMerge,
3066
- subgraph: this.subGraph.toJSON(options)
3067
- };
2970
+ while (eventQueue.length > 0) {
2971
+ yield eventQueue.shift();
3068
2972
  }
3069
- return json;
2973
+ unsub();
2974
+ const results = await runPromise;
2975
+ const mergedOutput = this.subGraph.mergeExecuteOutputsToRunOutput(results, this.compoundMerge);
2976
+ yield { type: "finish", data: mergedOutput };
2977
+ } else {
2978
+ yield { type: "finish", data: input };
3070
2979
  }
3071
- toDependencyJSON(options) {
3072
- const json = this.toJSON(options);
3073
- if (this.hasChildren()) {
3074
- if ("subgraph" in json) {
3075
- delete json.subgraph;
3076
- }
3077
- return { ...json, subtasks: this.subGraph.toDependencyJSON(options) };
2980
+ }
2981
+ regenerateGraph() {
2982
+ this._inputSchemaNode = undefined;
2983
+ this.events.emit("regenerate");
2984
+ }
2985
+ toJSON(options) {
2986
+ let json = super.toJSON(options);
2987
+ const hasChildren = this.hasChildren();
2988
+ if (hasChildren) {
2989
+ json = {
2990
+ ...json,
2991
+ merge: this.compoundMerge,
2992
+ subgraph: this.subGraph.toJSON(options)
2993
+ };
2994
+ }
2995
+ return json;
2996
+ }
2997
+ toDependencyJSON(options) {
2998
+ const json = this.toJSON(options);
2999
+ if (this.hasChildren()) {
3000
+ if ("subgraph" in json) {
3001
+ delete json.subgraph;
3078
3002
  }
3079
- return json;
3003
+ return { ...json, subtasks: this.subGraph.toDependencyJSON(options) };
3080
3004
  }
3081
- };
3082
- });
3005
+ return json;
3006
+ }
3007
+ }
3083
3008
 
3084
3009
  // src/task-graph/Conversions.ts
3010
+ var _OwnGraphTask;
3011
+ var _OwnWorkflowTask;
3012
+ var _GraphTask;
3013
+ var _ConvWorkflowTask;
3085
3014
  function getWrapperClasses() {
3086
3015
  if (!_OwnGraphTask) {
3087
- const GaT = (init_GraphAsTask(), __toCommonJS(exports_GraphAsTask)).GraphAsTask;
3088
3016
 
3089
- class ListeningGraphAsTask extends GaT {
3017
+ class ListeningGraphAsTask extends GraphAsTask {
3090
3018
  constructor(input, config) {
3091
3019
  super(input, config);
3092
3020
  this.subGraph.on("start", () => {
@@ -3109,11 +3037,11 @@ function getWrapperClasses() {
3109
3037
  static type = "Own[Workflow]";
3110
3038
  }
3111
3039
 
3112
- class GraphTask extends GaT {
3040
+ class GraphTask extends GraphAsTask {
3113
3041
  static type = "Graph";
3114
3042
  }
3115
3043
 
3116
- class ConvWorkflowTask extends GaT {
3044
+ class ConvWorkflowTask extends GraphAsTask {
3117
3045
  static type = "Workflow";
3118
3046
  }
3119
3047
  _OwnGraphTask = OwnGraphTask;
@@ -3178,37 +3106,31 @@ function ensureTask(arg, config = {}) {
3178
3106
  }
3179
3107
  return convertPipeFunctionToTask(arg, config);
3180
3108
  }
3181
- var _OwnGraphTask, _OwnWorkflowTask, _GraphTask, _ConvWorkflowTask;
3182
- var init_Conversions = __esm(() => {
3183
- init_Task();
3184
- init_Dataflow();
3185
- init_TaskGraph();
3186
- });
3187
3109
 
3188
3110
  // src/task-graph/TaskGraphEvents.ts
3189
- var EventDagToTaskGraphMapping, EventTaskGraphToDagMapping;
3190
- var init_TaskGraphEvents = __esm(() => {
3191
- EventDagToTaskGraphMapping = {
3192
- "node-added": "task_added",
3193
- "node-removed": "task_removed",
3194
- "node-replaced": "task_replaced",
3195
- "edge-added": "dataflow_added",
3196
- "edge-removed": "dataflow_removed",
3197
- "edge-replaced": "dataflow_replaced"
3198
- };
3199
- EventTaskGraphToDagMapping = {
3200
- task_added: "node-added",
3201
- task_removed: "node-removed",
3202
- task_replaced: "node-replaced",
3203
- dataflow_added: "edge-added",
3204
- dataflow_removed: "edge-removed",
3205
- dataflow_replaced: "edge-replaced"
3206
- };
3207
- });
3111
+ var EventDagToTaskGraphMapping = {
3112
+ "node-added": "task_added",
3113
+ "node-removed": "task_removed",
3114
+ "node-replaced": "task_replaced",
3115
+ "edge-added": "dataflow_added",
3116
+ "edge-removed": "dataflow_removed",
3117
+ "edge-replaced": "dataflow_replaced"
3118
+ };
3119
+ var EventTaskGraphToDagMapping = {
3120
+ task_added: "node-added",
3121
+ task_removed: "node-removed",
3122
+ task_replaced: "node-replaced",
3123
+ dataflow_added: "edge-added",
3124
+ dataflow_removed: "edge-removed",
3125
+ dataflow_replaced: "edge-replaced"
3126
+ };
3208
3127
 
3209
3128
  // src/task-graph/TaskGraph.ts
3210
- import { DirectedAcyclicGraph } from "@workglow/util/graph";
3211
- import { EventEmitter as EventEmitter4, uuid4 as uuid44 } from "@workglow/util";
3129
+ class TaskGraphDAG extends DirectedAcyclicGraph {
3130
+ constructor() {
3131
+ super((task) => task.id, (dataflow) => dataflow.id);
3132
+ }
3133
+ }
3212
3134
 
3213
3135
  class TaskGraph {
3214
3136
  outputCache;
@@ -3494,38 +3416,7 @@ function serialGraph(tasks, inputHandle, outputHandle) {
3494
3416
  graph.addDataflows(serialGraphEdges(tasks, inputHandle, outputHandle));
3495
3417
  return graph;
3496
3418
  }
3497
- var TaskGraphDAG;
3498
- var init_TaskGraph = __esm(() => {
3499
- init_Conversions();
3500
- init_Dataflow();
3501
- init_GraphSchemaUtils();
3502
- init_TaskGraphEvents();
3503
- init_TaskGraphRunner();
3504
- TaskGraphDAG = class TaskGraphDAG extends DirectedAcyclicGraph {
3505
- constructor() {
3506
- super((task) => task.id, (dataflow) => dataflow.id);
3507
- }
3508
- };
3509
- });
3510
-
3511
- // src/common.ts
3512
- init_Dataflow();
3513
- init_GraphSchemaUtils();
3514
- init_TaskGraph();
3515
- init_TaskGraphEvents();
3516
- init_TaskGraphRunner();
3517
- init_Conversions();
3518
-
3519
- // src/task-graph/GraphToWorkflowCode.ts
3520
- init_Dataflow();
3521
-
3522
3419
  // src/task-graph/Workflow.ts
3523
- init_GraphAsTask();
3524
- init_TaskError();
3525
- init_Conversions();
3526
- init_Dataflow();
3527
- init_TaskGraph();
3528
- init_TaskGraphRunner();
3529
3420
  import {
3530
3421
  EventEmitter as EventEmitter5,
3531
3422
  getLogger as getLogger3,
@@ -4617,17 +4508,7 @@ ${baseIndent}}`;
4617
4508
  function resetMethodNameCache() {
4618
4509
  methodNameCache = undefined;
4619
4510
  }
4620
- // src/task/index.ts
4621
- init_ConditionalTask();
4622
-
4623
- // src/task/FallbackTask.ts
4624
- init_GraphAsTask();
4625
-
4626
4511
  // src/task/FallbackTaskRunner.ts
4627
- init_GraphAsTaskRunner();
4628
- init_TaskError();
4629
- init_TaskTypes();
4630
-
4631
4512
  class FallbackTaskRunner extends GraphAsTaskRunner {
4632
4513
  async executeTask(input) {
4633
4514
  if (this.task.fallbackMode === "data") {
@@ -4826,21 +4707,8 @@ queueMicrotask(() => {
4826
4707
  };
4827
4708
  Workflow.prototype.endFallbackWith = CreateEndLoopWorkflow("endFallbackWith");
4828
4709
  });
4829
-
4830
- // src/task/index.ts
4831
- init_GraphAsTask();
4832
- init_GraphAsTaskRunner();
4833
- init_InputResolver();
4834
-
4835
- // src/task/IteratorTask.ts
4836
- init_GraphAsTask();
4837
-
4838
4710
  // src/task/IteratorTaskRunner.ts
4839
- init_Dataflow();
4840
- init_TaskGraph();
4841
- init_GraphAsTaskRunner();
4842
4711
  import { uuid4 as uuid46 } from "@workglow/util";
4843
-
4844
4712
  class IteratorTaskRunner extends GraphAsTaskRunner {
4845
4713
  aggregatingParentMapProgress = false;
4846
4714
  mapPartialProgress = [];
@@ -5006,7 +4874,6 @@ class IteratorTaskRunner extends GraphAsTaskRunner {
5006
4874
  }
5007
4875
 
5008
4876
  // src/task/IteratorTask.ts
5009
- init_TaskError();
5010
4877
  var ITERATOR_CONTEXT_SCHEMA = {
5011
4878
  type: "object",
5012
4879
  properties: {
@@ -5498,13 +5365,7 @@ class IteratorTask extends GraphAsTask {
5498
5365
  }
5499
5366
  }
5500
5367
 
5501
- // src/task/WhileTask.ts
5502
- init_GraphAsTask();
5503
- init_TaskError();
5504
-
5505
5368
  // src/task/WhileTaskRunner.ts
5506
- init_GraphAsTaskRunner();
5507
-
5508
5369
  class WhileTaskRunner extends GraphAsTaskRunner {
5509
5370
  async executeTask(input) {
5510
5371
  const result = await this.task.execute(input, {
@@ -6131,9 +5992,7 @@ if (!globalServiceRegistry3.has(JOB_QUEUE_FACTORY)) {
6131
5992
  registerJobQueueFactory(defaultJobQueueFactory);
6132
5993
  }
6133
5994
  // src/task/JobQueueTask.ts
6134
- init_GraphAsTask();
6135
5995
  import { Job as Job2 } from "@workglow/job-queue";
6136
- init_TaskError();
6137
5996
 
6138
5997
  // src/task/TaskQueueRegistry.ts
6139
5998
  var taskQueueRegistry = null;
@@ -6332,7 +6191,6 @@ class JobQueueTask extends GraphAsTask {
6332
6191
  }
6333
6192
  }
6334
6193
  // src/task/MapTask.ts
6335
- init_TaskGraphRunner();
6336
6194
  var mapTaskConfigSchema = {
6337
6195
  type: "object",
6338
6196
  properties: {
@@ -6504,16 +6362,6 @@ queueMicrotask(() => {
6504
6362
  Workflow.prototype.reduce = CreateLoopWorkflow(ReduceTask);
6505
6363
  Workflow.prototype.endReduce = CreateEndLoopWorkflow("endReduce");
6506
6364
  });
6507
-
6508
- // src/task/index.ts
6509
- init_Task();
6510
- init_TaskError();
6511
-
6512
- // src/task/TaskJSON.ts
6513
- init_Dataflow();
6514
- init_TaskGraph();
6515
- init_TaskError();
6516
-
6517
6365
  // src/task/TaskRegistry.ts
6518
6366
  import {
6519
6367
  createServiceToken as createServiceToken3,
@@ -6562,7 +6410,6 @@ function resolveTaskFromRegistry(id, _format, registry) {
6562
6410
  registerInputResolver("tasks", resolveTaskFromRegistry);
6563
6411
 
6564
6412
  // src/task/TaskJSON.ts
6565
- init_GraphAsTask();
6566
6413
  var createSingleTaskFromJSON = (item, registry) => {
6567
6414
  if (!item.id)
6568
6415
  throw new TaskJSONError("Task id required");
@@ -6618,11 +6465,7 @@ var createGraphFromGraphJSON = (graphJsonObj, registry) => {
6618
6465
  }
6619
6466
  return subGraph;
6620
6467
  };
6621
-
6622
6468
  // src/task/index.ts
6623
- init_ConditionalTask();
6624
- init_TaskTypes();
6625
- init_GraphAsTask();
6626
6469
  var registerBaseTasks = () => {
6627
6470
  const tasks = [GraphAsTask, ConditionalTask, FallbackTask, MapTask, WhileTask, ReduceTask];
6628
6471
  tasks.map(TaskRegistry.registerTask);
@@ -6704,12 +6547,7 @@ class TaskGraphTabularRepository extends TaskGraphRepository {
6704
6547
  return await this.tabularRepository.size();
6705
6548
  }
6706
6549
  }
6707
-
6708
- // src/common.ts
6709
- init_TaskOutputRepository();
6710
-
6711
6550
  // src/storage/TaskOutputTabularRepository.ts
6712
- init_TaskOutputRepository();
6713
6551
  import { compress, decompress } from "@workglow/util/compress";
6714
6552
  import { makeFingerprint } from "@workglow/util";
6715
6553
  var TaskOutputSchema = {
@@ -6917,4 +6755,4 @@ export {
6917
6755
  ConditionalTask
6918
6756
  };
6919
6757
 
6920
- //# debugId=F7E8A2EB122F7E0864756E2164756E21
6758
+ //# debugId=CAF9D48DE789CA7864756E2164756E21