@agentforge/tools 0.16.78 → 0.16.80
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 +15 -0
- package/dist/index.cjs +39 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -1
- package/dist/index.d.ts +29 -1
- package/dist/index.js +39 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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
|
@@ -9877,6 +9877,44 @@ function createPathUtilityTools(config = {}) {
|
|
|
9877
9877
|
createPathNormalizeTool()
|
|
9878
9878
|
];
|
|
9879
9879
|
}
|
|
9880
|
+
|
|
9881
|
+
// src/model-safe.ts
|
|
9882
|
+
function requireFilesystemRoot(options) {
|
|
9883
|
+
if (!options?.workspaceRoot && !options?.allowedRoots?.length) {
|
|
9884
|
+
throw new Error("Model-safe tool preset requires workspaceRoot or allowedRoots");
|
|
9885
|
+
}
|
|
9886
|
+
return {
|
|
9887
|
+
...options,
|
|
9888
|
+
allowOutsideRoots: false,
|
|
9889
|
+
allowRootDeletion: false
|
|
9890
|
+
};
|
|
9891
|
+
}
|
|
9892
|
+
function modelSafeDestinationPolicy(policy = {}) {
|
|
9893
|
+
return {
|
|
9894
|
+
...DEFAULT_DESTINATION_POLICY,
|
|
9895
|
+
...policy,
|
|
9896
|
+
allowLocalhost: false,
|
|
9897
|
+
allowPrivateNetwork: false,
|
|
9898
|
+
allowLinkLocal: false,
|
|
9899
|
+
allowMetadata: false
|
|
9900
|
+
};
|
|
9901
|
+
}
|
|
9902
|
+
function createModelSafeToolPreset(options = {}) {
|
|
9903
|
+
const fileSystemPolicy = createFileSystemPolicy(requireFilesystemRoot(options.fileSystem));
|
|
9904
|
+
const destinationPolicy = modelSafeDestinationPolicy(options.web?.destinationPolicy);
|
|
9905
|
+
const fileTools = createFileOperationTools({ ...options.file, policy: fileSystemPolicy });
|
|
9906
|
+
const directoryTools = createDirectoryOperationTools({ ...options.directory, policy: fileSystemPolicy });
|
|
9907
|
+
const webTools = [
|
|
9908
|
+
...createHttpTools({ ...options.web?.http, destinationPolicy }),
|
|
9909
|
+
...createScraperTools({ ...options.web?.scraper, destinationPolicy })
|
|
9910
|
+
];
|
|
9911
|
+
return {
|
|
9912
|
+
fileTools,
|
|
9913
|
+
directoryTools,
|
|
9914
|
+
webTools,
|
|
9915
|
+
tools: [...fileTools, ...directoryTools, ...webTools]
|
|
9916
|
+
};
|
|
9917
|
+
}
|
|
9880
9918
|
var CurrentDateTimeSchema = zod.z.object({
|
|
9881
9919
|
format: zod.z.enum(["iso", "unix", "custom"]).default("iso").describe("Output format"),
|
|
9882
9920
|
customFormat: zod.z.string().optional().describe('Custom format string (e.g., "yyyy-MM-dd HH:mm:ss") when format is "custom"'),
|
|
@@ -10848,6 +10886,7 @@ exports.createJsonTools = createJsonTools;
|
|
|
10848
10886
|
exports.createJsonValidatorTool = createJsonValidatorTool;
|
|
10849
10887
|
exports.createMathFunctionsTool = createMathFunctionsTool;
|
|
10850
10888
|
exports.createMathOperationTools = createMathOperationTools;
|
|
10889
|
+
exports.createModelSafeToolPreset = createModelSafeToolPreset;
|
|
10851
10890
|
exports.createNeo4jCreateNodeWithEmbeddingTool = createNeo4jCreateNodeWithEmbeddingTool;
|
|
10852
10891
|
exports.createNeo4jFindNodesTool = createNeo4jFindNodesTool;
|
|
10853
10892
|
exports.createNeo4jGetSchemaTool = createNeo4jGetSchemaTool;
|