@agentforge/tools 0.16.23 → 0.16.25
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/index.cjs +53 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -6
- package/dist/index.d.ts +18 -6
- package/dist/index.js +53 -27
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -2704,7 +2704,9 @@ declare function createArrayGroupByTool(): _agentforge_core.Tool<{
|
|
|
2704
2704
|
declare function createObjectPickTool(): _agentforge_core.Tool<{
|
|
2705
2705
|
object: Record<string, any>;
|
|
2706
2706
|
properties: string[];
|
|
2707
|
-
},
|
|
2707
|
+
}, {
|
|
2708
|
+
[x: string]: unknown;
|
|
2709
|
+
}>;
|
|
2708
2710
|
|
|
2709
2711
|
/**
|
|
2710
2712
|
* Object Omit Tool
|
|
@@ -2715,7 +2717,9 @@ declare function createObjectPickTool(): _agentforge_core.Tool<{
|
|
|
2715
2717
|
declare function createObjectOmitTool(): _agentforge_core.Tool<{
|
|
2716
2718
|
object: Record<string, any>;
|
|
2717
2719
|
properties: string[];
|
|
2718
|
-
},
|
|
2720
|
+
}, {
|
|
2721
|
+
[x: string]: unknown;
|
|
2722
|
+
}>;
|
|
2719
2723
|
|
|
2720
2724
|
/**
|
|
2721
2725
|
* Default array filter tool instance
|
|
@@ -2768,14 +2772,18 @@ declare const arrayGroupBy: _agentforge_core.Tool<{
|
|
|
2768
2772
|
declare const objectPick: _agentforge_core.Tool<{
|
|
2769
2773
|
object: Record<string, any>;
|
|
2770
2774
|
properties: string[];
|
|
2771
|
-
},
|
|
2775
|
+
}, {
|
|
2776
|
+
[x: string]: unknown;
|
|
2777
|
+
}>;
|
|
2772
2778
|
/**
|
|
2773
2779
|
* Default object omit tool instance
|
|
2774
2780
|
*/
|
|
2775
2781
|
declare const objectOmit: _agentforge_core.Tool<{
|
|
2776
2782
|
object: Record<string, any>;
|
|
2777
2783
|
properties: string[];
|
|
2778
|
-
},
|
|
2784
|
+
}, {
|
|
2785
|
+
[x: string]: unknown;
|
|
2786
|
+
}>;
|
|
2779
2787
|
/**
|
|
2780
2788
|
* All transformer tools
|
|
2781
2789
|
*/
|
|
@@ -2811,7 +2819,9 @@ declare const transformerTools: (_agentforge_core.Tool<{
|
|
|
2811
2819
|
}> | _agentforge_core.Tool<{
|
|
2812
2820
|
object: Record<string, any>;
|
|
2813
2821
|
properties: string[];
|
|
2814
|
-
},
|
|
2822
|
+
}, {
|
|
2823
|
+
[x: string]: unknown;
|
|
2824
|
+
}>)[];
|
|
2815
2825
|
/**
|
|
2816
2826
|
* Create transformer tools with custom configuration
|
|
2817
2827
|
*/
|
|
@@ -2847,7 +2857,9 @@ declare function createTransformerTools(config?: TransformerToolsConfig): (_agen
|
|
|
2847
2857
|
}> | _agentforge_core.Tool<{
|
|
2848
2858
|
object: Record<string, any>;
|
|
2849
2859
|
properties: string[];
|
|
2850
|
-
},
|
|
2860
|
+
}, {
|
|
2861
|
+
[x: string]: unknown;
|
|
2862
|
+
}>)[];
|
|
2851
2863
|
|
|
2852
2864
|
/**
|
|
2853
2865
|
* Neo4j Tools Types
|
package/dist/index.d.ts
CHANGED
|
@@ -2704,7 +2704,9 @@ declare function createArrayGroupByTool(): _agentforge_core.Tool<{
|
|
|
2704
2704
|
declare function createObjectPickTool(): _agentforge_core.Tool<{
|
|
2705
2705
|
object: Record<string, any>;
|
|
2706
2706
|
properties: string[];
|
|
2707
|
-
},
|
|
2707
|
+
}, {
|
|
2708
|
+
[x: string]: unknown;
|
|
2709
|
+
}>;
|
|
2708
2710
|
|
|
2709
2711
|
/**
|
|
2710
2712
|
* Object Omit Tool
|
|
@@ -2715,7 +2717,9 @@ declare function createObjectPickTool(): _agentforge_core.Tool<{
|
|
|
2715
2717
|
declare function createObjectOmitTool(): _agentforge_core.Tool<{
|
|
2716
2718
|
object: Record<string, any>;
|
|
2717
2719
|
properties: string[];
|
|
2718
|
-
},
|
|
2720
|
+
}, {
|
|
2721
|
+
[x: string]: unknown;
|
|
2722
|
+
}>;
|
|
2719
2723
|
|
|
2720
2724
|
/**
|
|
2721
2725
|
* Default array filter tool instance
|
|
@@ -2768,14 +2772,18 @@ declare const arrayGroupBy: _agentforge_core.Tool<{
|
|
|
2768
2772
|
declare const objectPick: _agentforge_core.Tool<{
|
|
2769
2773
|
object: Record<string, any>;
|
|
2770
2774
|
properties: string[];
|
|
2771
|
-
},
|
|
2775
|
+
}, {
|
|
2776
|
+
[x: string]: unknown;
|
|
2777
|
+
}>;
|
|
2772
2778
|
/**
|
|
2773
2779
|
* Default object omit tool instance
|
|
2774
2780
|
*/
|
|
2775
2781
|
declare const objectOmit: _agentforge_core.Tool<{
|
|
2776
2782
|
object: Record<string, any>;
|
|
2777
2783
|
properties: string[];
|
|
2778
|
-
},
|
|
2784
|
+
}, {
|
|
2785
|
+
[x: string]: unknown;
|
|
2786
|
+
}>;
|
|
2779
2787
|
/**
|
|
2780
2788
|
* All transformer tools
|
|
2781
2789
|
*/
|
|
@@ -2811,7 +2819,9 @@ declare const transformerTools: (_agentforge_core.Tool<{
|
|
|
2811
2819
|
}> | _agentforge_core.Tool<{
|
|
2812
2820
|
object: Record<string, any>;
|
|
2813
2821
|
properties: string[];
|
|
2814
|
-
},
|
|
2822
|
+
}, {
|
|
2823
|
+
[x: string]: unknown;
|
|
2824
|
+
}>)[];
|
|
2815
2825
|
/**
|
|
2816
2826
|
* Create transformer tools with custom configuration
|
|
2817
2827
|
*/
|
|
@@ -2847,7 +2857,9 @@ declare function createTransformerTools(config?: TransformerToolsConfig): (_agen
|
|
|
2847
2857
|
}> | _agentforge_core.Tool<{
|
|
2848
2858
|
object: Record<string, any>;
|
|
2849
2859
|
properties: string[];
|
|
2850
|
-
},
|
|
2860
|
+
}, {
|
|
2861
|
+
[x: string]: unknown;
|
|
2862
|
+
}>)[];
|
|
2851
2863
|
|
|
2852
2864
|
/**
|
|
2853
2865
|
* Neo4j Tools Types
|
package/dist/index.js
CHANGED
|
@@ -1914,11 +1914,52 @@ var objectOmitSchema = z.object({
|
|
|
1914
1914
|
object: z.record(z.any().describe("Property value")).describe("Source object"),
|
|
1915
1915
|
properties: z.array(z.string().describe("String value")).describe("List of property names to omit")
|
|
1916
1916
|
});
|
|
1917
|
+
|
|
1918
|
+
// src/data/transformer/tools/shared.ts
|
|
1919
|
+
function getNestedValue(value, path12) {
|
|
1920
|
+
return path12.split(".").reduce((current, key) => {
|
|
1921
|
+
if (current == null) {
|
|
1922
|
+
return void 0;
|
|
1923
|
+
}
|
|
1924
|
+
return Reflect.get(Object(current), key);
|
|
1925
|
+
}, value);
|
|
1926
|
+
}
|
|
1927
|
+
function compareRelationalValues(left, right) {
|
|
1928
|
+
const leftOperand = left;
|
|
1929
|
+
const rightOperand = right;
|
|
1930
|
+
if (leftOperand < rightOperand) {
|
|
1931
|
+
return -1;
|
|
1932
|
+
}
|
|
1933
|
+
if (leftOperand > rightOperand) {
|
|
1934
|
+
return 1;
|
|
1935
|
+
}
|
|
1936
|
+
return 0;
|
|
1937
|
+
}
|
|
1938
|
+
function pickObjectProperties(source, properties) {
|
|
1939
|
+
const picked = {};
|
|
1940
|
+
for (const property of properties) {
|
|
1941
|
+
if (property in source) {
|
|
1942
|
+
Object.defineProperty(picked, property, {
|
|
1943
|
+
value: source[property],
|
|
1944
|
+
enumerable: true,
|
|
1945
|
+
configurable: true,
|
|
1946
|
+
writable: true
|
|
1947
|
+
});
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
return picked;
|
|
1951
|
+
}
|
|
1952
|
+
function omitObjectProperties(source, properties) {
|
|
1953
|
+
const omitted = { ...source };
|
|
1954
|
+
for (const property of properties) {
|
|
1955
|
+
delete omitted[property];
|
|
1956
|
+
}
|
|
1957
|
+
return omitted;
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
// src/data/transformer/tools/array-filter.ts
|
|
1917
1961
|
function createArrayFilterTool() {
|
|
1918
1962
|
return toolBuilder().name("array-filter").description("Filter an array based on a property value. Supports equality, comparison, and contains operations.").category(ToolCategory.UTILITY).tags(["array", "filter", "data", "transform"]).schema(arrayFilterSchema).implement(async (input) => {
|
|
1919
|
-
const getNestedValue = (obj, path12) => {
|
|
1920
|
-
return path12.split(".").reduce((current, key) => current?.[key], obj);
|
|
1921
|
-
};
|
|
1922
1963
|
const filtered = input.array.filter((item) => {
|
|
1923
1964
|
const itemValue = getNestedValue(item, input.property);
|
|
1924
1965
|
switch (input.operator) {
|
|
@@ -1927,9 +1968,9 @@ function createArrayFilterTool() {
|
|
|
1927
1968
|
case "not-equals":
|
|
1928
1969
|
return itemValue !== input.value;
|
|
1929
1970
|
case "greater-than":
|
|
1930
|
-
return itemValue
|
|
1971
|
+
return compareRelationalValues(itemValue, input.value) > 0;
|
|
1931
1972
|
case "less-than":
|
|
1932
|
-
return itemValue
|
|
1973
|
+
return compareRelationalValues(itemValue, input.value) < 0;
|
|
1933
1974
|
case "contains":
|
|
1934
1975
|
return String(itemValue).includes(String(input.value));
|
|
1935
1976
|
case "starts-with":
|
|
@@ -1965,15 +2006,14 @@ function createArrayMapTool() {
|
|
|
1965
2006
|
}
|
|
1966
2007
|
function createArraySortTool() {
|
|
1967
2008
|
return toolBuilder().name("array-sort").description("Sort an array by a property value. Supports ascending and descending order.").category(ToolCategory.UTILITY).tags(["array", "sort", "data", "transform"]).schema(arraySortSchema).implement(async (input) => {
|
|
1968
|
-
const getNestedValue = (obj, path12) => {
|
|
1969
|
-
return path12.split(".").reduce((current, key) => current?.[key], obj);
|
|
1970
|
-
};
|
|
1971
2009
|
const sorted = [...input.array].sort((a, b) => {
|
|
1972
2010
|
const aValue = getNestedValue(a, input.property);
|
|
1973
2011
|
const bValue = getNestedValue(b, input.property);
|
|
1974
|
-
|
|
1975
|
-
if (
|
|
1976
|
-
|
|
2012
|
+
const comparison = compareRelationalValues(aValue, bValue);
|
|
2013
|
+
if (comparison === 0) {
|
|
2014
|
+
return 0;
|
|
2015
|
+
}
|
|
2016
|
+
return input.order === "asc" ? comparison : comparison * -1;
|
|
1977
2017
|
});
|
|
1978
2018
|
return {
|
|
1979
2019
|
sorted,
|
|
@@ -1999,24 +2039,10 @@ function createArrayGroupByTool() {
|
|
|
1999
2039
|
}).build();
|
|
2000
2040
|
}
|
|
2001
2041
|
function createObjectPickTool() {
|
|
2002
|
-
return toolBuilder().name("object-pick").description("Create a new object with only the specified properties from the source object.").category(ToolCategory.UTILITY).tags(["object", "pick", "data", "transform"]).schema(objectPickSchema).implement(async (input) =>
|
|
2003
|
-
const picked = {};
|
|
2004
|
-
for (const prop of input.properties) {
|
|
2005
|
-
if (prop in input.object) {
|
|
2006
|
-
picked[prop] = input.object[prop];
|
|
2007
|
-
}
|
|
2008
|
-
}
|
|
2009
|
-
return picked;
|
|
2010
|
-
}).build();
|
|
2042
|
+
return toolBuilder().name("object-pick").description("Create a new object with only the specified properties from the source object.").category(ToolCategory.UTILITY).tags(["object", "pick", "data", "transform"]).schema(objectPickSchema).implement(async (input) => pickObjectProperties(input.object, input.properties)).build();
|
|
2011
2043
|
}
|
|
2012
2044
|
function createObjectOmitTool() {
|
|
2013
|
-
return toolBuilder().name("object-omit").description("Create a new object excluding the specified properties from the source object.").category(ToolCategory.UTILITY).tags(["object", "omit", "data", "transform"]).schema(objectOmitSchema).implement(async (input) =>
|
|
2014
|
-
const omitted = { ...input.object };
|
|
2015
|
-
for (const prop of input.properties) {
|
|
2016
|
-
delete omitted[prop];
|
|
2017
|
-
}
|
|
2018
|
-
return omitted;
|
|
2019
|
-
}).build();
|
|
2045
|
+
return toolBuilder().name("object-omit").description("Create a new object excluding the specified properties from the source object.").category(ToolCategory.UTILITY).tags(["object", "omit", "data", "transform"]).schema(objectOmitSchema).implement(async (input) => omitObjectProperties(input.object, input.properties)).build();
|
|
2020
2046
|
}
|
|
2021
2047
|
|
|
2022
2048
|
// src/data/transformer/index.ts
|