@dexto/tools-filesystem 1.5.3 → 1.5.4
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/filesystem-service.cjs +7 -0
- package/dist/filesystem-service.d.cts +5 -0
- package/dist/filesystem-service.d.ts +5 -0
- package/dist/filesystem-service.js +7 -0
- package/dist/glob-files-tool.cjs +56 -3
- package/dist/glob-files-tool.d.cts +4 -3
- package/dist/glob-files-tool.d.ts +4 -3
- package/dist/glob-files-tool.js +46 -3
- package/dist/grep-content-tool.cjs +55 -3
- package/dist/grep-content-tool.d.cts +4 -3
- package/dist/grep-content-tool.d.ts +4 -3
- package/dist/grep-content-tool.js +45 -3
- package/dist/tool-provider.cjs +2 -2
- package/dist/tool-provider.js +2 -2
- package/package.json +2 -2
|
@@ -66,6 +66,13 @@ class FileSystemService {
|
|
|
66
66
|
getBackupDir() {
|
|
67
67
|
return this.config.backupPath || (0, import_core.getDextoPath)("backups");
|
|
68
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Get the effective working directory for file operations.
|
|
71
|
+
* Falls back to process.cwd() if not configured.
|
|
72
|
+
*/
|
|
73
|
+
getWorkingDirectory() {
|
|
74
|
+
return this.config.workingDirectory || process.cwd();
|
|
75
|
+
}
|
|
69
76
|
/**
|
|
70
77
|
* Initialize the service.
|
|
71
78
|
* Safe to call multiple times - subsequent calls return the same promise.
|
|
@@ -36,6 +36,11 @@ declare class FileSystemService {
|
|
|
36
36
|
* TODO: Migrate to explicit configuration via CLI enrichment layer (per-agent paths)
|
|
37
37
|
*/
|
|
38
38
|
private getBackupDir;
|
|
39
|
+
/**
|
|
40
|
+
* Get the effective working directory for file operations.
|
|
41
|
+
* Falls back to process.cwd() if not configured.
|
|
42
|
+
*/
|
|
43
|
+
getWorkingDirectory(): string;
|
|
39
44
|
/**
|
|
40
45
|
* Initialize the service.
|
|
41
46
|
* Safe to call multiple times - subsequent calls return the same promise.
|
|
@@ -36,6 +36,11 @@ declare class FileSystemService {
|
|
|
36
36
|
* TODO: Migrate to explicit configuration via CLI enrichment layer (per-agent paths)
|
|
37
37
|
*/
|
|
38
38
|
private getBackupDir;
|
|
39
|
+
/**
|
|
40
|
+
* Get the effective working directory for file operations.
|
|
41
|
+
* Falls back to process.cwd() if not configured.
|
|
42
|
+
*/
|
|
43
|
+
getWorkingDirectory(): string;
|
|
39
44
|
/**
|
|
40
45
|
* Initialize the service.
|
|
41
46
|
* Safe to call multiple times - subsequent calls return the same promise.
|
|
@@ -33,6 +33,13 @@ class FileSystemService {
|
|
|
33
33
|
getBackupDir() {
|
|
34
34
|
return this.config.backupPath || getDextoPath("backups");
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Get the effective working directory for file operations.
|
|
38
|
+
* Falls back to process.cwd() if not configured.
|
|
39
|
+
*/
|
|
40
|
+
getWorkingDirectory() {
|
|
41
|
+
return this.config.workingDirectory || process.cwd();
|
|
42
|
+
}
|
|
36
43
|
/**
|
|
37
44
|
* Initialize the service.
|
|
38
45
|
* Safe to call multiple times - subsequent calls return the same promise.
|
package/dist/glob-files-tool.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,27 +17,78 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var glob_files_tool_exports = {};
|
|
20
30
|
__export(glob_files_tool_exports, {
|
|
21
31
|
createGlobFilesTool: () => createGlobFilesTool
|
|
22
32
|
});
|
|
23
33
|
module.exports = __toCommonJS(glob_files_tool_exports);
|
|
34
|
+
var path = __toESM(require("node:path"), 1);
|
|
24
35
|
var import_zod = require("zod");
|
|
36
|
+
var import_core = require("@dexto/core");
|
|
25
37
|
const GlobFilesInputSchema = import_zod.z.object({
|
|
26
38
|
pattern: import_zod.z.string().describe('Glob pattern to match files (e.g., "**/*.ts", "src/**/*.js")'),
|
|
27
39
|
path: import_zod.z.string().optional().describe("Base directory to search from (defaults to working directory)"),
|
|
28
40
|
max_results: import_zod.z.number().int().positive().optional().default(1e3).describe("Maximum number of results to return (default: 1000)")
|
|
29
41
|
}).strict();
|
|
30
|
-
function createGlobFilesTool(
|
|
42
|
+
function createGlobFilesTool(options) {
|
|
43
|
+
const { fileSystemService, directoryApproval } = options;
|
|
44
|
+
let pendingApprovalSearchDir;
|
|
31
45
|
return {
|
|
32
46
|
id: "glob_files",
|
|
33
47
|
description: "Find files matching a glob pattern. Supports standard glob syntax like **/*.js for recursive matches, *.ts for files in current directory, and src/**/*.tsx for nested paths. Returns array of file paths with metadata (size, modified date). Results are limited to allowed paths only.",
|
|
34
48
|
inputSchema: GlobFilesInputSchema,
|
|
49
|
+
/**
|
|
50
|
+
* Check if this glob operation needs directory access approval.
|
|
51
|
+
* Returns custom approval request if the search directory is outside allowed paths.
|
|
52
|
+
*/
|
|
53
|
+
getApprovalOverride: async (args) => {
|
|
54
|
+
const { path: searchPath } = args;
|
|
55
|
+
const baseDir = fileSystemService.getWorkingDirectory();
|
|
56
|
+
const searchDir = path.resolve(baseDir, searchPath || ".");
|
|
57
|
+
const isAllowed = await fileSystemService.isPathWithinConfigAllowed(searchDir);
|
|
58
|
+
if (isAllowed) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
if (directoryApproval?.isSessionApproved(searchDir)) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
pendingApprovalSearchDir = searchDir;
|
|
65
|
+
return {
|
|
66
|
+
type: import_core.ApprovalType.DIRECTORY_ACCESS,
|
|
67
|
+
metadata: {
|
|
68
|
+
path: searchDir,
|
|
69
|
+
parentDir: searchDir,
|
|
70
|
+
operation: "search",
|
|
71
|
+
toolName: "glob_files"
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
/**
|
|
76
|
+
* Handle approved directory access - remember the directory for session
|
|
77
|
+
*/
|
|
78
|
+
onApprovalGranted: (response) => {
|
|
79
|
+
if (!directoryApproval || !pendingApprovalSearchDir) return;
|
|
80
|
+
const data = response.data;
|
|
81
|
+
const rememberDirectory = data?.rememberDirectory ?? false;
|
|
82
|
+
directoryApproval.addApproved(
|
|
83
|
+
pendingApprovalSearchDir,
|
|
84
|
+
rememberDirectory ? "session" : "once"
|
|
85
|
+
);
|
|
86
|
+
pendingApprovalSearchDir = void 0;
|
|
87
|
+
},
|
|
35
88
|
execute: async (input, _context) => {
|
|
36
|
-
const { pattern, path, max_results } = input;
|
|
89
|
+
const { pattern, path: path2, max_results } = input;
|
|
37
90
|
const result = await fileSystemService.globFiles(pattern, {
|
|
38
|
-
cwd:
|
|
91
|
+
cwd: path2,
|
|
39
92
|
maxResults: max_results,
|
|
40
93
|
includeMetadata: true
|
|
41
94
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InternalTool } from '@dexto/core';
|
|
2
|
-
import {
|
|
2
|
+
import { FileToolOptions } from './file-tool-types.cjs';
|
|
3
|
+
import './filesystem-service.cjs';
|
|
3
4
|
import './types.cjs';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -9,8 +10,8 @@ import './types.cjs';
|
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
|
-
* Create the glob_files internal tool
|
|
13
|
+
* Create the glob_files internal tool with directory approval support
|
|
13
14
|
*/
|
|
14
|
-
declare function createGlobFilesTool(
|
|
15
|
+
declare function createGlobFilesTool(options: FileToolOptions): InternalTool;
|
|
15
16
|
|
|
16
17
|
export { createGlobFilesTool };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InternalTool } from '@dexto/core';
|
|
2
|
-
import {
|
|
2
|
+
import { FileToolOptions } from './file-tool-types.js';
|
|
3
|
+
import './filesystem-service.js';
|
|
3
4
|
import './types.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -9,8 +10,8 @@ import './types.js';
|
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
|
-
* Create the glob_files internal tool
|
|
13
|
+
* Create the glob_files internal tool with directory approval support
|
|
13
14
|
*/
|
|
14
|
-
declare function createGlobFilesTool(
|
|
15
|
+
declare function createGlobFilesTool(options: FileToolOptions): InternalTool;
|
|
15
16
|
|
|
16
17
|
export { createGlobFilesTool };
|
package/dist/glob-files-tool.js
CHANGED
|
@@ -1,18 +1,61 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
1
2
|
import { z } from "zod";
|
|
3
|
+
import { ApprovalType } from "@dexto/core";
|
|
2
4
|
const GlobFilesInputSchema = z.object({
|
|
3
5
|
pattern: z.string().describe('Glob pattern to match files (e.g., "**/*.ts", "src/**/*.js")'),
|
|
4
6
|
path: z.string().optional().describe("Base directory to search from (defaults to working directory)"),
|
|
5
7
|
max_results: z.number().int().positive().optional().default(1e3).describe("Maximum number of results to return (default: 1000)")
|
|
6
8
|
}).strict();
|
|
7
|
-
function createGlobFilesTool(
|
|
9
|
+
function createGlobFilesTool(options) {
|
|
10
|
+
const { fileSystemService, directoryApproval } = options;
|
|
11
|
+
let pendingApprovalSearchDir;
|
|
8
12
|
return {
|
|
9
13
|
id: "glob_files",
|
|
10
14
|
description: "Find files matching a glob pattern. Supports standard glob syntax like **/*.js for recursive matches, *.ts for files in current directory, and src/**/*.tsx for nested paths. Returns array of file paths with metadata (size, modified date). Results are limited to allowed paths only.",
|
|
11
15
|
inputSchema: GlobFilesInputSchema,
|
|
16
|
+
/**
|
|
17
|
+
* Check if this glob operation needs directory access approval.
|
|
18
|
+
* Returns custom approval request if the search directory is outside allowed paths.
|
|
19
|
+
*/
|
|
20
|
+
getApprovalOverride: async (args) => {
|
|
21
|
+
const { path: searchPath } = args;
|
|
22
|
+
const baseDir = fileSystemService.getWorkingDirectory();
|
|
23
|
+
const searchDir = path.resolve(baseDir, searchPath || ".");
|
|
24
|
+
const isAllowed = await fileSystemService.isPathWithinConfigAllowed(searchDir);
|
|
25
|
+
if (isAllowed) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
if (directoryApproval?.isSessionApproved(searchDir)) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
pendingApprovalSearchDir = searchDir;
|
|
32
|
+
return {
|
|
33
|
+
type: ApprovalType.DIRECTORY_ACCESS,
|
|
34
|
+
metadata: {
|
|
35
|
+
path: searchDir,
|
|
36
|
+
parentDir: searchDir,
|
|
37
|
+
operation: "search",
|
|
38
|
+
toolName: "glob_files"
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Handle approved directory access - remember the directory for session
|
|
44
|
+
*/
|
|
45
|
+
onApprovalGranted: (response) => {
|
|
46
|
+
if (!directoryApproval || !pendingApprovalSearchDir) return;
|
|
47
|
+
const data = response.data;
|
|
48
|
+
const rememberDirectory = data?.rememberDirectory ?? false;
|
|
49
|
+
directoryApproval.addApproved(
|
|
50
|
+
pendingApprovalSearchDir,
|
|
51
|
+
rememberDirectory ? "session" : "once"
|
|
52
|
+
);
|
|
53
|
+
pendingApprovalSearchDir = void 0;
|
|
54
|
+
},
|
|
12
55
|
execute: async (input, _context) => {
|
|
13
|
-
const { pattern, path, max_results } = input;
|
|
56
|
+
const { pattern, path: path2, max_results } = input;
|
|
14
57
|
const result = await fileSystemService.globFiles(pattern, {
|
|
15
|
-
cwd:
|
|
58
|
+
cwd: path2,
|
|
16
59
|
maxResults: max_results,
|
|
17
60
|
includeMetadata: true
|
|
18
61
|
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,13 +17,23 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var grep_content_tool_exports = {};
|
|
20
30
|
__export(grep_content_tool_exports, {
|
|
21
31
|
createGrepContentTool: () => createGrepContentTool
|
|
22
32
|
});
|
|
23
33
|
module.exports = __toCommonJS(grep_content_tool_exports);
|
|
34
|
+
var path = __toESM(require("node:path"), 1);
|
|
24
35
|
var import_zod = require("zod");
|
|
36
|
+
var import_core = require("@dexto/core");
|
|
25
37
|
const GrepContentInputSchema = import_zod.z.object({
|
|
26
38
|
pattern: import_zod.z.string().describe("Regular expression pattern to search for"),
|
|
27
39
|
path: import_zod.z.string().optional().describe("Directory to search in (defaults to working directory)"),
|
|
@@ -32,15 +44,55 @@ const GrepContentInputSchema = import_zod.z.object({
|
|
|
32
44
|
case_insensitive: import_zod.z.boolean().optional().default(false).describe("Perform case-insensitive search (default: false)"),
|
|
33
45
|
max_results: import_zod.z.number().int().positive().optional().default(100).describe("Maximum number of results to return (default: 100)")
|
|
34
46
|
}).strict();
|
|
35
|
-
function createGrepContentTool(
|
|
47
|
+
function createGrepContentTool(options) {
|
|
48
|
+
const { fileSystemService, directoryApproval } = options;
|
|
49
|
+
let pendingApprovalSearchDir;
|
|
36
50
|
return {
|
|
37
51
|
id: "grep_content",
|
|
38
52
|
description: 'Search for text patterns in files using regular expressions. Returns matching lines with file path, line number, and optional context lines. Use glob parameter to filter specific file types (e.g., "*.ts"). Supports case-insensitive search. Great for finding code patterns, function definitions, or specific text across multiple files.',
|
|
39
53
|
inputSchema: GrepContentInputSchema,
|
|
54
|
+
/**
|
|
55
|
+
* Check if this grep operation needs directory access approval.
|
|
56
|
+
* Returns custom approval request if the search directory is outside allowed paths.
|
|
57
|
+
*/
|
|
58
|
+
getApprovalOverride: async (args) => {
|
|
59
|
+
const { path: searchPath } = args;
|
|
60
|
+
const searchDir = path.resolve(searchPath || process.cwd());
|
|
61
|
+
const isAllowed = await fileSystemService.isPathWithinConfigAllowed(searchDir);
|
|
62
|
+
if (isAllowed) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
if (directoryApproval?.isSessionApproved(searchDir)) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
pendingApprovalSearchDir = searchDir;
|
|
69
|
+
return {
|
|
70
|
+
type: import_core.ApprovalType.DIRECTORY_ACCESS,
|
|
71
|
+
metadata: {
|
|
72
|
+
path: searchDir,
|
|
73
|
+
parentDir: searchDir,
|
|
74
|
+
operation: "search",
|
|
75
|
+
toolName: "grep_content"
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
/**
|
|
80
|
+
* Handle approved directory access - remember the directory for session
|
|
81
|
+
*/
|
|
82
|
+
onApprovalGranted: (response) => {
|
|
83
|
+
if (!directoryApproval || !pendingApprovalSearchDir) return;
|
|
84
|
+
const data = response.data;
|
|
85
|
+
const rememberDirectory = data?.rememberDirectory ?? false;
|
|
86
|
+
directoryApproval.addApproved(
|
|
87
|
+
pendingApprovalSearchDir,
|
|
88
|
+
rememberDirectory ? "session" : "once"
|
|
89
|
+
);
|
|
90
|
+
pendingApprovalSearchDir = void 0;
|
|
91
|
+
},
|
|
40
92
|
execute: async (input, _context) => {
|
|
41
|
-
const { pattern, path, glob, context_lines, case_insensitive, max_results } = input;
|
|
93
|
+
const { pattern, path: path2, glob, context_lines, case_insensitive, max_results } = input;
|
|
42
94
|
const result = await fileSystemService.searchContent(pattern, {
|
|
43
|
-
path,
|
|
95
|
+
path: path2,
|
|
44
96
|
glob,
|
|
45
97
|
contextLines: context_lines,
|
|
46
98
|
caseInsensitive: case_insensitive,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InternalTool } from '@dexto/core';
|
|
2
|
-
import {
|
|
2
|
+
import { FileToolOptions } from './file-tool-types.cjs';
|
|
3
|
+
import './filesystem-service.cjs';
|
|
3
4
|
import './types.cjs';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -9,8 +10,8 @@ import './types.cjs';
|
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
|
-
* Create the grep_content internal tool
|
|
13
|
+
* Create the grep_content internal tool with directory approval support
|
|
13
14
|
*/
|
|
14
|
-
declare function createGrepContentTool(
|
|
15
|
+
declare function createGrepContentTool(options: FileToolOptions): InternalTool;
|
|
15
16
|
|
|
16
17
|
export { createGrepContentTool };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InternalTool } from '@dexto/core';
|
|
2
|
-
import {
|
|
2
|
+
import { FileToolOptions } from './file-tool-types.js';
|
|
3
|
+
import './filesystem-service.js';
|
|
3
4
|
import './types.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -9,8 +10,8 @@ import './types.js';
|
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
|
-
* Create the grep_content internal tool
|
|
13
|
+
* Create the grep_content internal tool with directory approval support
|
|
13
14
|
*/
|
|
14
|
-
declare function createGrepContentTool(
|
|
15
|
+
declare function createGrepContentTool(options: FileToolOptions): InternalTool;
|
|
15
16
|
|
|
16
17
|
export { createGrepContentTool };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
1
2
|
import { z } from "zod";
|
|
3
|
+
import { ApprovalType } from "@dexto/core";
|
|
2
4
|
const GrepContentInputSchema = z.object({
|
|
3
5
|
pattern: z.string().describe("Regular expression pattern to search for"),
|
|
4
6
|
path: z.string().optional().describe("Directory to search in (defaults to working directory)"),
|
|
@@ -9,15 +11,55 @@ const GrepContentInputSchema = z.object({
|
|
|
9
11
|
case_insensitive: z.boolean().optional().default(false).describe("Perform case-insensitive search (default: false)"),
|
|
10
12
|
max_results: z.number().int().positive().optional().default(100).describe("Maximum number of results to return (default: 100)")
|
|
11
13
|
}).strict();
|
|
12
|
-
function createGrepContentTool(
|
|
14
|
+
function createGrepContentTool(options) {
|
|
15
|
+
const { fileSystemService, directoryApproval } = options;
|
|
16
|
+
let pendingApprovalSearchDir;
|
|
13
17
|
return {
|
|
14
18
|
id: "grep_content",
|
|
15
19
|
description: 'Search for text patterns in files using regular expressions. Returns matching lines with file path, line number, and optional context lines. Use glob parameter to filter specific file types (e.g., "*.ts"). Supports case-insensitive search. Great for finding code patterns, function definitions, or specific text across multiple files.',
|
|
16
20
|
inputSchema: GrepContentInputSchema,
|
|
21
|
+
/**
|
|
22
|
+
* Check if this grep operation needs directory access approval.
|
|
23
|
+
* Returns custom approval request if the search directory is outside allowed paths.
|
|
24
|
+
*/
|
|
25
|
+
getApprovalOverride: async (args) => {
|
|
26
|
+
const { path: searchPath } = args;
|
|
27
|
+
const searchDir = path.resolve(searchPath || process.cwd());
|
|
28
|
+
const isAllowed = await fileSystemService.isPathWithinConfigAllowed(searchDir);
|
|
29
|
+
if (isAllowed) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
if (directoryApproval?.isSessionApproved(searchDir)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
pendingApprovalSearchDir = searchDir;
|
|
36
|
+
return {
|
|
37
|
+
type: ApprovalType.DIRECTORY_ACCESS,
|
|
38
|
+
metadata: {
|
|
39
|
+
path: searchDir,
|
|
40
|
+
parentDir: searchDir,
|
|
41
|
+
operation: "search",
|
|
42
|
+
toolName: "grep_content"
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* Handle approved directory access - remember the directory for session
|
|
48
|
+
*/
|
|
49
|
+
onApprovalGranted: (response) => {
|
|
50
|
+
if (!directoryApproval || !pendingApprovalSearchDir) return;
|
|
51
|
+
const data = response.data;
|
|
52
|
+
const rememberDirectory = data?.rememberDirectory ?? false;
|
|
53
|
+
directoryApproval.addApproved(
|
|
54
|
+
pendingApprovalSearchDir,
|
|
55
|
+
rememberDirectory ? "session" : "once"
|
|
56
|
+
);
|
|
57
|
+
pendingApprovalSearchDir = void 0;
|
|
58
|
+
},
|
|
17
59
|
execute: async (input, _context) => {
|
|
18
|
-
const { pattern, path, glob, context_lines, case_insensitive, max_results } = input;
|
|
60
|
+
const { pattern, path: path2, glob, context_lines, case_insensitive, max_results } = input;
|
|
19
61
|
const result = await fileSystemService.searchContent(pattern, {
|
|
20
|
-
path,
|
|
62
|
+
path: path2,
|
|
21
63
|
glob,
|
|
22
64
|
contextLines: context_lines,
|
|
23
65
|
caseInsensitive: case_insensitive,
|
package/dist/tool-provider.cjs
CHANGED
|
@@ -102,8 +102,8 @@ const fileSystemToolsProvider = {
|
|
|
102
102
|
read_file: () => (0, import_read_file_tool.createReadFileTool)(fileToolOptions),
|
|
103
103
|
write_file: () => (0, import_write_file_tool.createWriteFileTool)(fileToolOptions),
|
|
104
104
|
edit_file: () => (0, import_edit_file_tool.createEditFileTool)(fileToolOptions),
|
|
105
|
-
glob_files: () => (0, import_glob_files_tool.createGlobFilesTool)(
|
|
106
|
-
grep_content: () => (0, import_grep_content_tool.createGrepContentTool)(
|
|
105
|
+
glob_files: () => (0, import_glob_files_tool.createGlobFilesTool)(fileToolOptions),
|
|
106
|
+
grep_content: () => (0, import_grep_content_tool.createGrepContentTool)(fileToolOptions)
|
|
107
107
|
};
|
|
108
108
|
const toolsToCreate = config.enabledTools ?? FILESYSTEM_TOOL_NAMES;
|
|
109
109
|
if (config.enabledTools) {
|
package/dist/tool-provider.js
CHANGED
|
@@ -79,8 +79,8 @@ const fileSystemToolsProvider = {
|
|
|
79
79
|
read_file: () => createReadFileTool(fileToolOptions),
|
|
80
80
|
write_file: () => createWriteFileTool(fileToolOptions),
|
|
81
81
|
edit_file: () => createEditFileTool(fileToolOptions),
|
|
82
|
-
glob_files: () => createGlobFilesTool(
|
|
83
|
-
grep_content: () => createGrepContentTool(
|
|
82
|
+
glob_files: () => createGlobFilesTool(fileToolOptions),
|
|
83
|
+
grep_content: () => createGrepContentTool(fileToolOptions)
|
|
84
84
|
};
|
|
85
85
|
const toolsToCreate = config.enabledTools ?? FILESYSTEM_TOOL_NAMES;
|
|
86
86
|
if (config.enabledTools) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexto/tools-filesystem",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.4",
|
|
4
4
|
"description": "FileSystem tools provider for Dexto agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"glob": "^11.1.0",
|
|
23
23
|
"safe-regex": "^2.1.1",
|
|
24
24
|
"zod": "^3.25.0",
|
|
25
|
-
"@dexto/core": "1.5.
|
|
25
|
+
"@dexto/core": "1.5.4"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/diff": "^5.2.3",
|