@workglow/tasks 0.0.89 → 0.0.91
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 +1177 -88
- package/dist/browser.js.map +30 -8
- package/dist/bun.js +1177 -88
- package/dist/bun.js.map +30 -8
- package/dist/common.d.ts +43 -2
- package/dist/common.d.ts.map +1 -1
- package/dist/node.js +1177 -88
- package/dist/node.js.map +30 -8
- package/dist/task/ArrayTask.d.ts +1 -1
- package/dist/task/ArrayTask.d.ts.map +1 -1
- package/dist/task/JsonTask.d.ts.map +1 -1
- package/dist/task/MergeTask.d.ts +1 -1
- package/dist/task/MergeTask.d.ts.map +1 -1
- package/dist/task/adaptive.d.ts +16 -0
- package/dist/task/adaptive.d.ts.map +1 -0
- package/dist/task/scalar/ScalarAbsTask.d.ts +71 -0
- package/dist/task/scalar/ScalarAbsTask.d.ts.map +1 -0
- package/dist/task/scalar/ScalarAddTask.d.ts +81 -0
- package/dist/task/scalar/ScalarAddTask.d.ts.map +1 -0
- package/dist/task/scalar/ScalarCeilTask.d.ts +71 -0
- package/dist/task/scalar/ScalarCeilTask.d.ts.map +1 -0
- package/dist/task/scalar/ScalarDivideTask.d.ts +81 -0
- package/dist/task/scalar/ScalarDivideTask.d.ts.map +1 -0
- package/dist/task/scalar/ScalarFloorTask.d.ts +71 -0
- package/dist/task/scalar/ScalarFloorTask.d.ts.map +1 -0
- package/dist/task/scalar/ScalarMaxTask.d.ts +77 -0
- package/dist/task/scalar/ScalarMaxTask.d.ts.map +1 -0
- package/dist/task/scalar/ScalarMinTask.d.ts +77 -0
- package/dist/task/scalar/ScalarMinTask.d.ts.map +1 -0
- package/dist/task/scalar/ScalarMultiplyTask.d.ts +81 -0
- package/dist/task/scalar/ScalarMultiplyTask.d.ts.map +1 -0
- package/dist/task/scalar/ScalarRoundTask.d.ts +71 -0
- package/dist/task/scalar/ScalarRoundTask.d.ts.map +1 -0
- package/dist/task/scalar/ScalarSubtractTask.d.ts +81 -0
- package/dist/task/scalar/ScalarSubtractTask.d.ts.map +1 -0
- package/dist/task/scalar/ScalarSumTask.d.ts +77 -0
- package/dist/task/scalar/ScalarSumTask.d.ts.map +1 -0
- package/dist/task/scalar/ScalarTruncTask.d.ts +71 -0
- package/dist/task/scalar/ScalarTruncTask.d.ts.map +1 -0
- package/dist/task/scalar/scalar.test.d.ts +7 -0
- package/dist/task/scalar/scalar.test.d.ts.map +1 -0
- package/dist/task/scalar/sumPrecise.d.ts +12 -0
- package/dist/task/scalar/sumPrecise.d.ts.map +1 -0
- package/dist/task/vector/VectorDistanceTask.d.ts +83 -0
- package/dist/task/vector/VectorDistanceTask.d.ts.map +1 -0
- package/dist/task/vector/VectorDivideTask.d.ts +85 -0
- package/dist/task/vector/VectorDivideTask.d.ts.map +1 -0
- package/dist/task/vector/VectorDotProductTask.d.ts +83 -0
- package/dist/task/vector/VectorDotProductTask.d.ts.map +1 -0
- package/dist/task/vector/VectorMultiplyTask.d.ts +85 -0
- package/dist/task/vector/VectorMultiplyTask.d.ts.map +1 -0
- package/dist/task/vector/VectorNormalizeTask.d.ts +75 -0
- package/dist/task/vector/VectorNormalizeTask.d.ts.map +1 -0
- package/dist/task/vector/VectorScaleTask.d.ts +85 -0
- package/dist/task/vector/VectorScaleTask.d.ts.map +1 -0
- package/dist/task/vector/VectorSubtractTask.d.ts +85 -0
- package/dist/task/vector/VectorSubtractTask.d.ts.map +1 -0
- package/dist/task/vector/VectorSumTask.d.ts +85 -0
- package/dist/task/vector/VectorSumTask.d.ts.map +1 -0
- package/dist/task/vector/vector.test.d.ts +7 -0
- package/dist/task/vector/vector.test.d.ts.map +1 -0
- package/package.json +9 -9
package/dist/browser.js
CHANGED
|
@@ -622,6 +622,534 @@ var fileLoader = (input, config) => {
|
|
|
622
622
|
};
|
|
623
623
|
Workflow2.prototype.fileLoader = CreateWorkflow2(FileLoaderTask);
|
|
624
624
|
|
|
625
|
+
// src/task/adaptive.ts
|
|
626
|
+
import { CreateAdaptiveWorkflow, Workflow as Workflow12 } from "@workglow/task-graph";
|
|
627
|
+
|
|
628
|
+
// src/task/scalar/ScalarAddTask.ts
|
|
629
|
+
import { CreateWorkflow as CreateWorkflow3, Task as Task2, Workflow as Workflow3 } from "@workglow/task-graph";
|
|
630
|
+
|
|
631
|
+
// src/task/scalar/sumPrecise.ts
|
|
632
|
+
function kahanSum(values) {
|
|
633
|
+
let sum = 0;
|
|
634
|
+
let compensation = 0;
|
|
635
|
+
for (const value of values) {
|
|
636
|
+
const y = value - compensation;
|
|
637
|
+
const t = sum + y;
|
|
638
|
+
compensation = t - sum - y;
|
|
639
|
+
sum = t;
|
|
640
|
+
}
|
|
641
|
+
return sum;
|
|
642
|
+
}
|
|
643
|
+
var nativeSumPrecise = typeof Math.sumPrecise === "function" ? Math.sumPrecise : undefined;
|
|
644
|
+
var sumPrecise = nativeSumPrecise ? nativeSumPrecise.bind(Math) : kahanSum;
|
|
645
|
+
|
|
646
|
+
// src/task/scalar/ScalarAddTask.ts
|
|
647
|
+
var inputSchema3 = {
|
|
648
|
+
type: "object",
|
|
649
|
+
properties: {
|
|
650
|
+
a: {
|
|
651
|
+
type: "number",
|
|
652
|
+
title: "A",
|
|
653
|
+
description: "First number"
|
|
654
|
+
},
|
|
655
|
+
b: {
|
|
656
|
+
type: "number",
|
|
657
|
+
title: "B",
|
|
658
|
+
description: "Second number"
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
required: ["a", "b"],
|
|
662
|
+
additionalProperties: false
|
|
663
|
+
};
|
|
664
|
+
var outputSchema3 = {
|
|
665
|
+
type: "object",
|
|
666
|
+
properties: {
|
|
667
|
+
result: {
|
|
668
|
+
type: "number",
|
|
669
|
+
title: "Result",
|
|
670
|
+
description: "Sum of a and b"
|
|
671
|
+
}
|
|
672
|
+
},
|
|
673
|
+
required: ["result"],
|
|
674
|
+
additionalProperties: false
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
class ScalarAddTask extends Task2 {
|
|
678
|
+
static type = "ScalarAddTask";
|
|
679
|
+
static category = "Math";
|
|
680
|
+
static title = "Add";
|
|
681
|
+
static description = "Returns the sum of two numbers";
|
|
682
|
+
static inputSchema() {
|
|
683
|
+
return inputSchema3;
|
|
684
|
+
}
|
|
685
|
+
static outputSchema() {
|
|
686
|
+
return outputSchema3;
|
|
687
|
+
}
|
|
688
|
+
async execute(input, _context) {
|
|
689
|
+
return { result: sumPrecise([input.a, input.b]) };
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
Workflow3.prototype.scalarAdd = CreateWorkflow3(ScalarAddTask);
|
|
693
|
+
|
|
694
|
+
// src/task/scalar/ScalarDivideTask.ts
|
|
695
|
+
import { CreateWorkflow as CreateWorkflow4, Task as Task3, Workflow as Workflow4 } from "@workglow/task-graph";
|
|
696
|
+
var inputSchema4 = {
|
|
697
|
+
type: "object",
|
|
698
|
+
properties: {
|
|
699
|
+
a: {
|
|
700
|
+
type: "number",
|
|
701
|
+
title: "A",
|
|
702
|
+
description: "Numerator"
|
|
703
|
+
},
|
|
704
|
+
b: {
|
|
705
|
+
type: "number",
|
|
706
|
+
title: "B",
|
|
707
|
+
description: "Denominator"
|
|
708
|
+
}
|
|
709
|
+
},
|
|
710
|
+
required: ["a", "b"],
|
|
711
|
+
additionalProperties: false
|
|
712
|
+
};
|
|
713
|
+
var outputSchema4 = {
|
|
714
|
+
type: "object",
|
|
715
|
+
properties: {
|
|
716
|
+
result: {
|
|
717
|
+
type: "number",
|
|
718
|
+
title: "Result",
|
|
719
|
+
description: "Quotient (a / b)"
|
|
720
|
+
}
|
|
721
|
+
},
|
|
722
|
+
required: ["result"],
|
|
723
|
+
additionalProperties: false
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
class ScalarDivideTask extends Task3 {
|
|
727
|
+
static type = "ScalarDivideTask";
|
|
728
|
+
static category = "Math";
|
|
729
|
+
static title = "Divide";
|
|
730
|
+
static description = "Returns the quotient of two numbers (a / b)";
|
|
731
|
+
static inputSchema() {
|
|
732
|
+
return inputSchema4;
|
|
733
|
+
}
|
|
734
|
+
static outputSchema() {
|
|
735
|
+
return outputSchema4;
|
|
736
|
+
}
|
|
737
|
+
async execute(input, _context) {
|
|
738
|
+
return { result: input.a / input.b };
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
Workflow4.prototype.scalarDivide = CreateWorkflow4(ScalarDivideTask);
|
|
742
|
+
|
|
743
|
+
// src/task/scalar/ScalarMultiplyTask.ts
|
|
744
|
+
import { CreateWorkflow as CreateWorkflow5, Task as Task4, Workflow as Workflow5 } from "@workglow/task-graph";
|
|
745
|
+
var inputSchema5 = {
|
|
746
|
+
type: "object",
|
|
747
|
+
properties: {
|
|
748
|
+
a: {
|
|
749
|
+
type: "number",
|
|
750
|
+
title: "A",
|
|
751
|
+
description: "First number"
|
|
752
|
+
},
|
|
753
|
+
b: {
|
|
754
|
+
type: "number",
|
|
755
|
+
title: "B",
|
|
756
|
+
description: "Second number"
|
|
757
|
+
}
|
|
758
|
+
},
|
|
759
|
+
required: ["a", "b"],
|
|
760
|
+
additionalProperties: false
|
|
761
|
+
};
|
|
762
|
+
var outputSchema5 = {
|
|
763
|
+
type: "object",
|
|
764
|
+
properties: {
|
|
765
|
+
result: {
|
|
766
|
+
type: "number",
|
|
767
|
+
title: "Result",
|
|
768
|
+
description: "Product of a and b"
|
|
769
|
+
}
|
|
770
|
+
},
|
|
771
|
+
required: ["result"],
|
|
772
|
+
additionalProperties: false
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
class ScalarMultiplyTask extends Task4 {
|
|
776
|
+
static type = "ScalarMultiplyTask";
|
|
777
|
+
static category = "Math";
|
|
778
|
+
static title = "Multiply";
|
|
779
|
+
static description = "Returns the product of two numbers";
|
|
780
|
+
static inputSchema() {
|
|
781
|
+
return inputSchema5;
|
|
782
|
+
}
|
|
783
|
+
static outputSchema() {
|
|
784
|
+
return outputSchema5;
|
|
785
|
+
}
|
|
786
|
+
async execute(input, _context) {
|
|
787
|
+
return { result: input.a * input.b };
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
Workflow5.prototype.scalarMultiply = CreateWorkflow5(ScalarMultiplyTask);
|
|
791
|
+
|
|
792
|
+
// src/task/scalar/ScalarSubtractTask.ts
|
|
793
|
+
import { CreateWorkflow as CreateWorkflow6, Task as Task5, Workflow as Workflow6 } from "@workglow/task-graph";
|
|
794
|
+
var inputSchema6 = {
|
|
795
|
+
type: "object",
|
|
796
|
+
properties: {
|
|
797
|
+
a: {
|
|
798
|
+
type: "number",
|
|
799
|
+
title: "A",
|
|
800
|
+
description: "First number"
|
|
801
|
+
},
|
|
802
|
+
b: {
|
|
803
|
+
type: "number",
|
|
804
|
+
title: "B",
|
|
805
|
+
description: "Second number"
|
|
806
|
+
}
|
|
807
|
+
},
|
|
808
|
+
required: ["a", "b"],
|
|
809
|
+
additionalProperties: false
|
|
810
|
+
};
|
|
811
|
+
var outputSchema6 = {
|
|
812
|
+
type: "object",
|
|
813
|
+
properties: {
|
|
814
|
+
result: {
|
|
815
|
+
type: "number",
|
|
816
|
+
title: "Result",
|
|
817
|
+
description: "Difference (a - b)"
|
|
818
|
+
}
|
|
819
|
+
},
|
|
820
|
+
required: ["result"],
|
|
821
|
+
additionalProperties: false
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
class ScalarSubtractTask extends Task5 {
|
|
825
|
+
static type = "ScalarSubtractTask";
|
|
826
|
+
static category = "Math";
|
|
827
|
+
static title = "Subtract";
|
|
828
|
+
static description = "Returns the difference of two numbers (a - b)";
|
|
829
|
+
static inputSchema() {
|
|
830
|
+
return inputSchema6;
|
|
831
|
+
}
|
|
832
|
+
static outputSchema() {
|
|
833
|
+
return outputSchema6;
|
|
834
|
+
}
|
|
835
|
+
async execute(input, _context) {
|
|
836
|
+
return { result: input.a - input.b };
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
Workflow6.prototype.scalarSubtract = CreateWorkflow6(ScalarSubtractTask);
|
|
840
|
+
|
|
841
|
+
// src/task/scalar/ScalarSumTask.ts
|
|
842
|
+
import { CreateWorkflow as CreateWorkflow7, Task as Task6, Workflow as Workflow7 } from "@workglow/task-graph";
|
|
843
|
+
var inputSchema7 = {
|
|
844
|
+
type: "object",
|
|
845
|
+
properties: {
|
|
846
|
+
values: {
|
|
847
|
+
type: "array",
|
|
848
|
+
items: { type: "number" },
|
|
849
|
+
title: "Values",
|
|
850
|
+
description: "Array of numbers to sum"
|
|
851
|
+
}
|
|
852
|
+
},
|
|
853
|
+
required: ["values"],
|
|
854
|
+
additionalProperties: false
|
|
855
|
+
};
|
|
856
|
+
var outputSchema7 = {
|
|
857
|
+
type: "object",
|
|
858
|
+
properties: {
|
|
859
|
+
result: {
|
|
860
|
+
type: "number",
|
|
861
|
+
title: "Result",
|
|
862
|
+
description: "Sum of all values"
|
|
863
|
+
}
|
|
864
|
+
},
|
|
865
|
+
required: ["result"],
|
|
866
|
+
additionalProperties: false
|
|
867
|
+
};
|
|
868
|
+
|
|
869
|
+
class ScalarSumTask extends Task6 {
|
|
870
|
+
static type = "ScalarSumTask";
|
|
871
|
+
static category = "Math";
|
|
872
|
+
static title = "Sum";
|
|
873
|
+
static description = "Returns the sum of an array of numbers";
|
|
874
|
+
static inputSchema() {
|
|
875
|
+
return inputSchema7;
|
|
876
|
+
}
|
|
877
|
+
static outputSchema() {
|
|
878
|
+
return outputSchema7;
|
|
879
|
+
}
|
|
880
|
+
async execute(input, _context) {
|
|
881
|
+
return { result: sumPrecise(input.values) };
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
Workflow7.prototype.scalarSum = CreateWorkflow7(ScalarSumTask);
|
|
885
|
+
|
|
886
|
+
// src/task/vector/VectorDivideTask.ts
|
|
887
|
+
import { CreateWorkflow as CreateWorkflow8, Task as Task7, Workflow as Workflow8 } from "@workglow/task-graph";
|
|
888
|
+
import {
|
|
889
|
+
createTypedArrayFrom,
|
|
890
|
+
TypedArraySchema
|
|
891
|
+
} from "@workglow/util";
|
|
892
|
+
var inputSchema8 = {
|
|
893
|
+
type: "object",
|
|
894
|
+
properties: {
|
|
895
|
+
vectors: {
|
|
896
|
+
type: "array",
|
|
897
|
+
items: TypedArraySchema({
|
|
898
|
+
title: "Vector",
|
|
899
|
+
description: "Vector (first is numerator, rest are denominators)"
|
|
900
|
+
}),
|
|
901
|
+
title: "Vectors",
|
|
902
|
+
description: "Array of vectors: vectors[0] / vectors[1] / vectors[2] / ..."
|
|
903
|
+
}
|
|
904
|
+
},
|
|
905
|
+
required: ["vectors"],
|
|
906
|
+
additionalProperties: false
|
|
907
|
+
};
|
|
908
|
+
var outputSchema8 = {
|
|
909
|
+
type: "object",
|
|
910
|
+
properties: {
|
|
911
|
+
result: TypedArraySchema({
|
|
912
|
+
title: "Result",
|
|
913
|
+
description: "Component-wise quotient"
|
|
914
|
+
})
|
|
915
|
+
},
|
|
916
|
+
required: ["result"],
|
|
917
|
+
additionalProperties: false
|
|
918
|
+
};
|
|
919
|
+
|
|
920
|
+
class VectorDivideTask extends Task7 {
|
|
921
|
+
static type = "VectorDivideTask";
|
|
922
|
+
static category = "Vector";
|
|
923
|
+
static title = "Divide";
|
|
924
|
+
static description = "Returns component-wise quotient: vectors[0] / vectors[1] / vectors[2] / ...";
|
|
925
|
+
static inputSchema() {
|
|
926
|
+
return inputSchema8;
|
|
927
|
+
}
|
|
928
|
+
static outputSchema() {
|
|
929
|
+
return outputSchema8;
|
|
930
|
+
}
|
|
931
|
+
async execute(input, _context) {
|
|
932
|
+
const { vectors } = input;
|
|
933
|
+
if (vectors.length < 2) {
|
|
934
|
+
throw new Error("At least two vectors are required");
|
|
935
|
+
}
|
|
936
|
+
const len = vectors[0].length;
|
|
937
|
+
for (let i = 1;i < vectors.length; i++) {
|
|
938
|
+
if (vectors[i].length !== len) {
|
|
939
|
+
throw new Error("All vectors must have the same length");
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
const values = Array.from({ length: len }, (_, i) => {
|
|
943
|
+
let acc = Number(vectors[0][i]);
|
|
944
|
+
for (let j = 1;j < vectors.length; j++) {
|
|
945
|
+
acc /= Number(vectors[j][i]);
|
|
946
|
+
}
|
|
947
|
+
return acc;
|
|
948
|
+
});
|
|
949
|
+
return { result: createTypedArrayFrom(vectors, values) };
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
Workflow8.prototype.vectorDivide = CreateWorkflow8(VectorDivideTask);
|
|
953
|
+
|
|
954
|
+
// src/task/vector/VectorMultiplyTask.ts
|
|
955
|
+
import { CreateWorkflow as CreateWorkflow9, Task as Task8, Workflow as Workflow9 } from "@workglow/task-graph";
|
|
956
|
+
import {
|
|
957
|
+
createTypedArrayFrom as createTypedArrayFrom2,
|
|
958
|
+
TypedArraySchema as TypedArraySchema2
|
|
959
|
+
} from "@workglow/util";
|
|
960
|
+
var inputSchema9 = {
|
|
961
|
+
type: "object",
|
|
962
|
+
properties: {
|
|
963
|
+
vectors: {
|
|
964
|
+
type: "array",
|
|
965
|
+
items: TypedArraySchema2({
|
|
966
|
+
title: "Vector",
|
|
967
|
+
description: "Vector for component-wise product"
|
|
968
|
+
}),
|
|
969
|
+
title: "Vectors",
|
|
970
|
+
description: "Array of vectors to multiply component-wise"
|
|
971
|
+
}
|
|
972
|
+
},
|
|
973
|
+
required: ["vectors"],
|
|
974
|
+
additionalProperties: false
|
|
975
|
+
};
|
|
976
|
+
var outputSchema9 = {
|
|
977
|
+
type: "object",
|
|
978
|
+
properties: {
|
|
979
|
+
result: TypedArraySchema2({
|
|
980
|
+
title: "Result",
|
|
981
|
+
description: "Component-wise product (Hadamard product)"
|
|
982
|
+
})
|
|
983
|
+
},
|
|
984
|
+
required: ["result"],
|
|
985
|
+
additionalProperties: false
|
|
986
|
+
};
|
|
987
|
+
|
|
988
|
+
class VectorMultiplyTask extends Task8 {
|
|
989
|
+
static type = "VectorMultiplyTask";
|
|
990
|
+
static category = "Vector";
|
|
991
|
+
static title = "Multiply";
|
|
992
|
+
static description = "Returns the component-wise product (Hadamard product) of all vectors";
|
|
993
|
+
static inputSchema() {
|
|
994
|
+
return inputSchema9;
|
|
995
|
+
}
|
|
996
|
+
static outputSchema() {
|
|
997
|
+
return outputSchema9;
|
|
998
|
+
}
|
|
999
|
+
async execute(input, _context) {
|
|
1000
|
+
const { vectors } = input;
|
|
1001
|
+
if (vectors.length === 0) {
|
|
1002
|
+
throw new Error("At least one vector is required");
|
|
1003
|
+
}
|
|
1004
|
+
const len = vectors[0].length;
|
|
1005
|
+
for (let i = 1;i < vectors.length; i++) {
|
|
1006
|
+
if (vectors[i].length !== len) {
|
|
1007
|
+
throw new Error("All vectors must have the same length");
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
const values = Array.from({ length: len }, (_, i) => vectors.reduce((acc, v) => acc * Number(v[i]), 1));
|
|
1011
|
+
return { result: createTypedArrayFrom2(vectors, values) };
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
Workflow9.prototype.vectorMultiply = CreateWorkflow9(VectorMultiplyTask);
|
|
1015
|
+
|
|
1016
|
+
// src/task/vector/VectorSubtractTask.ts
|
|
1017
|
+
import { CreateWorkflow as CreateWorkflow10, Task as Task9, Workflow as Workflow10 } from "@workglow/task-graph";
|
|
1018
|
+
import {
|
|
1019
|
+
createTypedArrayFrom as createTypedArrayFrom3,
|
|
1020
|
+
TypedArraySchema as TypedArraySchema3
|
|
1021
|
+
} from "@workglow/util";
|
|
1022
|
+
var inputSchema10 = {
|
|
1023
|
+
type: "object",
|
|
1024
|
+
properties: {
|
|
1025
|
+
vectors: {
|
|
1026
|
+
type: "array",
|
|
1027
|
+
items: TypedArraySchema3({
|
|
1028
|
+
title: "Vector",
|
|
1029
|
+
description: "Vector (first is minuend, rest are subtrahends)"
|
|
1030
|
+
}),
|
|
1031
|
+
title: "Vectors",
|
|
1032
|
+
description: "Array of vectors: vectors[0] - vectors[1] - vectors[2] - ..."
|
|
1033
|
+
}
|
|
1034
|
+
},
|
|
1035
|
+
required: ["vectors"],
|
|
1036
|
+
additionalProperties: false
|
|
1037
|
+
};
|
|
1038
|
+
var outputSchema10 = {
|
|
1039
|
+
type: "object",
|
|
1040
|
+
properties: {
|
|
1041
|
+
result: TypedArraySchema3({
|
|
1042
|
+
title: "Result",
|
|
1043
|
+
description: "Difference of vectors"
|
|
1044
|
+
})
|
|
1045
|
+
},
|
|
1046
|
+
required: ["result"],
|
|
1047
|
+
additionalProperties: false
|
|
1048
|
+
};
|
|
1049
|
+
|
|
1050
|
+
class VectorSubtractTask extends Task9 {
|
|
1051
|
+
static type = "VectorSubtractTask";
|
|
1052
|
+
static category = "Vector";
|
|
1053
|
+
static title = "Subtract";
|
|
1054
|
+
static description = "Returns component-wise difference: vectors[0] - vectors[1] - vectors[2] - ...";
|
|
1055
|
+
static inputSchema() {
|
|
1056
|
+
return inputSchema10;
|
|
1057
|
+
}
|
|
1058
|
+
static outputSchema() {
|
|
1059
|
+
return outputSchema10;
|
|
1060
|
+
}
|
|
1061
|
+
async execute(input, _context) {
|
|
1062
|
+
const { vectors } = input;
|
|
1063
|
+
if (vectors.length < 2) {
|
|
1064
|
+
throw new Error("At least two vectors are required");
|
|
1065
|
+
}
|
|
1066
|
+
const len = vectors[0].length;
|
|
1067
|
+
for (let i = 1;i < vectors.length; i++) {
|
|
1068
|
+
if (vectors[i].length !== len) {
|
|
1069
|
+
throw new Error("All vectors must have the same length");
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
const values = Array.from({ length: len }, (_, i) => {
|
|
1073
|
+
let acc = Number(vectors[0][i]);
|
|
1074
|
+
for (let j = 1;j < vectors.length; j++) {
|
|
1075
|
+
acc -= Number(vectors[j][i]);
|
|
1076
|
+
}
|
|
1077
|
+
return acc;
|
|
1078
|
+
});
|
|
1079
|
+
return { result: createTypedArrayFrom3(vectors, values) };
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
Workflow10.prototype.vectorSubtract = CreateWorkflow10(VectorSubtractTask);
|
|
1083
|
+
|
|
1084
|
+
// src/task/vector/VectorSumTask.ts
|
|
1085
|
+
import { CreateWorkflow as CreateWorkflow11, Task as Task10, Workflow as Workflow11 } from "@workglow/task-graph";
|
|
1086
|
+
import {
|
|
1087
|
+
createTypedArrayFrom as createTypedArrayFrom4,
|
|
1088
|
+
TypedArraySchema as TypedArraySchema4
|
|
1089
|
+
} from "@workglow/util";
|
|
1090
|
+
var inputSchema11 = {
|
|
1091
|
+
type: "object",
|
|
1092
|
+
properties: {
|
|
1093
|
+
vectors: {
|
|
1094
|
+
type: "array",
|
|
1095
|
+
items: TypedArraySchema4({
|
|
1096
|
+
title: "Vector",
|
|
1097
|
+
description: "Vector to sum"
|
|
1098
|
+
}),
|
|
1099
|
+
title: "Vectors",
|
|
1100
|
+
description: "Array of vectors to sum component-wise"
|
|
1101
|
+
}
|
|
1102
|
+
},
|
|
1103
|
+
required: ["vectors"],
|
|
1104
|
+
additionalProperties: false
|
|
1105
|
+
};
|
|
1106
|
+
var outputSchema11 = {
|
|
1107
|
+
type: "object",
|
|
1108
|
+
properties: {
|
|
1109
|
+
result: TypedArraySchema4({
|
|
1110
|
+
title: "Result",
|
|
1111
|
+
description: "Sum of vectors"
|
|
1112
|
+
})
|
|
1113
|
+
},
|
|
1114
|
+
required: ["result"],
|
|
1115
|
+
additionalProperties: false
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
class VectorSumTask extends Task10 {
|
|
1119
|
+
static type = "VectorSumTask";
|
|
1120
|
+
static category = "Vector";
|
|
1121
|
+
static title = "Sum";
|
|
1122
|
+
static description = "Returns the component-wise sum of an array of vectors";
|
|
1123
|
+
static inputSchema() {
|
|
1124
|
+
return inputSchema11;
|
|
1125
|
+
}
|
|
1126
|
+
static outputSchema() {
|
|
1127
|
+
return outputSchema11;
|
|
1128
|
+
}
|
|
1129
|
+
async execute(input, _context) {
|
|
1130
|
+
const { vectors } = input;
|
|
1131
|
+
if (vectors.length === 0) {
|
|
1132
|
+
throw new Error("At least one vector is required");
|
|
1133
|
+
}
|
|
1134
|
+
const len = vectors[0].length;
|
|
1135
|
+
for (let i = 1;i < vectors.length; i++) {
|
|
1136
|
+
if (vectors[i].length !== len) {
|
|
1137
|
+
throw new Error("All vectors must have the same length");
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
const values = Array.from({ length: len }, (_, i) => sumPrecise(vectors.map((v) => Number(v[i]))));
|
|
1141
|
+
return { result: createTypedArrayFrom4(vectors, values) };
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
Workflow11.prototype.vectorSum = CreateWorkflow11(VectorSumTask);
|
|
1145
|
+
|
|
1146
|
+
// src/task/adaptive.ts
|
|
1147
|
+
Workflow12.prototype.add = CreateAdaptiveWorkflow(ScalarAddTask, VectorSumTask);
|
|
1148
|
+
Workflow12.prototype.subtract = CreateAdaptiveWorkflow(ScalarSubtractTask, VectorSubtractTask);
|
|
1149
|
+
Workflow12.prototype.multiply = CreateAdaptiveWorkflow(ScalarMultiplyTask, VectorMultiplyTask);
|
|
1150
|
+
Workflow12.prototype.divide = CreateAdaptiveWorkflow(ScalarDivideTask, VectorDivideTask);
|
|
1151
|
+
Workflow12.prototype.sum = CreateAdaptiveWorkflow(ScalarSumTask, VectorSumTask);
|
|
1152
|
+
|
|
625
1153
|
// src/task/ArrayTask.ts
|
|
626
1154
|
import {
|
|
627
1155
|
uuid4
|
|
@@ -656,12 +1184,12 @@ class ArrayTask extends GraphAsTask {
|
|
|
656
1184
|
regenerateGraph() {
|
|
657
1185
|
const arrayInputs = new Map;
|
|
658
1186
|
let hasArrayInputs = false;
|
|
659
|
-
const
|
|
660
|
-
if (typeof
|
|
661
|
-
const keys = Object.keys(
|
|
1187
|
+
const inputSchema12 = this.inputSchema();
|
|
1188
|
+
if (typeof inputSchema12 !== "boolean") {
|
|
1189
|
+
const keys = Object.keys(inputSchema12.properties || {});
|
|
662
1190
|
for (const inputId of keys) {
|
|
663
1191
|
const inputValue = this.runInputData[inputId];
|
|
664
|
-
const inputDef =
|
|
1192
|
+
const inputDef = inputSchema12.properties?.[inputId];
|
|
665
1193
|
if (typeof inputDef === "object" && inputDef !== null && "x-replicate" in inputDef && inputDef["x-replicate"] === true && Array.isArray(inputValue) && inputValue.length > 1) {
|
|
666
1194
|
arrayInputs.set(inputId, inputValue);
|
|
667
1195
|
hasArrayInputs = true;
|
|
@@ -750,10 +1278,10 @@ class ArrayTaskRunner extends GraphAsTaskRunner {
|
|
|
750
1278
|
}
|
|
751
1279
|
}
|
|
752
1280
|
// src/task/DebugLogTask.ts
|
|
753
|
-
import { CreateWorkflow as
|
|
1281
|
+
import { CreateWorkflow as CreateWorkflow12, Task as Task11, Workflow as Workflow13 } from "@workglow/task-graph";
|
|
754
1282
|
var log_levels = ["dir", "log", "debug", "info", "warn", "error"];
|
|
755
1283
|
var DEFAULT_LOG_LEVEL = "log";
|
|
756
|
-
var
|
|
1284
|
+
var inputSchema12 = {
|
|
757
1285
|
type: "object",
|
|
758
1286
|
properties: {
|
|
759
1287
|
console: {
|
|
@@ -770,7 +1298,7 @@ var inputSchema3 = {
|
|
|
770
1298
|
},
|
|
771
1299
|
additionalProperties: false
|
|
772
1300
|
};
|
|
773
|
-
var
|
|
1301
|
+
var outputSchema12 = {
|
|
774
1302
|
type: "object",
|
|
775
1303
|
properties: {
|
|
776
1304
|
console: {
|
|
@@ -781,17 +1309,17 @@ var outputSchema3 = {
|
|
|
781
1309
|
additionalProperties: false
|
|
782
1310
|
};
|
|
783
1311
|
|
|
784
|
-
class DebugLogTask extends
|
|
1312
|
+
class DebugLogTask extends Task11 {
|
|
785
1313
|
static type = "DebugLogTask";
|
|
786
1314
|
static category = "Utility";
|
|
787
1315
|
static title = "Debug Log";
|
|
788
1316
|
static description = "Logs messages to the console with configurable log levels for debugging task graphs";
|
|
789
1317
|
static cacheable = false;
|
|
790
1318
|
static inputSchema() {
|
|
791
|
-
return
|
|
1319
|
+
return inputSchema12;
|
|
792
1320
|
}
|
|
793
1321
|
static outputSchema() {
|
|
794
|
-
return
|
|
1322
|
+
return outputSchema12;
|
|
795
1323
|
}
|
|
796
1324
|
async executeReactive(input, output) {
|
|
797
1325
|
const { log_level = DEFAULT_LOG_LEVEL, console: messages } = input;
|
|
@@ -808,16 +1336,16 @@ var debugLog = (input, config = {}) => {
|
|
|
808
1336
|
const task = new DebugLogTask({}, config);
|
|
809
1337
|
return task.run(input);
|
|
810
1338
|
};
|
|
811
|
-
|
|
1339
|
+
Workflow13.prototype.debugLog = CreateWorkflow12(DebugLogTask);
|
|
812
1340
|
// src/task/DelayTask.ts
|
|
813
1341
|
import {
|
|
814
|
-
CreateWorkflow as
|
|
815
|
-
Task as
|
|
1342
|
+
CreateWorkflow as CreateWorkflow13,
|
|
1343
|
+
Task as Task12,
|
|
816
1344
|
TaskAbortedError as TaskAbortedError2,
|
|
817
|
-
Workflow as
|
|
1345
|
+
Workflow as Workflow14
|
|
818
1346
|
} from "@workglow/task-graph";
|
|
819
1347
|
import { sleep } from "@workglow/util";
|
|
820
|
-
var
|
|
1348
|
+
var inputSchema13 = {
|
|
821
1349
|
type: "object",
|
|
822
1350
|
properties: {
|
|
823
1351
|
delay: {
|
|
@@ -832,22 +1360,22 @@ var inputSchema4 = {
|
|
|
832
1360
|
},
|
|
833
1361
|
additionalProperties: false
|
|
834
1362
|
};
|
|
835
|
-
var
|
|
1363
|
+
var outputSchema13 = {
|
|
836
1364
|
type: "object",
|
|
837
1365
|
properties: {},
|
|
838
1366
|
additionalProperties: true
|
|
839
1367
|
};
|
|
840
1368
|
|
|
841
|
-
class DelayTask extends
|
|
1369
|
+
class DelayTask extends Task12 {
|
|
842
1370
|
static type = "DelayTask";
|
|
843
1371
|
static category = "Utility";
|
|
844
1372
|
static title = "Delay";
|
|
845
1373
|
static description = "Delays execution for a specified duration with progress tracking";
|
|
846
1374
|
static inputSchema() {
|
|
847
|
-
return
|
|
1375
|
+
return inputSchema13;
|
|
848
1376
|
}
|
|
849
1377
|
static outputSchema() {
|
|
850
|
-
return
|
|
1378
|
+
return outputSchema13;
|
|
851
1379
|
}
|
|
852
1380
|
async execute(input, executeContext) {
|
|
853
1381
|
const delay = input.delay ?? 0;
|
|
@@ -871,11 +1399,11 @@ var delay = (input, config = {}) => {
|
|
|
871
1399
|
const task = new DelayTask({}, config);
|
|
872
1400
|
return task.run(input);
|
|
873
1401
|
};
|
|
874
|
-
|
|
1402
|
+
Workflow14.prototype.delay = CreateWorkflow13(DelayTask);
|
|
875
1403
|
// src/task/InputTask.ts
|
|
876
|
-
import { CreateWorkflow as
|
|
1404
|
+
import { CreateWorkflow as CreateWorkflow14, Task as Task13, Workflow as Workflow15 } from "@workglow/task-graph";
|
|
877
1405
|
|
|
878
|
-
class InputTask extends
|
|
1406
|
+
class InputTask extends Task13 {
|
|
879
1407
|
static type = "InputTask";
|
|
880
1408
|
static category = "Flow Control";
|
|
881
1409
|
static title = "Input";
|
|
@@ -909,9 +1437,9 @@ class InputTask extends Task4 {
|
|
|
909
1437
|
return input;
|
|
910
1438
|
}
|
|
911
1439
|
}
|
|
912
|
-
|
|
1440
|
+
Workflow15.prototype.input = CreateWorkflow14(InputTask);
|
|
913
1441
|
// src/task/JavaScriptTask.ts
|
|
914
|
-
import { CreateWorkflow as
|
|
1442
|
+
import { CreateWorkflow as CreateWorkflow15, Task as Task14, Workflow as Workflow16 } from "@workglow/task-graph";
|
|
915
1443
|
|
|
916
1444
|
// src/util/acorn.js
|
|
917
1445
|
var options;
|
|
@@ -2660,7 +3188,7 @@ Interpreter.prototype.initGlobal = function(globalObject) {
|
|
|
2660
3188
|
}(strFunctions[i][0]);
|
|
2661
3189
|
this.setProperty(globalObject, strFunctions[i][1], this.createNativeFunction(wrapper, false), Interpreter.NONENUMERABLE_DESCRIPTOR);
|
|
2662
3190
|
}
|
|
2663
|
-
wrapper = function
|
|
3191
|
+
wrapper = function setTimeout2(var_args) {
|
|
2664
3192
|
return thisInterpreter.createTask_(false, arguments);
|
|
2665
3193
|
};
|
|
2666
3194
|
this.setProperty(globalObject, "setTimeout", this.createNativeFunction(wrapper, false), Interpreter.NONENUMERABLE_DESCRIPTOR);
|
|
@@ -2668,7 +3196,7 @@ Interpreter.prototype.initGlobal = function(globalObject) {
|
|
|
2668
3196
|
return thisInterpreter.createTask_(true, arguments);
|
|
2669
3197
|
};
|
|
2670
3198
|
this.setProperty(globalObject, "setInterval", this.createNativeFunction(wrapper, false), Interpreter.NONENUMERABLE_DESCRIPTOR);
|
|
2671
|
-
wrapper = function
|
|
3199
|
+
wrapper = function clearTimeout2(pid) {
|
|
2672
3200
|
thisInterpreter.deleteTask_(pid);
|
|
2673
3201
|
};
|
|
2674
3202
|
this.setProperty(globalObject, "clearTimeout", this.createNativeFunction(wrapper, false), Interpreter.NONENUMERABLE_DESCRIPTOR);
|
|
@@ -2695,7 +3223,7 @@ Interpreter.prototype.initFunction = function(globalObject) {
|
|
|
2695
3223
|
var thisInterpreter = this;
|
|
2696
3224
|
var wrapper;
|
|
2697
3225
|
var identifierRegexp = /^[A-Za-z_$][\w$]*$/;
|
|
2698
|
-
wrapper = function
|
|
3226
|
+
wrapper = function Function2(var_args) {
|
|
2699
3227
|
if (arguments.length) {
|
|
2700
3228
|
var code = String(arguments[arguments.length - 1]);
|
|
2701
3229
|
} else {
|
|
@@ -2773,7 +3301,7 @@ Interpreter.prototype.initFunction = function(globalObject) {
|
|
|
2773
3301
|
Interpreter.prototype.initObject = function(globalObject) {
|
|
2774
3302
|
var thisInterpreter = this;
|
|
2775
3303
|
var wrapper;
|
|
2776
|
-
wrapper = function
|
|
3304
|
+
wrapper = function Object2(value) {
|
|
2777
3305
|
if (value === undefined || value === null) {
|
|
2778
3306
|
if (thisInterpreter.calledWithNew()) {
|
|
2779
3307
|
return this;
|
|
@@ -2913,7 +3441,7 @@ Interpreter.prototype.initObject = function(globalObject) {
|
|
|
2913
3441
|
Interpreter.prototype.initArray = function(globalObject) {
|
|
2914
3442
|
var thisInterpreter = this;
|
|
2915
3443
|
var wrapper;
|
|
2916
|
-
wrapper = function
|
|
3444
|
+
wrapper = function Array2(var_args) {
|
|
2917
3445
|
if (thisInterpreter.calledWithNew()) {
|
|
2918
3446
|
var newArray = this;
|
|
2919
3447
|
} else {
|
|
@@ -2951,7 +3479,7 @@ Interpreter.prototype.initArray = function(globalObject) {
|
|
|
2951
3479
|
Interpreter.prototype.initString = function(globalObject) {
|
|
2952
3480
|
var thisInterpreter = this;
|
|
2953
3481
|
var wrapper;
|
|
2954
|
-
wrapper = function
|
|
3482
|
+
wrapper = function String2(value) {
|
|
2955
3483
|
value = arguments.length ? Interpreter.nativeGlobal.String(value) : "";
|
|
2956
3484
|
if (thisInterpreter.calledWithNew()) {
|
|
2957
3485
|
this.data = value;
|
|
@@ -3126,7 +3654,7 @@ Interpreter.prototype.initString = function(globalObject) {
|
|
|
3126
3654
|
Interpreter.prototype.initBoolean = function(globalObject) {
|
|
3127
3655
|
var thisInterpreter = this;
|
|
3128
3656
|
var wrapper;
|
|
3129
|
-
wrapper = function
|
|
3657
|
+
wrapper = function Boolean2(value) {
|
|
3130
3658
|
value = Interpreter.nativeGlobal.Boolean(value);
|
|
3131
3659
|
if (thisInterpreter.calledWithNew()) {
|
|
3132
3660
|
this.data = value;
|
|
@@ -3141,7 +3669,7 @@ Interpreter.prototype.initBoolean = function(globalObject) {
|
|
|
3141
3669
|
Interpreter.prototype.initNumber = function(globalObject) {
|
|
3142
3670
|
var thisInterpreter = this;
|
|
3143
3671
|
var wrapper;
|
|
3144
|
-
wrapper = function
|
|
3672
|
+
wrapper = function Number2(value) {
|
|
3145
3673
|
value = arguments.length ? Interpreter.nativeGlobal.Number(value) : 0;
|
|
3146
3674
|
if (thisInterpreter.calledWithNew()) {
|
|
3147
3675
|
this.data = value;
|
|
@@ -3202,7 +3730,7 @@ Interpreter.prototype.initNumber = function(globalObject) {
|
|
|
3202
3730
|
Interpreter.prototype.initDate = function(globalObject) {
|
|
3203
3731
|
var thisInterpreter = this;
|
|
3204
3732
|
var wrapper;
|
|
3205
|
-
wrapper = function
|
|
3733
|
+
wrapper = function Date2(_value, var_args) {
|
|
3206
3734
|
if (!thisInterpreter.calledWithNew()) {
|
|
3207
3735
|
return Interpreter.nativeGlobal.Date();
|
|
3208
3736
|
}
|
|
@@ -3282,7 +3810,7 @@ Interpreter.prototype.initDate = function(globalObject) {
|
|
|
3282
3810
|
Interpreter.prototype.initRegExp = function(globalObject) {
|
|
3283
3811
|
var thisInterpreter = this;
|
|
3284
3812
|
var wrapper;
|
|
3285
|
-
wrapper = function
|
|
3813
|
+
wrapper = function RegExp2(pattern, flags) {
|
|
3286
3814
|
if (thisInterpreter.calledWithNew()) {
|
|
3287
3815
|
var rgx = this;
|
|
3288
3816
|
} else {
|
|
@@ -3359,7 +3887,7 @@ Interpreter.prototype.initRegExp = function(globalObject) {
|
|
|
3359
3887
|
};
|
|
3360
3888
|
Interpreter.prototype.initError = function(globalObject) {
|
|
3361
3889
|
var thisInterpreter = this;
|
|
3362
|
-
this.ERROR = this.createNativeFunction(function
|
|
3890
|
+
this.ERROR = this.createNativeFunction(function Error2(opt_message) {
|
|
3363
3891
|
if (thisInterpreter.calledWithNew()) {
|
|
3364
3892
|
var newError = this;
|
|
3365
3893
|
} else {
|
|
@@ -3429,7 +3957,7 @@ Interpreter.prototype.initJSON = function(globalObject) {
|
|
|
3429
3957
|
var thisInterpreter = this;
|
|
3430
3958
|
var myJSON = thisInterpreter.createObjectProto(this.OBJECT_PROTO);
|
|
3431
3959
|
this.setProperty(globalObject, "JSON", myJSON, Interpreter.NONENUMERABLE_DESCRIPTOR);
|
|
3432
|
-
wrapper = function
|
|
3960
|
+
wrapper = function parse2(text) {
|
|
3433
3961
|
try {
|
|
3434
3962
|
var nativeObj = JSON.parse(String(text));
|
|
3435
3963
|
} catch (e) {
|
|
@@ -5374,7 +5902,7 @@ Interpreter["VALUE_IN_DESCRIPTOR"] = Interpreter.VALUE_IN_DESCRIPTOR;
|
|
|
5374
5902
|
Interpreter["Status"] = Interpreter.Status;
|
|
5375
5903
|
|
|
5376
5904
|
// src/task/JavaScriptTask.ts
|
|
5377
|
-
var
|
|
5905
|
+
var inputSchema14 = {
|
|
5378
5906
|
type: "object",
|
|
5379
5907
|
properties: {
|
|
5380
5908
|
javascript_code: {
|
|
@@ -5388,7 +5916,7 @@ var inputSchema5 = {
|
|
|
5388
5916
|
required: ["javascript_code"],
|
|
5389
5917
|
additionalProperties: true
|
|
5390
5918
|
};
|
|
5391
|
-
var
|
|
5919
|
+
var outputSchema14 = {
|
|
5392
5920
|
type: "object",
|
|
5393
5921
|
properties: {
|
|
5394
5922
|
output: {
|
|
@@ -5400,16 +5928,16 @@ var outputSchema5 = {
|
|
|
5400
5928
|
additionalProperties: false
|
|
5401
5929
|
};
|
|
5402
5930
|
|
|
5403
|
-
class JavaScriptTask extends
|
|
5931
|
+
class JavaScriptTask extends Task14 {
|
|
5404
5932
|
static type = "JavaScriptTask";
|
|
5405
5933
|
static category = "Utility";
|
|
5406
5934
|
static title = "JavaScript Interpreter";
|
|
5407
5935
|
static description = "Executes JavaScript code in a sandboxed interpreter environment";
|
|
5408
5936
|
static inputSchema() {
|
|
5409
|
-
return
|
|
5937
|
+
return inputSchema14;
|
|
5410
5938
|
}
|
|
5411
5939
|
static outputSchema() {
|
|
5412
|
-
return
|
|
5940
|
+
return outputSchema14;
|
|
5413
5941
|
}
|
|
5414
5942
|
async executeReactive(input2, output) {
|
|
5415
5943
|
if (input2.javascript_code) {
|
|
@@ -5420,10 +5948,7 @@ class JavaScriptTask extends Task5 {
|
|
|
5420
5948
|
const myInterpreter = new Interpreter(`${inputVariablesString} ${input2.javascript_code}`);
|
|
5421
5949
|
myInterpreter.run();
|
|
5422
5950
|
output.output = myInterpreter.value;
|
|
5423
|
-
|
|
5424
|
-
} catch (e) {
|
|
5425
|
-
console.error("error", e);
|
|
5426
|
-
}
|
|
5951
|
+
} catch (e) {}
|
|
5427
5952
|
}
|
|
5428
5953
|
return output;
|
|
5429
5954
|
}
|
|
@@ -5431,17 +5956,18 @@ class JavaScriptTask extends Task5 {
|
|
|
5431
5956
|
var javaScript = (input2, config = {}) => {
|
|
5432
5957
|
return new JavaScriptTask({}, config).run(input2);
|
|
5433
5958
|
};
|
|
5434
|
-
|
|
5959
|
+
Workflow16.prototype.javaScript = CreateWorkflow15(JavaScriptTask);
|
|
5435
5960
|
// src/task/JsonTask.ts
|
|
5436
5961
|
import {
|
|
5437
5962
|
createGraphFromDependencyJSON,
|
|
5438
|
-
|
|
5963
|
+
createGraphFromGraphJSON,
|
|
5964
|
+
CreateWorkflow as CreateWorkflow16,
|
|
5439
5965
|
Dataflow,
|
|
5440
5966
|
GraphAsTask as GraphAsTask2,
|
|
5441
5967
|
TaskConfigurationError as TaskConfigurationError2,
|
|
5442
|
-
Workflow as
|
|
5968
|
+
Workflow as Workflow17
|
|
5443
5969
|
} from "@workglow/task-graph";
|
|
5444
|
-
var
|
|
5970
|
+
var inputSchema15 = {
|
|
5445
5971
|
type: "object",
|
|
5446
5972
|
properties: {
|
|
5447
5973
|
json: {
|
|
@@ -5452,7 +5978,7 @@ var inputSchema6 = {
|
|
|
5452
5978
|
},
|
|
5453
5979
|
additionalProperties: false
|
|
5454
5980
|
};
|
|
5455
|
-
var
|
|
5981
|
+
var outputSchema15 = {
|
|
5456
5982
|
type: "object",
|
|
5457
5983
|
properties: {
|
|
5458
5984
|
output: {
|
|
@@ -5469,18 +5995,21 @@ class JsonTask extends GraphAsTask2 {
|
|
|
5469
5995
|
static title = "JSON Task";
|
|
5470
5996
|
static description = "A task that creates and manages task graphs from JSON configurations";
|
|
5471
5997
|
static inputSchema() {
|
|
5472
|
-
return
|
|
5998
|
+
return inputSchema15;
|
|
5473
5999
|
}
|
|
5474
6000
|
static outputSchema() {
|
|
5475
|
-
return
|
|
6001
|
+
return outputSchema15;
|
|
5476
6002
|
}
|
|
5477
6003
|
regenerateGraph() {
|
|
5478
6004
|
if (!this.runInputData.json)
|
|
5479
6005
|
return;
|
|
5480
|
-
|
|
5481
|
-
if (
|
|
5482
|
-
|
|
5483
|
-
|
|
6006
|
+
const data = JSON.parse(this.runInputData.json);
|
|
6007
|
+
if (data && typeof data === "object" && "tasks" in data && Array.isArray(data.tasks) && "dataflows" in data && Array.isArray(data.dataflows)) {
|
|
6008
|
+
this.subGraph = createGraphFromGraphJSON(data);
|
|
6009
|
+
super.regenerateGraph();
|
|
6010
|
+
return;
|
|
6011
|
+
}
|
|
6012
|
+
let jsonItems = Array.isArray(data) ? data : [data];
|
|
5484
6013
|
this.subGraph = createGraphFromDependencyJSON(jsonItems);
|
|
5485
6014
|
for (const item of jsonItems) {
|
|
5486
6015
|
if (!item.dependencies)
|
|
@@ -5503,16 +6032,16 @@ class JsonTask extends GraphAsTask2 {
|
|
|
5503
6032
|
var json = (input2, config = {}) => {
|
|
5504
6033
|
return new JsonTask({}, config).run(input2);
|
|
5505
6034
|
};
|
|
5506
|
-
|
|
6035
|
+
Workflow17.prototype.json = CreateWorkflow16(JsonTask);
|
|
5507
6036
|
// src/task/LambdaTask.ts
|
|
5508
6037
|
import {
|
|
5509
|
-
CreateWorkflow as
|
|
6038
|
+
CreateWorkflow as CreateWorkflow17,
|
|
5510
6039
|
DATAFLOW_ALL_PORTS,
|
|
5511
|
-
Task as
|
|
6040
|
+
Task as Task15,
|
|
5512
6041
|
TaskConfigurationError as TaskConfigurationError3,
|
|
5513
|
-
Workflow as
|
|
6042
|
+
Workflow as Workflow18
|
|
5514
6043
|
} from "@workglow/task-graph";
|
|
5515
|
-
var
|
|
6044
|
+
var inputSchema16 = {
|
|
5516
6045
|
type: "object",
|
|
5517
6046
|
properties: {
|
|
5518
6047
|
[DATAFLOW_ALL_PORTS]: {
|
|
@@ -5522,7 +6051,7 @@ var inputSchema7 = {
|
|
|
5522
6051
|
},
|
|
5523
6052
|
additionalProperties: true
|
|
5524
6053
|
};
|
|
5525
|
-
var
|
|
6054
|
+
var outputSchema16 = {
|
|
5526
6055
|
type: "object",
|
|
5527
6056
|
properties: {
|
|
5528
6057
|
[DATAFLOW_ALL_PORTS]: {
|
|
@@ -5533,17 +6062,17 @@ var outputSchema7 = {
|
|
|
5533
6062
|
additionalProperties: true
|
|
5534
6063
|
};
|
|
5535
6064
|
|
|
5536
|
-
class LambdaTask extends
|
|
6065
|
+
class LambdaTask extends Task15 {
|
|
5537
6066
|
static type = "LambdaTask";
|
|
5538
6067
|
static title = "Lambda Task";
|
|
5539
6068
|
static description = "A task that wraps a provided function and its input";
|
|
5540
6069
|
static category = "Hidden";
|
|
5541
6070
|
static cacheable = true;
|
|
5542
6071
|
static inputSchema() {
|
|
5543
|
-
return
|
|
6072
|
+
return inputSchema16;
|
|
5544
6073
|
}
|
|
5545
6074
|
static outputSchema() {
|
|
5546
|
-
return
|
|
6075
|
+
return outputSchema16;
|
|
5547
6076
|
}
|
|
5548
6077
|
constructor(input2 = {}, config = {}) {
|
|
5549
6078
|
if (!config.execute && !config.executeReactive) {
|
|
@@ -5581,15 +6110,15 @@ function lambda(input2, config) {
|
|
|
5581
6110
|
const task = new LambdaTask(input2, config);
|
|
5582
6111
|
return task.run();
|
|
5583
6112
|
}
|
|
5584
|
-
|
|
6113
|
+
Workflow18.prototype.lambda = CreateWorkflow17(LambdaTask);
|
|
5585
6114
|
// src/task/MergeTask.ts
|
|
5586
|
-
import { CreateWorkflow as
|
|
5587
|
-
var
|
|
6115
|
+
import { CreateWorkflow as CreateWorkflow18, Task as Task16, Workflow as Workflow19 } from "@workglow/task-graph";
|
|
6116
|
+
var inputSchema17 = {
|
|
5588
6117
|
type: "object",
|
|
5589
6118
|
properties: {},
|
|
5590
6119
|
additionalProperties: true
|
|
5591
6120
|
};
|
|
5592
|
-
var
|
|
6121
|
+
var outputSchema17 = {
|
|
5593
6122
|
type: "object",
|
|
5594
6123
|
properties: {
|
|
5595
6124
|
output: {
|
|
@@ -5601,19 +6130,19 @@ var outputSchema8 = {
|
|
|
5601
6130
|
additionalProperties: false
|
|
5602
6131
|
};
|
|
5603
6132
|
|
|
5604
|
-
class MergeTask extends
|
|
6133
|
+
class MergeTask extends Task16 {
|
|
5605
6134
|
static type = "MergeTask";
|
|
5606
6135
|
static category = "Utility";
|
|
5607
6136
|
static title = "Merge";
|
|
5608
6137
|
static description = "Merges multiple inputs into a single array output";
|
|
5609
6138
|
static cacheable = true;
|
|
5610
6139
|
static inputSchema() {
|
|
5611
|
-
return
|
|
6140
|
+
return inputSchema17;
|
|
5612
6141
|
}
|
|
5613
6142
|
static outputSchema() {
|
|
5614
|
-
return
|
|
6143
|
+
return outputSchema17;
|
|
5615
6144
|
}
|
|
5616
|
-
async execute(input2,
|
|
6145
|
+
async execute(input2, _context) {
|
|
5617
6146
|
const keys = Object.keys(input2).sort();
|
|
5618
6147
|
const values = keys.map((key) => input2[key]);
|
|
5619
6148
|
return {
|
|
@@ -5625,11 +6154,11 @@ var merge = (input2, config = {}) => {
|
|
|
5625
6154
|
const task = new MergeTask({}, config);
|
|
5626
6155
|
return task.run(input2);
|
|
5627
6156
|
};
|
|
5628
|
-
|
|
6157
|
+
Workflow19.prototype.merge = CreateWorkflow18(MergeTask);
|
|
5629
6158
|
// src/task/OutputTask.ts
|
|
5630
|
-
import { CreateWorkflow as
|
|
6159
|
+
import { CreateWorkflow as CreateWorkflow19, Task as Task17, Workflow as Workflow20 } from "@workglow/task-graph";
|
|
5631
6160
|
|
|
5632
|
-
class OutputTask extends
|
|
6161
|
+
class OutputTask extends Task17 {
|
|
5633
6162
|
static type = "OutputTask";
|
|
5634
6163
|
static category = "Flow Control";
|
|
5635
6164
|
static title = "Output";
|
|
@@ -5663,10 +6192,10 @@ class OutputTask extends Task8 {
|
|
|
5663
6192
|
return input2;
|
|
5664
6193
|
}
|
|
5665
6194
|
}
|
|
5666
|
-
|
|
6195
|
+
Workflow20.prototype.output = CreateWorkflow19(OutputTask);
|
|
5667
6196
|
// src/task/SplitTask.ts
|
|
5668
|
-
import { CreateWorkflow as
|
|
5669
|
-
var
|
|
6197
|
+
import { CreateWorkflow as CreateWorkflow20, Task as Task18, Workflow as Workflow21 } from "@workglow/task-graph";
|
|
6198
|
+
var inputSchema18 = {
|
|
5670
6199
|
type: "object",
|
|
5671
6200
|
properties: {
|
|
5672
6201
|
input: {
|
|
@@ -5676,13 +6205,13 @@ var inputSchema9 = {
|
|
|
5676
6205
|
},
|
|
5677
6206
|
additionalProperties: false
|
|
5678
6207
|
};
|
|
5679
|
-
var
|
|
6208
|
+
var outputSchema18 = {
|
|
5680
6209
|
type: "object",
|
|
5681
6210
|
properties: {},
|
|
5682
6211
|
additionalProperties: true
|
|
5683
6212
|
};
|
|
5684
6213
|
|
|
5685
|
-
class SplitTask extends
|
|
6214
|
+
class SplitTask extends Task18 {
|
|
5686
6215
|
static type = "SplitTask";
|
|
5687
6216
|
static category = "Utility";
|
|
5688
6217
|
static title = "Split";
|
|
@@ -5690,13 +6219,13 @@ class SplitTask extends Task9 {
|
|
|
5690
6219
|
static hasDynamicSchemas = true;
|
|
5691
6220
|
static cacheable = false;
|
|
5692
6221
|
static inputSchema() {
|
|
5693
|
-
return
|
|
6222
|
+
return inputSchema18;
|
|
5694
6223
|
}
|
|
5695
6224
|
static outputSchema() {
|
|
5696
|
-
return
|
|
6225
|
+
return outputSchema18;
|
|
5697
6226
|
}
|
|
5698
6227
|
outputSchema() {
|
|
5699
|
-
return
|
|
6228
|
+
return outputSchema18;
|
|
5700
6229
|
}
|
|
5701
6230
|
async executeReactive(input2) {
|
|
5702
6231
|
const inputValue = input2.input;
|
|
@@ -5715,13 +6244,533 @@ var split = (input2, config = {}) => {
|
|
|
5715
6244
|
const task = new SplitTask({}, config);
|
|
5716
6245
|
return task.run(input2);
|
|
5717
6246
|
};
|
|
5718
|
-
|
|
6247
|
+
Workflow21.prototype.split = CreateWorkflow20(SplitTask);
|
|
6248
|
+
// src/task/scalar/ScalarAbsTask.ts
|
|
6249
|
+
import { CreateWorkflow as CreateWorkflow21, Task as Task19, Workflow as Workflow22 } from "@workglow/task-graph";
|
|
6250
|
+
var inputSchema19 = {
|
|
6251
|
+
type: "object",
|
|
6252
|
+
properties: {
|
|
6253
|
+
value: {
|
|
6254
|
+
type: "number",
|
|
6255
|
+
title: "Value",
|
|
6256
|
+
description: "Input number"
|
|
6257
|
+
}
|
|
6258
|
+
},
|
|
6259
|
+
required: ["value"],
|
|
6260
|
+
additionalProperties: false
|
|
6261
|
+
};
|
|
6262
|
+
var outputSchema19 = {
|
|
6263
|
+
type: "object",
|
|
6264
|
+
properties: {
|
|
6265
|
+
result: {
|
|
6266
|
+
type: "number",
|
|
6267
|
+
title: "Result",
|
|
6268
|
+
description: "Absolute value"
|
|
6269
|
+
}
|
|
6270
|
+
},
|
|
6271
|
+
required: ["result"],
|
|
6272
|
+
additionalProperties: false
|
|
6273
|
+
};
|
|
6274
|
+
|
|
6275
|
+
class ScalarAbsTask extends Task19 {
|
|
6276
|
+
static type = "ScalarAbsTask";
|
|
6277
|
+
static category = "Math";
|
|
6278
|
+
static title = "Abs";
|
|
6279
|
+
static description = "Returns the absolute value of a number";
|
|
6280
|
+
static inputSchema() {
|
|
6281
|
+
return inputSchema19;
|
|
6282
|
+
}
|
|
6283
|
+
static outputSchema() {
|
|
6284
|
+
return outputSchema19;
|
|
6285
|
+
}
|
|
6286
|
+
async execute(input2, _context) {
|
|
6287
|
+
return { result: Math.abs(input2.value) };
|
|
6288
|
+
}
|
|
6289
|
+
}
|
|
6290
|
+
Workflow22.prototype.scalarAbs = CreateWorkflow21(ScalarAbsTask);
|
|
6291
|
+
// src/task/scalar/ScalarCeilTask.ts
|
|
6292
|
+
import { CreateWorkflow as CreateWorkflow22, Task as Task20, Workflow as Workflow23 } from "@workglow/task-graph";
|
|
6293
|
+
var inputSchema20 = {
|
|
6294
|
+
type: "object",
|
|
6295
|
+
properties: {
|
|
6296
|
+
value: {
|
|
6297
|
+
type: "number",
|
|
6298
|
+
title: "Value",
|
|
6299
|
+
description: "Input number"
|
|
6300
|
+
}
|
|
6301
|
+
},
|
|
6302
|
+
required: ["value"],
|
|
6303
|
+
additionalProperties: false
|
|
6304
|
+
};
|
|
6305
|
+
var outputSchema20 = {
|
|
6306
|
+
type: "object",
|
|
6307
|
+
properties: {
|
|
6308
|
+
result: {
|
|
6309
|
+
type: "number",
|
|
6310
|
+
title: "Result",
|
|
6311
|
+
description: "Ceiling value"
|
|
6312
|
+
}
|
|
6313
|
+
},
|
|
6314
|
+
required: ["result"],
|
|
6315
|
+
additionalProperties: false
|
|
6316
|
+
};
|
|
6317
|
+
|
|
6318
|
+
class ScalarCeilTask extends Task20 {
|
|
6319
|
+
static type = "ScalarCeilTask";
|
|
6320
|
+
static category = "Math";
|
|
6321
|
+
static title = "Ceil";
|
|
6322
|
+
static description = "Returns the smallest integer greater than or equal to a number";
|
|
6323
|
+
static inputSchema() {
|
|
6324
|
+
return inputSchema20;
|
|
6325
|
+
}
|
|
6326
|
+
static outputSchema() {
|
|
6327
|
+
return outputSchema20;
|
|
6328
|
+
}
|
|
6329
|
+
async execute(input2, _context) {
|
|
6330
|
+
return { result: Math.ceil(input2.value) };
|
|
6331
|
+
}
|
|
6332
|
+
}
|
|
6333
|
+
Workflow23.prototype.scalarCeil = CreateWorkflow22(ScalarCeilTask);
|
|
6334
|
+
// src/task/scalar/ScalarFloorTask.ts
|
|
6335
|
+
import { CreateWorkflow as CreateWorkflow23, Task as Task21, Workflow as Workflow24 } from "@workglow/task-graph";
|
|
6336
|
+
var inputSchema21 = {
|
|
6337
|
+
type: "object",
|
|
6338
|
+
properties: {
|
|
6339
|
+
value: {
|
|
6340
|
+
type: "number",
|
|
6341
|
+
title: "Value",
|
|
6342
|
+
description: "Input number"
|
|
6343
|
+
}
|
|
6344
|
+
},
|
|
6345
|
+
required: ["value"],
|
|
6346
|
+
additionalProperties: false
|
|
6347
|
+
};
|
|
6348
|
+
var outputSchema21 = {
|
|
6349
|
+
type: "object",
|
|
6350
|
+
properties: {
|
|
6351
|
+
result: {
|
|
6352
|
+
type: "number",
|
|
6353
|
+
title: "Result",
|
|
6354
|
+
description: "Floored value"
|
|
6355
|
+
}
|
|
6356
|
+
},
|
|
6357
|
+
required: ["result"],
|
|
6358
|
+
additionalProperties: false
|
|
6359
|
+
};
|
|
6360
|
+
|
|
6361
|
+
class ScalarFloorTask extends Task21 {
|
|
6362
|
+
static type = "ScalarFloorTask";
|
|
6363
|
+
static category = "Math";
|
|
6364
|
+
static title = "Floor";
|
|
6365
|
+
static description = "Returns the largest integer less than or equal to a number";
|
|
6366
|
+
static inputSchema() {
|
|
6367
|
+
return inputSchema21;
|
|
6368
|
+
}
|
|
6369
|
+
static outputSchema() {
|
|
6370
|
+
return outputSchema21;
|
|
6371
|
+
}
|
|
6372
|
+
async execute(input2, _context) {
|
|
6373
|
+
return { result: Math.floor(input2.value) };
|
|
6374
|
+
}
|
|
6375
|
+
}
|
|
6376
|
+
Workflow24.prototype.scalarFloor = CreateWorkflow23(ScalarFloorTask);
|
|
6377
|
+
// src/task/scalar/ScalarMaxTask.ts
|
|
6378
|
+
import { CreateWorkflow as CreateWorkflow24, Task as Task22, Workflow as Workflow25 } from "@workglow/task-graph";
|
|
6379
|
+
var inputSchema22 = {
|
|
6380
|
+
type: "object",
|
|
6381
|
+
properties: {
|
|
6382
|
+
values: {
|
|
6383
|
+
type: "array",
|
|
6384
|
+
items: { type: "number" },
|
|
6385
|
+
title: "Values",
|
|
6386
|
+
description: "Array of numbers"
|
|
6387
|
+
}
|
|
6388
|
+
},
|
|
6389
|
+
required: ["values"],
|
|
6390
|
+
additionalProperties: false
|
|
6391
|
+
};
|
|
6392
|
+
var outputSchema22 = {
|
|
6393
|
+
type: "object",
|
|
6394
|
+
properties: {
|
|
6395
|
+
result: {
|
|
6396
|
+
type: "number",
|
|
6397
|
+
title: "Result",
|
|
6398
|
+
description: "Maximum value"
|
|
6399
|
+
}
|
|
6400
|
+
},
|
|
6401
|
+
required: ["result"],
|
|
6402
|
+
additionalProperties: false
|
|
6403
|
+
};
|
|
6404
|
+
|
|
6405
|
+
class ScalarMaxTask extends Task22 {
|
|
6406
|
+
static type = "ScalarMaxTask";
|
|
6407
|
+
static category = "Math";
|
|
6408
|
+
static title = "Max";
|
|
6409
|
+
static description = "Returns the largest of the given numbers";
|
|
6410
|
+
static inputSchema() {
|
|
6411
|
+
return inputSchema22;
|
|
6412
|
+
}
|
|
6413
|
+
static outputSchema() {
|
|
6414
|
+
return outputSchema22;
|
|
6415
|
+
}
|
|
6416
|
+
async execute(input2, _context) {
|
|
6417
|
+
return { result: Math.max(...input2.values) };
|
|
6418
|
+
}
|
|
6419
|
+
}
|
|
6420
|
+
Workflow25.prototype.scalarMax = CreateWorkflow24(ScalarMaxTask);
|
|
6421
|
+
// src/task/scalar/ScalarMinTask.ts
|
|
6422
|
+
import { CreateWorkflow as CreateWorkflow25, Task as Task23, Workflow as Workflow26 } from "@workglow/task-graph";
|
|
6423
|
+
var inputSchema23 = {
|
|
6424
|
+
type: "object",
|
|
6425
|
+
properties: {
|
|
6426
|
+
values: {
|
|
6427
|
+
type: "array",
|
|
6428
|
+
items: { type: "number" },
|
|
6429
|
+
title: "Values",
|
|
6430
|
+
description: "Array of numbers"
|
|
6431
|
+
}
|
|
6432
|
+
},
|
|
6433
|
+
required: ["values"],
|
|
6434
|
+
additionalProperties: false
|
|
6435
|
+
};
|
|
6436
|
+
var outputSchema23 = {
|
|
6437
|
+
type: "object",
|
|
6438
|
+
properties: {
|
|
6439
|
+
result: {
|
|
6440
|
+
type: "number",
|
|
6441
|
+
title: "Result",
|
|
6442
|
+
description: "Minimum value"
|
|
6443
|
+
}
|
|
6444
|
+
},
|
|
6445
|
+
required: ["result"],
|
|
6446
|
+
additionalProperties: false
|
|
6447
|
+
};
|
|
6448
|
+
|
|
6449
|
+
class ScalarMinTask extends Task23 {
|
|
6450
|
+
static type = "ScalarMinTask";
|
|
6451
|
+
static category = "Math";
|
|
6452
|
+
static title = "Min";
|
|
6453
|
+
static description = "Returns the smallest of the given numbers";
|
|
6454
|
+
static inputSchema() {
|
|
6455
|
+
return inputSchema23;
|
|
6456
|
+
}
|
|
6457
|
+
static outputSchema() {
|
|
6458
|
+
return outputSchema23;
|
|
6459
|
+
}
|
|
6460
|
+
async execute(input2, _context) {
|
|
6461
|
+
return { result: Math.min(...input2.values) };
|
|
6462
|
+
}
|
|
6463
|
+
}
|
|
6464
|
+
Workflow26.prototype.scalarMin = CreateWorkflow25(ScalarMinTask);
|
|
6465
|
+
// src/task/scalar/ScalarRoundTask.ts
|
|
6466
|
+
import { CreateWorkflow as CreateWorkflow26, Task as Task24, Workflow as Workflow27 } from "@workglow/task-graph";
|
|
6467
|
+
var inputSchema24 = {
|
|
6468
|
+
type: "object",
|
|
6469
|
+
properties: {
|
|
6470
|
+
value: {
|
|
6471
|
+
type: "number",
|
|
6472
|
+
title: "Value",
|
|
6473
|
+
description: "Input number"
|
|
6474
|
+
}
|
|
6475
|
+
},
|
|
6476
|
+
required: ["value"],
|
|
6477
|
+
additionalProperties: false
|
|
6478
|
+
};
|
|
6479
|
+
var outputSchema24 = {
|
|
6480
|
+
type: "object",
|
|
6481
|
+
properties: {
|
|
6482
|
+
result: {
|
|
6483
|
+
type: "number",
|
|
6484
|
+
title: "Result",
|
|
6485
|
+
description: "Rounded value"
|
|
6486
|
+
}
|
|
6487
|
+
},
|
|
6488
|
+
required: ["result"],
|
|
6489
|
+
additionalProperties: false
|
|
6490
|
+
};
|
|
6491
|
+
|
|
6492
|
+
class ScalarRoundTask extends Task24 {
|
|
6493
|
+
static type = "ScalarRoundTask";
|
|
6494
|
+
static category = "Math";
|
|
6495
|
+
static title = "Round";
|
|
6496
|
+
static description = "Returns the value of a number rounded to the nearest integer";
|
|
6497
|
+
static inputSchema() {
|
|
6498
|
+
return inputSchema24;
|
|
6499
|
+
}
|
|
6500
|
+
static outputSchema() {
|
|
6501
|
+
return outputSchema24;
|
|
6502
|
+
}
|
|
6503
|
+
async execute(input2, _context) {
|
|
6504
|
+
return { result: Math.round(input2.value) };
|
|
6505
|
+
}
|
|
6506
|
+
}
|
|
6507
|
+
Workflow27.prototype.scalarRound = CreateWorkflow26(ScalarRoundTask);
|
|
6508
|
+
// src/task/scalar/ScalarTruncTask.ts
|
|
6509
|
+
import { CreateWorkflow as CreateWorkflow27, Task as Task25, Workflow as Workflow28 } from "@workglow/task-graph";
|
|
6510
|
+
var inputSchema25 = {
|
|
6511
|
+
type: "object",
|
|
6512
|
+
properties: {
|
|
6513
|
+
value: {
|
|
6514
|
+
type: "number",
|
|
6515
|
+
title: "Value",
|
|
6516
|
+
description: "Input number"
|
|
6517
|
+
}
|
|
6518
|
+
},
|
|
6519
|
+
required: ["value"],
|
|
6520
|
+
additionalProperties: false
|
|
6521
|
+
};
|
|
6522
|
+
var outputSchema25 = {
|
|
6523
|
+
type: "object",
|
|
6524
|
+
properties: {
|
|
6525
|
+
result: {
|
|
6526
|
+
type: "number",
|
|
6527
|
+
title: "Result",
|
|
6528
|
+
description: "Truncated value"
|
|
6529
|
+
}
|
|
6530
|
+
},
|
|
6531
|
+
required: ["result"],
|
|
6532
|
+
additionalProperties: false
|
|
6533
|
+
};
|
|
6534
|
+
|
|
6535
|
+
class ScalarTruncTask extends Task25 {
|
|
6536
|
+
static type = "ScalarTruncTask";
|
|
6537
|
+
static category = "Math";
|
|
6538
|
+
static title = "Truncate";
|
|
6539
|
+
static description = "Returns the integer part of a number by removing fractional digits";
|
|
6540
|
+
static inputSchema() {
|
|
6541
|
+
return inputSchema25;
|
|
6542
|
+
}
|
|
6543
|
+
static outputSchema() {
|
|
6544
|
+
return outputSchema25;
|
|
6545
|
+
}
|
|
6546
|
+
async execute(input2, _context) {
|
|
6547
|
+
return { result: Math.trunc(input2.value) };
|
|
6548
|
+
}
|
|
6549
|
+
}
|
|
6550
|
+
Workflow28.prototype.scalarTrunc = CreateWorkflow27(ScalarTruncTask);
|
|
6551
|
+
// src/task/vector/VectorDistanceTask.ts
|
|
6552
|
+
import { CreateWorkflow as CreateWorkflow28, Task as Task26, Workflow as Workflow29 } from "@workglow/task-graph";
|
|
6553
|
+
import {
|
|
6554
|
+
TypedArraySchema as TypedArraySchema5
|
|
6555
|
+
} from "@workglow/util";
|
|
6556
|
+
var inputSchema26 = {
|
|
6557
|
+
type: "object",
|
|
6558
|
+
properties: {
|
|
6559
|
+
vectors: {
|
|
6560
|
+
type: "array",
|
|
6561
|
+
items: TypedArraySchema5({
|
|
6562
|
+
title: "Vector",
|
|
6563
|
+
description: "Vector for distance computation"
|
|
6564
|
+
}),
|
|
6565
|
+
title: "Vectors",
|
|
6566
|
+
description: "Array of two vectors to compute Euclidean distance"
|
|
6567
|
+
}
|
|
6568
|
+
},
|
|
6569
|
+
required: ["vectors"],
|
|
6570
|
+
additionalProperties: false
|
|
6571
|
+
};
|
|
6572
|
+
var outputSchema26 = {
|
|
6573
|
+
type: "object",
|
|
6574
|
+
properties: {
|
|
6575
|
+
result: {
|
|
6576
|
+
type: "number",
|
|
6577
|
+
title: "Result",
|
|
6578
|
+
description: "Euclidean distance between vectors"
|
|
6579
|
+
}
|
|
6580
|
+
},
|
|
6581
|
+
required: ["result"],
|
|
6582
|
+
additionalProperties: false
|
|
6583
|
+
};
|
|
6584
|
+
|
|
6585
|
+
class VectorDistanceTask extends Task26 {
|
|
6586
|
+
static type = "VectorDistanceTask";
|
|
6587
|
+
static category = "Vector";
|
|
6588
|
+
static title = "Distance";
|
|
6589
|
+
static description = "Returns the Euclidean distance between the first two vectors";
|
|
6590
|
+
static inputSchema() {
|
|
6591
|
+
return inputSchema26;
|
|
6592
|
+
}
|
|
6593
|
+
static outputSchema() {
|
|
6594
|
+
return outputSchema26;
|
|
6595
|
+
}
|
|
6596
|
+
async execute(input2, _context) {
|
|
6597
|
+
const { vectors } = input2;
|
|
6598
|
+
if (vectors.length < 2) {
|
|
6599
|
+
throw new Error("Exactly two vectors are required for distance");
|
|
6600
|
+
}
|
|
6601
|
+
const [a, b] = vectors;
|
|
6602
|
+
if (a.length !== b.length) {
|
|
6603
|
+
throw new Error("Vectors must have the same length");
|
|
6604
|
+
}
|
|
6605
|
+
const diffs = Array.from({ length: a.length }, (_, i) => {
|
|
6606
|
+
const d = Number(a[i]) - Number(b[i]);
|
|
6607
|
+
return d * d;
|
|
6608
|
+
});
|
|
6609
|
+
return { result: Math.sqrt(sumPrecise(diffs)) };
|
|
6610
|
+
}
|
|
6611
|
+
}
|
|
6612
|
+
Workflow29.prototype.vectorDistance = CreateWorkflow28(VectorDistanceTask);
|
|
6613
|
+
// src/task/vector/VectorDotProductTask.ts
|
|
6614
|
+
import { CreateWorkflow as CreateWorkflow29, Task as Task27, Workflow as Workflow30 } from "@workglow/task-graph";
|
|
6615
|
+
import {
|
|
6616
|
+
TypedArraySchema as TypedArraySchema6
|
|
6617
|
+
} from "@workglow/util";
|
|
6618
|
+
var inputSchema27 = {
|
|
6619
|
+
type: "object",
|
|
6620
|
+
properties: {
|
|
6621
|
+
vectors: {
|
|
6622
|
+
type: "array",
|
|
6623
|
+
items: TypedArraySchema6({
|
|
6624
|
+
title: "Vector",
|
|
6625
|
+
description: "Vector for dot product"
|
|
6626
|
+
}),
|
|
6627
|
+
title: "Vectors",
|
|
6628
|
+
description: "Array of two vectors to compute dot product"
|
|
6629
|
+
}
|
|
6630
|
+
},
|
|
6631
|
+
required: ["vectors"],
|
|
6632
|
+
additionalProperties: false
|
|
6633
|
+
};
|
|
6634
|
+
var outputSchema27 = {
|
|
6635
|
+
type: "object",
|
|
6636
|
+
properties: {
|
|
6637
|
+
result: {
|
|
6638
|
+
type: "number",
|
|
6639
|
+
title: "Result",
|
|
6640
|
+
description: "Dot product of the vectors"
|
|
6641
|
+
}
|
|
6642
|
+
},
|
|
6643
|
+
required: ["result"],
|
|
6644
|
+
additionalProperties: false
|
|
6645
|
+
};
|
|
6646
|
+
|
|
6647
|
+
class VectorDotProductTask extends Task27 {
|
|
6648
|
+
static type = "VectorDotProductTask";
|
|
6649
|
+
static category = "Vector";
|
|
6650
|
+
static title = "Dot Product";
|
|
6651
|
+
static description = "Returns the dot (inner) product of the first two vectors";
|
|
6652
|
+
static inputSchema() {
|
|
6653
|
+
return inputSchema27;
|
|
6654
|
+
}
|
|
6655
|
+
static outputSchema() {
|
|
6656
|
+
return outputSchema27;
|
|
6657
|
+
}
|
|
6658
|
+
async execute(input2, _context) {
|
|
6659
|
+
const { vectors } = input2;
|
|
6660
|
+
if (vectors.length < 2) {
|
|
6661
|
+
throw new Error("Exactly two vectors are required for dot product");
|
|
6662
|
+
}
|
|
6663
|
+
const [a, b] = vectors;
|
|
6664
|
+
if (a.length !== b.length) {
|
|
6665
|
+
throw new Error("Vectors must have the same length");
|
|
6666
|
+
}
|
|
6667
|
+
const products = Array.from({ length: a.length }, (_, i) => Number(a[i]) * Number(b[i]));
|
|
6668
|
+
return { result: sumPrecise(products) };
|
|
6669
|
+
}
|
|
6670
|
+
}
|
|
6671
|
+
Workflow30.prototype.vectorDotProduct = CreateWorkflow29(VectorDotProductTask);
|
|
6672
|
+
// src/task/vector/VectorNormalizeTask.ts
|
|
6673
|
+
import { CreateWorkflow as CreateWorkflow30, Task as Task28, Workflow as Workflow31 } from "@workglow/task-graph";
|
|
6674
|
+
import {
|
|
6675
|
+
TypedArraySchema as TypedArraySchema7,
|
|
6676
|
+
normalize
|
|
6677
|
+
} from "@workglow/util";
|
|
6678
|
+
var inputSchema28 = {
|
|
6679
|
+
type: "object",
|
|
6680
|
+
properties: {
|
|
6681
|
+
vector: TypedArraySchema7({
|
|
6682
|
+
title: "Vector",
|
|
6683
|
+
description: "Input vector to normalize"
|
|
6684
|
+
})
|
|
6685
|
+
},
|
|
6686
|
+
required: ["vector"],
|
|
6687
|
+
additionalProperties: false
|
|
6688
|
+
};
|
|
6689
|
+
var outputSchema28 = {
|
|
6690
|
+
type: "object",
|
|
6691
|
+
properties: {
|
|
6692
|
+
result: TypedArraySchema7({
|
|
6693
|
+
title: "Result",
|
|
6694
|
+
description: "L2-normalized vector"
|
|
6695
|
+
})
|
|
6696
|
+
},
|
|
6697
|
+
required: ["result"],
|
|
6698
|
+
additionalProperties: false
|
|
6699
|
+
};
|
|
6700
|
+
|
|
6701
|
+
class VectorNormalizeTask extends Task28 {
|
|
6702
|
+
static type = "VectorNormalizeTask";
|
|
6703
|
+
static category = "Vector";
|
|
6704
|
+
static title = "Normalize";
|
|
6705
|
+
static description = "Returns the L2-normalized (unit length) vector";
|
|
6706
|
+
static inputSchema() {
|
|
6707
|
+
return inputSchema28;
|
|
6708
|
+
}
|
|
6709
|
+
static outputSchema() {
|
|
6710
|
+
return outputSchema28;
|
|
6711
|
+
}
|
|
6712
|
+
async execute(input2, _context) {
|
|
6713
|
+
return { result: normalize(input2.vector) };
|
|
6714
|
+
}
|
|
6715
|
+
}
|
|
6716
|
+
Workflow31.prototype.vectorNormalize = CreateWorkflow30(VectorNormalizeTask);
|
|
6717
|
+
// src/task/vector/VectorScaleTask.ts
|
|
6718
|
+
import { CreateWorkflow as CreateWorkflow31, Task as Task29, Workflow as Workflow32 } from "@workglow/task-graph";
|
|
6719
|
+
import {
|
|
6720
|
+
createTypedArrayFrom as createTypedArrayFrom5,
|
|
6721
|
+
TypedArraySchema as TypedArraySchema8
|
|
6722
|
+
} from "@workglow/util";
|
|
6723
|
+
var inputSchema29 = {
|
|
6724
|
+
type: "object",
|
|
6725
|
+
properties: {
|
|
6726
|
+
vector: TypedArraySchema8({
|
|
6727
|
+
title: "Vector",
|
|
6728
|
+
description: "Input vector"
|
|
6729
|
+
}),
|
|
6730
|
+
scalar: {
|
|
6731
|
+
type: "number",
|
|
6732
|
+
title: "Scalar",
|
|
6733
|
+
description: "Scalar multiplier"
|
|
6734
|
+
}
|
|
6735
|
+
},
|
|
6736
|
+
required: ["vector", "scalar"],
|
|
6737
|
+
additionalProperties: false
|
|
6738
|
+
};
|
|
6739
|
+
var outputSchema29 = {
|
|
6740
|
+
type: "object",
|
|
6741
|
+
properties: {
|
|
6742
|
+
result: TypedArraySchema8({
|
|
6743
|
+
title: "Result",
|
|
6744
|
+
description: "Scaled vector"
|
|
6745
|
+
})
|
|
6746
|
+
},
|
|
6747
|
+
required: ["result"],
|
|
6748
|
+
additionalProperties: false
|
|
6749
|
+
};
|
|
6750
|
+
|
|
6751
|
+
class VectorScaleTask extends Task29 {
|
|
6752
|
+
static type = "VectorScaleTask";
|
|
6753
|
+
static category = "Vector";
|
|
6754
|
+
static title = "Scale";
|
|
6755
|
+
static description = "Multiplies each element of a vector by a scalar";
|
|
6756
|
+
static inputSchema() {
|
|
6757
|
+
return inputSchema29;
|
|
6758
|
+
}
|
|
6759
|
+
static outputSchema() {
|
|
6760
|
+
return outputSchema29;
|
|
6761
|
+
}
|
|
6762
|
+
async execute(input2, _context) {
|
|
6763
|
+
const { vector, scalar } = input2;
|
|
6764
|
+
const values = Array.from(vector, (v) => Number(v) * scalar);
|
|
6765
|
+
return { result: createTypedArrayFrom5([vector], values) };
|
|
6766
|
+
}
|
|
6767
|
+
}
|
|
6768
|
+
Workflow32.prototype.vectorScale = CreateWorkflow31(VectorScaleTask);
|
|
5719
6769
|
|
|
5720
6770
|
// src/common.ts
|
|
5721
6771
|
import { TaskRegistry } from "@workglow/task-graph";
|
|
5722
6772
|
var registerCommonTasks = () => {
|
|
5723
6773
|
const tasks = [
|
|
5724
|
-
ArrayTask,
|
|
5725
6774
|
DebugLogTask,
|
|
5726
6775
|
DelayTask,
|
|
5727
6776
|
FetchUrlTask,
|
|
@@ -5731,7 +6780,27 @@ var registerCommonTasks = () => {
|
|
|
5731
6780
|
LambdaTask,
|
|
5732
6781
|
MergeTask,
|
|
5733
6782
|
OutputTask,
|
|
5734
|
-
SplitTask
|
|
6783
|
+
SplitTask,
|
|
6784
|
+
ScalarAbsTask,
|
|
6785
|
+
ScalarAddTask,
|
|
6786
|
+
ScalarCeilTask,
|
|
6787
|
+
ScalarDivideTask,
|
|
6788
|
+
ScalarFloorTask,
|
|
6789
|
+
ScalarMaxTask,
|
|
6790
|
+
ScalarMinTask,
|
|
6791
|
+
ScalarMultiplyTask,
|
|
6792
|
+
ScalarRoundTask,
|
|
6793
|
+
ScalarSubtractTask,
|
|
6794
|
+
ScalarSumTask,
|
|
6795
|
+
ScalarTruncTask,
|
|
6796
|
+
VectorSumTask,
|
|
6797
|
+
VectorDistanceTask,
|
|
6798
|
+
VectorDivideTask,
|
|
6799
|
+
VectorDotProductTask,
|
|
6800
|
+
VectorMultiplyTask,
|
|
6801
|
+
VectorNormalizeTask,
|
|
6802
|
+
VectorScaleTask,
|
|
6803
|
+
VectorSubtractTask
|
|
5735
6804
|
];
|
|
5736
6805
|
tasks.map(TaskRegistry.registerTask);
|
|
5737
6806
|
return tasks;
|
|
@@ -5751,8 +6820,28 @@ export {
|
|
|
5751
6820
|
fetchUrl,
|
|
5752
6821
|
delay,
|
|
5753
6822
|
debugLog,
|
|
6823
|
+
VectorSumTask,
|
|
6824
|
+
VectorSubtractTask,
|
|
6825
|
+
VectorScaleTask,
|
|
6826
|
+
VectorNormalizeTask,
|
|
6827
|
+
VectorMultiplyTask,
|
|
6828
|
+
VectorDotProductTask,
|
|
6829
|
+
VectorDivideTask,
|
|
6830
|
+
VectorDistanceTask,
|
|
5754
6831
|
TypeReplicateArray,
|
|
5755
6832
|
SplitTask,
|
|
6833
|
+
ScalarTruncTask,
|
|
6834
|
+
ScalarSumTask,
|
|
6835
|
+
ScalarSubtractTask,
|
|
6836
|
+
ScalarRoundTask,
|
|
6837
|
+
ScalarMultiplyTask,
|
|
6838
|
+
ScalarMinTask,
|
|
6839
|
+
ScalarMaxTask,
|
|
6840
|
+
ScalarFloorTask,
|
|
6841
|
+
ScalarDivideTask,
|
|
6842
|
+
ScalarCeilTask,
|
|
6843
|
+
ScalarAddTask,
|
|
6844
|
+
ScalarAbsTask,
|
|
5756
6845
|
OutputTask,
|
|
5757
6846
|
MergeTask,
|
|
5758
6847
|
LambdaTask,
|
|
@@ -5767,4 +6856,4 @@ export {
|
|
|
5767
6856
|
ArrayTask
|
|
5768
6857
|
};
|
|
5769
6858
|
|
|
5770
|
-
//# debugId=
|
|
6859
|
+
//# debugId=1C4F2D27323C353864756E2164756E21
|