@agentforge/tools 0.16.34 → 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 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.any().optional().describe("Optional request body (for POST, PUT, PATCH)"),
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.any().describe("The request body (will be sent as JSON)"),
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.any().describe("Data to convert to JSON string"),
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.any().describe("JSON data to query"),
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(zod.z.any().describe("Object to merge")).describe("Array of objects to merge"),
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
- const arrayMatch = part.match(/^(\w+)\[(\d+)\]$/);
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 Object.assign({}, ...input.objects);
1809
+ return shallowMerge(input.objects);
1757
1810
  }
1758
1811
  }).build();
1759
1812
  }
@@ -10177,11 +10230,11 @@ var AskHumanInputSchema = zod.z.object({
10177
10230
  });
10178
10231
  var logLevel3 = process.env.LOG_LEVEL?.toLowerCase() || core.LogLevel.INFO;
10179
10232
  var logger22 = core.createLogger("agentforge:tools:agent:ask-human", { level: logLevel3 });
10180
- function isRecord(value) {
10233
+ function isRecord2(value) {
10181
10234
  return typeof value === "object" && value !== null;
10182
10235
  }
10183
10236
  function resolveInterrupt(module) {
10184
- if (!isRecord(module)) {
10237
+ if (!isRecord2(module)) {
10185
10238
  return void 0;
10186
10239
  }
10187
10240
  const candidate = module.interrupt;