@agentforge/tools 0.16.33 → 0.16.35
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 +109 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +116 -106
- package/dist/index.d.ts +116 -106
- package/dist/index.js +107 -39
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -53,7 +53,7 @@ var httpRequestSchema = zod.z.object({
|
|
|
53
53
|
url: zod.z.string().url().describe("The URL to make the request to"),
|
|
54
54
|
method: HttpMethod.default("GET").describe("HTTP method to use"),
|
|
55
55
|
headers: zod.z.record(zod.z.string()).optional().describe("Optional HTTP headers"),
|
|
56
|
-
body: zod.z.
|
|
56
|
+
body: zod.z.unknown().optional().describe("Optional request body (for POST, PUT, PATCH)"),
|
|
57
57
|
timeout: zod.z.number().default(3e4).describe("Request timeout in milliseconds"),
|
|
58
58
|
params: zod.z.record(zod.z.string()).optional().describe("Optional URL query parameters")
|
|
59
59
|
});
|
|
@@ -64,7 +64,7 @@ var httpGetSchema = zod.z.object({
|
|
|
64
64
|
});
|
|
65
65
|
var httpPostSchema = zod.z.object({
|
|
66
66
|
url: zod.z.string().url().describe("The URL to post to"),
|
|
67
|
-
body: zod.z.
|
|
67
|
+
body: zod.z.unknown().describe("The request body (will be sent as JSON)"),
|
|
68
68
|
headers: zod.z.record(zod.z.string()).optional().describe("Optional HTTP headers")
|
|
69
69
|
});
|
|
70
70
|
|
|
@@ -1671,19 +1671,21 @@ var jsonParserSchema = zod.z.object({
|
|
|
1671
1671
|
strict: zod.z.boolean().default(true).describe("Use strict JSON parsing (no trailing commas, etc.)")
|
|
1672
1672
|
});
|
|
1673
1673
|
var jsonStringifySchema = zod.z.object({
|
|
1674
|
-
data: zod.z.
|
|
1674
|
+
data: zod.z.unknown().describe("Data to convert to JSON string"),
|
|
1675
1675
|
pretty: zod.z.boolean().default(false).describe("Format with indentation for readability"),
|
|
1676
1676
|
indent: zod.z.number().default(2).describe("Number of spaces for indentation (when pretty is true)")
|
|
1677
1677
|
});
|
|
1678
1678
|
var jsonQuerySchema = zod.z.object({
|
|
1679
|
-
data: zod.z.
|
|
1679
|
+
data: zod.z.unknown().describe("JSON data to query"),
|
|
1680
1680
|
path: zod.z.string().describe('Dot notation path to query (e.g., "user.name" or "items[0].id")')
|
|
1681
1681
|
});
|
|
1682
1682
|
var jsonValidatorSchema = zod.z.object({
|
|
1683
1683
|
json: zod.z.string().describe("JSON string to validate")
|
|
1684
1684
|
});
|
|
1685
1685
|
var jsonMergeSchema = zod.z.object({
|
|
1686
|
-
objects: zod.z.array(
|
|
1686
|
+
objects: zod.z.array(
|
|
1687
|
+
zod.z.record(zod.z.unknown().describe("Value associated with the object key")).describe("Object to merge")
|
|
1688
|
+
).describe("Array of objects to merge"),
|
|
1687
1689
|
deep: zod.z.boolean().default(false).describe("Perform deep merge (nested objects)")
|
|
1688
1690
|
});
|
|
1689
1691
|
function createJsonParserTool() {
|
|
@@ -1706,18 +1708,33 @@ function createJsonStringifyTool(defaultIndent = 2, defaultPretty = false) {
|
|
|
1706
1708
|
};
|
|
1707
1709
|
}).build();
|
|
1708
1710
|
}
|
|
1711
|
+
function isRecord(value) {
|
|
1712
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1713
|
+
}
|
|
1714
|
+
function getPathValue(current, part) {
|
|
1715
|
+
const arrayMatch = part.match(/^(\w+)\[(\d+)\]$/);
|
|
1716
|
+
if (arrayMatch) {
|
|
1717
|
+
const [, key, index] = arrayMatch;
|
|
1718
|
+
if (!isRecord(current)) {
|
|
1719
|
+
return void 0;
|
|
1720
|
+
}
|
|
1721
|
+
const candidate = current[key];
|
|
1722
|
+
if (!Array.isArray(candidate)) {
|
|
1723
|
+
return void 0;
|
|
1724
|
+
}
|
|
1725
|
+
return candidate[parseInt(index, 10)];
|
|
1726
|
+
}
|
|
1727
|
+
if (!isRecord(current)) {
|
|
1728
|
+
return void 0;
|
|
1729
|
+
}
|
|
1730
|
+
return current[part];
|
|
1731
|
+
}
|
|
1709
1732
|
function createJsonQueryTool() {
|
|
1710
1733
|
return core.toolBuilder().name("json-query").description('Query JSON data using dot notation path (e.g., "user.address.city"). Supports array indexing.').category(core.ToolCategory.UTILITY).tags(["json", "query", "path", "data"]).schema(jsonQuerySchema).implementSafe(async (input) => {
|
|
1711
1734
|
const parts = input.path.split(".");
|
|
1712
1735
|
let current = input.data;
|
|
1713
1736
|
for (const part of parts) {
|
|
1714
|
-
|
|
1715
|
-
if (arrayMatch) {
|
|
1716
|
-
const [, key, index] = arrayMatch;
|
|
1717
|
-
current = current[key][parseInt(index, 10)];
|
|
1718
|
-
} else {
|
|
1719
|
-
current = current[part];
|
|
1720
|
-
}
|
|
1737
|
+
current = getPathValue(current, part);
|
|
1721
1738
|
if (current === void 0) {
|
|
1722
1739
|
throw new Error(`Path not found: ${input.path}`);
|
|
1723
1740
|
}
|
|
@@ -1737,23 +1754,59 @@ function createJsonValidatorTool() {
|
|
|
1737
1754
|
};
|
|
1738
1755
|
}).build();
|
|
1739
1756
|
}
|
|
1757
|
+
function isMergeObject(value) {
|
|
1758
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1759
|
+
}
|
|
1760
|
+
function setMergeProperty(target, key, value) {
|
|
1761
|
+
Object.defineProperty(target, key, {
|
|
1762
|
+
value,
|
|
1763
|
+
enumerable: true,
|
|
1764
|
+
configurable: true,
|
|
1765
|
+
writable: true
|
|
1766
|
+
});
|
|
1767
|
+
}
|
|
1768
|
+
function cloneMergeObject(source) {
|
|
1769
|
+
const output = {};
|
|
1770
|
+
for (const [key, value] of Object.entries(source)) {
|
|
1771
|
+
if (isMergeObject(value)) {
|
|
1772
|
+
setMergeProperty(output, key, cloneMergeObject(value));
|
|
1773
|
+
continue;
|
|
1774
|
+
}
|
|
1775
|
+
setMergeProperty(output, key, value);
|
|
1776
|
+
}
|
|
1777
|
+
return output;
|
|
1778
|
+
}
|
|
1779
|
+
function deepMerge(target, source) {
|
|
1780
|
+
const output = cloneMergeObject(target);
|
|
1781
|
+
for (const [key, sourceValue] of Object.entries(source)) {
|
|
1782
|
+
const targetValue = output[key];
|
|
1783
|
+
if (isMergeObject(sourceValue) && isMergeObject(targetValue)) {
|
|
1784
|
+
setMergeProperty(output, key, deepMerge(targetValue, sourceValue));
|
|
1785
|
+
continue;
|
|
1786
|
+
}
|
|
1787
|
+
if (isMergeObject(sourceValue)) {
|
|
1788
|
+
setMergeProperty(output, key, cloneMergeObject(sourceValue));
|
|
1789
|
+
continue;
|
|
1790
|
+
}
|
|
1791
|
+
setMergeProperty(output, key, sourceValue);
|
|
1792
|
+
}
|
|
1793
|
+
return output;
|
|
1794
|
+
}
|
|
1795
|
+
function shallowMerge(objects) {
|
|
1796
|
+
const output = {};
|
|
1797
|
+
for (const object of objects) {
|
|
1798
|
+
for (const [key, value] of Object.entries(object)) {
|
|
1799
|
+
setMergeProperty(output, key, value);
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
return output;
|
|
1803
|
+
}
|
|
1740
1804
|
function createJsonMergeTool() {
|
|
1741
1805
|
return core.toolBuilder().name("json-merge").description("Merge two or more JSON objects. Later objects override earlier ones for conflicting keys.").category(core.ToolCategory.UTILITY).tags(["json", "merge", "combine", "data"]).schema(jsonMergeSchema).implement(async (input) => {
|
|
1742
1806
|
if (input.deep) {
|
|
1743
|
-
const deepMerge = (target, source) => {
|
|
1744
|
-
const output = { ...target };
|
|
1745
|
-
for (const key in source) {
|
|
1746
|
-
if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key])) {
|
|
1747
|
-
output[key] = deepMerge(output[key] || {}, source[key]);
|
|
1748
|
-
} else {
|
|
1749
|
-
output[key] = source[key];
|
|
1750
|
-
}
|
|
1751
|
-
}
|
|
1752
|
-
return output;
|
|
1753
|
-
};
|
|
1754
1807
|
return input.objects.reduce((acc, obj) => deepMerge(acc, obj), {});
|
|
1755
1808
|
} else {
|
|
1756
|
-
return
|
|
1809
|
+
return shallowMerge(input.objects);
|
|
1757
1810
|
}
|
|
1758
1811
|
}).build();
|
|
1759
1812
|
}
|
|
@@ -1914,31 +1967,34 @@ function createXmlTools(config = {}) {
|
|
|
1914
1967
|
createJsonToXmlTool(defaultRootName, defaultFormat)
|
|
1915
1968
|
];
|
|
1916
1969
|
}
|
|
1970
|
+
var transformerValueSchema = zod.z.unknown().describe("Transformer value");
|
|
1971
|
+
var transformerArraySchema = zod.z.array(transformerValueSchema).describe("Array to transform");
|
|
1972
|
+
var transformerObjectSchema = zod.z.record(zod.z.string(), transformerValueSchema).describe("Source object");
|
|
1917
1973
|
var arrayFilterSchema = zod.z.object({
|
|
1918
|
-
array:
|
|
1974
|
+
array: transformerArraySchema.describe("Array to filter"),
|
|
1919
1975
|
property: zod.z.string().describe("Property name to filter by (use dot notation for nested properties)"),
|
|
1920
1976
|
operator: zod.z.enum(["equals", "not-equals", "greater-than", "less-than", "contains", "starts-with", "ends-with"]).describe("Comparison operator"),
|
|
1921
|
-
value:
|
|
1977
|
+
value: transformerValueSchema.describe("Value to compare against")
|
|
1922
1978
|
});
|
|
1923
1979
|
var arrayMapSchema = zod.z.object({
|
|
1924
|
-
array:
|
|
1980
|
+
array: transformerArraySchema.describe("Array to map"),
|
|
1925
1981
|
properties: zod.z.array(zod.z.string().describe("String value")).describe("List of property names to extract from each object")
|
|
1926
1982
|
});
|
|
1927
1983
|
var arraySortSchema = zod.z.object({
|
|
1928
|
-
array:
|
|
1984
|
+
array: transformerArraySchema.describe("Array to sort"),
|
|
1929
1985
|
property: zod.z.string().describe("Property name to sort by (use dot notation for nested properties)"),
|
|
1930
1986
|
order: zod.z.enum(["asc", "desc"]).default("asc").describe("Sort order: ascending or descending")
|
|
1931
1987
|
});
|
|
1932
1988
|
var arrayGroupBySchema = zod.z.object({
|
|
1933
|
-
array:
|
|
1989
|
+
array: transformerArraySchema.describe("Array to group"),
|
|
1934
1990
|
property: zod.z.string().describe("Property name to group by")
|
|
1935
1991
|
});
|
|
1936
1992
|
var objectPickSchema = zod.z.object({
|
|
1937
|
-
object:
|
|
1993
|
+
object: transformerObjectSchema,
|
|
1938
1994
|
properties: zod.z.array(zod.z.string().describe("String value")).describe("List of property names to pick")
|
|
1939
1995
|
});
|
|
1940
1996
|
var objectOmitSchema = zod.z.object({
|
|
1941
|
-
object:
|
|
1997
|
+
object: transformerObjectSchema,
|
|
1942
1998
|
properties: zod.z.array(zod.z.string().describe("String value")).describe("List of property names to omit")
|
|
1943
1999
|
});
|
|
1944
2000
|
|
|
@@ -2020,8 +2076,12 @@ function createArrayMapTool() {
|
|
|
2020
2076
|
const mapped = input.array.map((item) => {
|
|
2021
2077
|
const result = {};
|
|
2022
2078
|
for (const prop of input.properties) {
|
|
2023
|
-
|
|
2024
|
-
|
|
2079
|
+
Object.defineProperty(result, prop, {
|
|
2080
|
+
value: getNestedValue(item, prop),
|
|
2081
|
+
enumerable: true,
|
|
2082
|
+
configurable: true,
|
|
2083
|
+
writable: true
|
|
2084
|
+
});
|
|
2025
2085
|
}
|
|
2026
2086
|
return result;
|
|
2027
2087
|
});
|
|
@@ -2052,9 +2112,17 @@ function createArrayGroupByTool() {
|
|
|
2052
2112
|
return core.toolBuilder().name("array-group-by").description("Group an array of objects by a property value. Returns an object with groups as keys.").category(core.ToolCategory.UTILITY).tags(["array", "group", "data", "transform"]).schema(arrayGroupBySchema).implement(async (input) => {
|
|
2053
2113
|
const groups = {};
|
|
2054
2114
|
for (const item of input.array) {
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2115
|
+
if (item == null) {
|
|
2116
|
+
throw new TypeError(`Cannot read properties of ${item} (reading '${input.property}')`);
|
|
2117
|
+
}
|
|
2118
|
+
const key = String(Reflect.get(Object(item), input.property));
|
|
2119
|
+
if (!Object.hasOwn(groups, key)) {
|
|
2120
|
+
Object.defineProperty(groups, key, {
|
|
2121
|
+
value: [],
|
|
2122
|
+
enumerable: true,
|
|
2123
|
+
configurable: true,
|
|
2124
|
+
writable: true
|
|
2125
|
+
});
|
|
2058
2126
|
}
|
|
2059
2127
|
groups[key].push(item);
|
|
2060
2128
|
}
|
|
@@ -10162,11 +10230,11 @@ var AskHumanInputSchema = zod.z.object({
|
|
|
10162
10230
|
});
|
|
10163
10231
|
var logLevel3 = process.env.LOG_LEVEL?.toLowerCase() || core.LogLevel.INFO;
|
|
10164
10232
|
var logger22 = core.createLogger("agentforge:tools:agent:ask-human", { level: logLevel3 });
|
|
10165
|
-
function
|
|
10233
|
+
function isRecord2(value) {
|
|
10166
10234
|
return typeof value === "object" && value !== null;
|
|
10167
10235
|
}
|
|
10168
10236
|
function resolveInterrupt(module) {
|
|
10169
|
-
if (!
|
|
10237
|
+
if (!isRecord2(module)) {
|
|
10170
10238
|
return void 0;
|
|
10171
10239
|
}
|
|
10172
10240
|
const candidate = module.interrupt;
|
|
@@ -10584,7 +10652,10 @@ exports.stringSplit = stringSplit;
|
|
|
10584
10652
|
exports.stringSubstring = stringSubstring;
|
|
10585
10653
|
exports.stringTrim = stringTrim;
|
|
10586
10654
|
exports.stringUtilityTools = stringUtilityTools;
|
|
10655
|
+
exports.transformerArraySchema = transformerArraySchema;
|
|
10656
|
+
exports.transformerObjectSchema = transformerObjectSchema;
|
|
10587
10657
|
exports.transformerTools = transformerTools;
|
|
10658
|
+
exports.transformerValueSchema = transformerValueSchema;
|
|
10588
10659
|
exports.updateConfluencePage = updateConfluencePage;
|
|
10589
10660
|
exports.urlBuilder = urlBuilder;
|
|
10590
10661
|
exports.urlBuilderSchema = urlBuilderSchema;
|