@agentforge/tools 0.16.79 → 0.16.81

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/README.md CHANGED
@@ -225,6 +225,21 @@ const safeDirectoryTools = createDirectoryOperationTools({ policy });
225
225
 
226
226
  The policy rejects `..` traversal, resolved symlink escapes, paths outside configured roots, and recursive deletion of a configured root. Use `allowedRoots` for multiple roots. Keep the default unrestricted exports for trusted local automation only; `allowOutsideRoots: true` is an explicit privileged opt-out when a configured factory must access the wider host filesystem. The `file-exists` tool preserves its legacy result shape for successful and missing-path checks, while policy violations return `{ success: false, error }`. Detailed `directory-list` results use non-following `lstat` metadata for symlink entries under both default and confined policies.
227
227
 
228
+ For the recommended model-exposed setup, use the combined preset. It requires a workspace or allowed root, applies the same root confinement to all file and directory tools, and retains the web policy's localhost, private-network, link-local, metadata, and redirect checks:
229
+
230
+ ```typescript
231
+ import { createModelSafeToolPreset } from '@agentforge/tools';
232
+
233
+ const { tools } = createModelSafeToolPreset({
234
+ fileSystem: { workspaceRoot: process.cwd() },
235
+ web: { http: { defaultTimeout: 15000 } },
236
+ });
237
+
238
+ const agentTools = tools;
239
+ ```
240
+
241
+ The preset deliberately ignores privileged filesystem and network opt-ins such as `allowOutsideRoots` and `allowPrivateNetwork`. Use the existing standalone factories for trusted operator-controlled automation that needs those capabilities.
242
+
228
243
  ### Utility Tools (22 tools)
229
244
 
230
245
  General utility tools for common operations.
package/dist/index.cjs CHANGED
@@ -70,6 +70,8 @@ var DestinationPolicyError = class extends Error {
70
70
  this.reason = reason;
71
71
  this.name = "DestinationPolicyError";
72
72
  }
73
+ url;
74
+ reason;
73
75
  code = "WEB_DESTINATION_BLOCKED";
74
76
  };
75
77
  function ipv4ToNumber(address) {
@@ -4158,6 +4160,8 @@ For more information, see the @agentforge/tools documentation.`
4158
4160
  this.name = "MissingPeerDependencyError";
4159
4161
  Object.setPrototypeOf(this, _MissingPeerDependencyError.prototype);
4160
4162
  }
4163
+ vendor;
4164
+ packageName;
4161
4165
  };
4162
4166
  function isPeerDependencyAvailable(packageName) {
4163
4167
  try {
@@ -6846,6 +6850,8 @@ var SchemaInspector = class _SchemaInspector {
6846
6850
  this.cacheTtlMs = config?.cacheTtlMs ?? DEFAULT_CACHE_TTL_MS;
6847
6851
  this.cacheKey = config?.cacheKey;
6848
6852
  }
6853
+ manager;
6854
+ vendor;
6849
6855
  cacheTtlMs;
6850
6856
  cacheKey;
6851
6857
  static clearCache(cacheKey) {
@@ -9362,6 +9368,8 @@ var FileSystemPolicyError = class extends Error {
9362
9368
  this.inputPath = inputPath;
9363
9369
  this.name = "FileSystemPolicyError";
9364
9370
  }
9371
+ operation;
9372
+ inputPath;
9365
9373
  code = "FILE_SYSTEM_POLICY_VIOLATION";
9366
9374
  };
9367
9375
  function containsTraversal(inputPath) {
@@ -9877,6 +9885,44 @@ function createPathUtilityTools(config = {}) {
9877
9885
  createPathNormalizeTool()
9878
9886
  ];
9879
9887
  }
9888
+
9889
+ // src/model-safe.ts
9890
+ function requireFilesystemRoot(options) {
9891
+ if (!options?.workspaceRoot && !options?.allowedRoots?.length) {
9892
+ throw new Error("Model-safe tool preset requires workspaceRoot or allowedRoots");
9893
+ }
9894
+ return {
9895
+ ...options,
9896
+ allowOutsideRoots: false,
9897
+ allowRootDeletion: false
9898
+ };
9899
+ }
9900
+ function modelSafeDestinationPolicy(policy = {}) {
9901
+ return {
9902
+ ...DEFAULT_DESTINATION_POLICY,
9903
+ ...policy,
9904
+ allowLocalhost: false,
9905
+ allowPrivateNetwork: false,
9906
+ allowLinkLocal: false,
9907
+ allowMetadata: false
9908
+ };
9909
+ }
9910
+ function createModelSafeToolPreset(options = {}) {
9911
+ const fileSystemPolicy = createFileSystemPolicy(requireFilesystemRoot(options.fileSystem));
9912
+ const destinationPolicy = modelSafeDestinationPolicy(options.web?.destinationPolicy);
9913
+ const fileTools = createFileOperationTools({ ...options.file, policy: fileSystemPolicy });
9914
+ const directoryTools = createDirectoryOperationTools({ ...options.directory, policy: fileSystemPolicy });
9915
+ const webTools = [
9916
+ ...createHttpTools({ ...options.web?.http, destinationPolicy }),
9917
+ ...createScraperTools({ ...options.web?.scraper, destinationPolicy })
9918
+ ];
9919
+ return {
9920
+ fileTools,
9921
+ directoryTools,
9922
+ webTools,
9923
+ tools: [...fileTools, ...directoryTools, ...webTools]
9924
+ };
9925
+ }
9880
9926
  var CurrentDateTimeSchema = zod.z.object({
9881
9927
  format: zod.z.enum(["iso", "unix", "custom"]).default("iso").describe("Output format"),
9882
9928
  customFormat: zod.z.string().optional().describe('Custom format string (e.g., "yyyy-MM-dd HH:mm:ss") when format is "custom"'),
@@ -10848,6 +10894,7 @@ exports.createJsonTools = createJsonTools;
10848
10894
  exports.createJsonValidatorTool = createJsonValidatorTool;
10849
10895
  exports.createMathFunctionsTool = createMathFunctionsTool;
10850
10896
  exports.createMathOperationTools = createMathOperationTools;
10897
+ exports.createModelSafeToolPreset = createModelSafeToolPreset;
10851
10898
  exports.createNeo4jCreateNodeWithEmbeddingTool = createNeo4jCreateNodeWithEmbeddingTool;
10852
10899
  exports.createNeo4jFindNodesTool = createNeo4jFindNodesTool;
10853
10900
  exports.createNeo4jGetSchemaTool = createNeo4jGetSchemaTool;