@dexto/tools-filesystem 1.6.0 → 1.6.2
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/directory-approval.cjs +44 -40
- package/dist/directory-approval.d.ts +8 -4
- package/dist/directory-approval.d.ts.map +1 -1
- package/dist/directory-approval.integration.test.cjs +107 -356
- package/dist/directory-approval.integration.test.d.ts +6 -6
- package/dist/directory-approval.integration.test.js +109 -360
- package/dist/directory-approval.js +45 -41
- package/dist/edit-file-tool.cjs +69 -47
- package/dist/edit-file-tool.d.ts.map +1 -1
- package/dist/edit-file-tool.js +77 -48
- package/dist/edit-file-tool.test.cjs +54 -11
- package/dist/edit-file-tool.test.js +54 -11
- package/dist/error-codes.cjs +4 -0
- package/dist/error-codes.d.ts +4 -0
- package/dist/error-codes.d.ts.map +1 -1
- package/dist/error-codes.js +4 -0
- package/dist/errors.cjs +48 -0
- package/dist/errors.d.ts +16 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +48 -0
- package/dist/filesystem-service.cjs +307 -9
- package/dist/filesystem-service.d.ts +28 -1
- package/dist/filesystem-service.d.ts.map +1 -1
- package/dist/filesystem-service.js +308 -10
- package/dist/glob-files-tool.cjs +12 -1
- package/dist/glob-files-tool.d.ts.map +1 -1
- package/dist/glob-files-tool.js +13 -2
- package/dist/grep-content-tool.cjs +13 -1
- package/dist/grep-content-tool.d.ts.map +1 -1
- package/dist/grep-content-tool.js +14 -2
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +852 -16
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/path-validator.cjs +28 -2
- package/dist/path-validator.d.ts +14 -0
- package/dist/path-validator.d.ts.map +1 -1
- package/dist/path-validator.js +28 -2
- package/dist/read-file-tool.cjs +7 -1
- package/dist/read-file-tool.d.ts.map +1 -1
- package/dist/read-file-tool.js +8 -2
- package/dist/tool-factory.cjs +21 -0
- package/dist/tool-factory.d.ts.map +1 -1
- package/dist/tool-factory.js +21 -0
- package/dist/types.d.ts +65 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/write-file-tool.cjs +60 -38
- package/dist/write-file-tool.d.ts +1 -1
- package/dist/write-file-tool.d.ts.map +1 -1
- package/dist/write-file-tool.js +67 -39
- package/dist/write-file-tool.test.cjs +75 -13
- package/dist/write-file-tool.test.js +75 -13
- package/package.json +6 -6
- package/dist/directory-approval.d.cts +0 -22
- package/dist/directory-approval.integration.test.d.cts +0 -2
- package/dist/edit-file-tool.d.cts +0 -34
- package/dist/edit-file-tool.test.d.cts +0 -2
- package/dist/error-codes.d.cts +0 -32
- package/dist/errors.d.cts +0 -112
- package/dist/file-tool-types.d.cts +0 -18
- package/dist/filesystem-service.d.cts +0 -117
- package/dist/filesystem-service.test.d.cts +0 -2
- package/dist/glob-files-tool.d.cts +0 -31
- package/dist/grep-content-tool.d.cts +0 -40
- package/dist/path-validator.d.cts +0 -97
- package/dist/path-validator.test.d.cts +0 -2
- package/dist/read-file-tool.d.cts +0 -31
- package/dist/tool-factory-config.d.cts +0 -63
- package/dist/tool-factory.d.cts +0 -7
- package/dist/types.d.cts +0 -178
- package/dist/write-file-tool.d.cts +0 -34
- package/dist/write-file-tool.test.d.cts +0 -2
package/dist/errors.d.cts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { DextoRuntimeError } from '@dexto/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* FileSystem Service Errors
|
|
5
|
-
*
|
|
6
|
-
* Error classes for file system operations
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
interface FileSystemErrorContext {
|
|
10
|
-
path?: string;
|
|
11
|
-
pattern?: string;
|
|
12
|
-
size?: number;
|
|
13
|
-
maxSize?: number;
|
|
14
|
-
encoding?: string;
|
|
15
|
-
operation?: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Factory class for creating FileSystem-related errors
|
|
19
|
-
*/
|
|
20
|
-
declare class FileSystemError {
|
|
21
|
-
private constructor();
|
|
22
|
-
/**
|
|
23
|
-
* File not found error
|
|
24
|
-
*/
|
|
25
|
-
static fileNotFound(path: string): DextoRuntimeError;
|
|
26
|
-
/**
|
|
27
|
-
* Directory not found error
|
|
28
|
-
*/
|
|
29
|
-
static directoryNotFound(path: string): DextoRuntimeError;
|
|
30
|
-
/**
|
|
31
|
-
* Permission denied error
|
|
32
|
-
*/
|
|
33
|
-
static permissionDenied(path: string, operation: string): DextoRuntimeError;
|
|
34
|
-
/**
|
|
35
|
-
* Path not allowed error
|
|
36
|
-
*/
|
|
37
|
-
static pathNotAllowed(path: string, allowedPaths: string[]): DextoRuntimeError;
|
|
38
|
-
/**
|
|
39
|
-
* Path blocked error
|
|
40
|
-
*/
|
|
41
|
-
static pathBlocked(path: string, reason: string): DextoRuntimeError;
|
|
42
|
-
/**
|
|
43
|
-
* Invalid path error
|
|
44
|
-
*/
|
|
45
|
-
static invalidPath(path: string, reason: string): DextoRuntimeError;
|
|
46
|
-
/**
|
|
47
|
-
* Path traversal detected
|
|
48
|
-
*/
|
|
49
|
-
static pathTraversal(path: string): DextoRuntimeError;
|
|
50
|
-
/**
|
|
51
|
-
* Invalid file extension error
|
|
52
|
-
*/
|
|
53
|
-
static invalidExtension(path: string, blockedExtensions: string[]): DextoRuntimeError;
|
|
54
|
-
/**
|
|
55
|
-
* File too large error
|
|
56
|
-
*/
|
|
57
|
-
static fileTooLarge(path: string, size: number, maxSize: number): DextoRuntimeError;
|
|
58
|
-
/**
|
|
59
|
-
* Too many results error
|
|
60
|
-
*/
|
|
61
|
-
static tooManyResults(operation: string, count: number, maxResults: number): DextoRuntimeError;
|
|
62
|
-
/**
|
|
63
|
-
* Read operation failed
|
|
64
|
-
*/
|
|
65
|
-
static readFailed(path: string, cause: string): DextoRuntimeError;
|
|
66
|
-
/**
|
|
67
|
-
* Write operation failed
|
|
68
|
-
*/
|
|
69
|
-
static writeFailed(path: string, cause: string): DextoRuntimeError;
|
|
70
|
-
/**
|
|
71
|
-
* Backup creation failed
|
|
72
|
-
*/
|
|
73
|
-
static backupFailed(path: string, cause: string): DextoRuntimeError;
|
|
74
|
-
/**
|
|
75
|
-
* Edit operation failed
|
|
76
|
-
*/
|
|
77
|
-
static editFailed(path: string, cause: string): DextoRuntimeError;
|
|
78
|
-
/**
|
|
79
|
-
* String not unique error
|
|
80
|
-
*/
|
|
81
|
-
static stringNotUnique(path: string, searchString: string, occurrences: number): DextoRuntimeError;
|
|
82
|
-
/**
|
|
83
|
-
* String not found error
|
|
84
|
-
*/
|
|
85
|
-
static stringNotFound(path: string, searchString: string): DextoRuntimeError;
|
|
86
|
-
/**
|
|
87
|
-
* Glob operation failed
|
|
88
|
-
*/
|
|
89
|
-
static globFailed(pattern: string, cause: string): DextoRuntimeError;
|
|
90
|
-
/**
|
|
91
|
-
* Search operation failed
|
|
92
|
-
*/
|
|
93
|
-
static searchFailed(pattern: string, cause: string): DextoRuntimeError;
|
|
94
|
-
/**
|
|
95
|
-
* Invalid pattern error
|
|
96
|
-
*/
|
|
97
|
-
static invalidPattern(pattern: string, cause: string): DextoRuntimeError;
|
|
98
|
-
/**
|
|
99
|
-
* Regex timeout error
|
|
100
|
-
*/
|
|
101
|
-
static regexTimeout(pattern: string): DextoRuntimeError;
|
|
102
|
-
/**
|
|
103
|
-
* Invalid configuration error
|
|
104
|
-
*/
|
|
105
|
-
static invalidConfig(reason: string): DextoRuntimeError;
|
|
106
|
-
/**
|
|
107
|
-
* Service not initialized error
|
|
108
|
-
*/
|
|
109
|
-
static notInitialized(): DextoRuntimeError;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export { FileSystemError, type FileSystemErrorContext };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ToolExecutionContext } from '@dexto/core';
|
|
2
|
-
import { FileSystemService } from './filesystem-service.cjs';
|
|
3
|
-
import './types.cjs';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* File Tool Types
|
|
7
|
-
*
|
|
8
|
-
* Types shared between file tools and factories.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Getter for a lazily-initialized {@link FileSystemService}.
|
|
13
|
-
* Tool factories construct tools before runtime services are available, so tools
|
|
14
|
-
* resolve the service on-demand using {@link ToolExecutionContext}.
|
|
15
|
-
*/
|
|
16
|
-
type FileSystemServiceGetter = (context: ToolExecutionContext) => Promise<FileSystemService>;
|
|
17
|
-
|
|
18
|
-
export type { FileSystemServiceGetter };
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@dexto/core';
|
|
2
|
-
import { FileSystemConfig, ReadFileOptions, FileContent, GlobOptions, GlobResult, GrepOptions, SearchResult, WriteFileOptions, WriteResult, EditOperation, EditFileOptions, EditResult } from './types.cjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* FileSystem Service
|
|
6
|
-
*
|
|
7
|
-
* Secure file system operations for Dexto internal tools
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* FileSystemService - Handles all file system operations with security checks
|
|
12
|
-
*
|
|
13
|
-
* This service receives fully-validated configuration from the FileSystem Tools Factory.
|
|
14
|
-
* All defaults have been applied by the factory's schema, so the service trusts the config
|
|
15
|
-
* and uses it as-is without any fallback logic.
|
|
16
|
-
*
|
|
17
|
-
* TODO: instantiate only when internal file tools are enabled to avoid file dependencies which won't work in serverless
|
|
18
|
-
*/
|
|
19
|
-
declare class FileSystemService {
|
|
20
|
-
private config;
|
|
21
|
-
private pathValidator;
|
|
22
|
-
private initialized;
|
|
23
|
-
private initPromise;
|
|
24
|
-
private logger;
|
|
25
|
-
private directoryApprovalChecker?;
|
|
26
|
-
/**
|
|
27
|
-
* Create a new FileSystemService with validated configuration.
|
|
28
|
-
*
|
|
29
|
-
* @param config - Fully-validated configuration from the factory schema.
|
|
30
|
-
* All required fields have values, defaults already applied.
|
|
31
|
-
* @param logger - Logger instance for this service
|
|
32
|
-
*/
|
|
33
|
-
constructor(config: FileSystemConfig, logger: Logger);
|
|
34
|
-
/**
|
|
35
|
-
* Get backup directory path (context-aware with optional override)
|
|
36
|
-
* TODO: Migrate to explicit configuration via CLI enrichment layer (per-agent paths)
|
|
37
|
-
*/
|
|
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;
|
|
44
|
-
/**
|
|
45
|
-
* Initialize the service.
|
|
46
|
-
* Safe to call multiple times - subsequent calls return the same promise.
|
|
47
|
-
*/
|
|
48
|
-
initialize(): Promise<void>;
|
|
49
|
-
/**
|
|
50
|
-
* Internal initialization logic.
|
|
51
|
-
*/
|
|
52
|
-
private doInitialize;
|
|
53
|
-
/**
|
|
54
|
-
* Ensure the service is initialized before use.
|
|
55
|
-
* Tools should call this at the start of their execute methods.
|
|
56
|
-
* Safe to call multiple times - will await the same initialization promise.
|
|
57
|
-
*/
|
|
58
|
-
ensureInitialized(): Promise<void>;
|
|
59
|
-
/**
|
|
60
|
-
* Set a callback to check if a path is in an approved directory.
|
|
61
|
-
* This allows PathValidator to consult ApprovalManager without a direct dependency.
|
|
62
|
-
*
|
|
63
|
-
* @param checker Function that returns true if path is in an approved directory
|
|
64
|
-
*/
|
|
65
|
-
setDirectoryApprovalChecker(checker: (filePath: string) => boolean): void;
|
|
66
|
-
/**
|
|
67
|
-
* Update the working directory at runtime (e.g., when workspace changes).
|
|
68
|
-
* Rebuilds the PathValidator so allowed/blocked path roots are recalculated.
|
|
69
|
-
*/
|
|
70
|
-
setWorkingDirectory(workingDirectory: string): void;
|
|
71
|
-
/**
|
|
72
|
-
* Check if a file path is within the configured allowed paths (config only).
|
|
73
|
-
* This is used by file tools to determine if directory approval is needed.
|
|
74
|
-
*
|
|
75
|
-
* @param filePath The file path to check (can be relative or absolute)
|
|
76
|
-
* @returns true if the path is within config-allowed paths, false otherwise
|
|
77
|
-
*/
|
|
78
|
-
isPathWithinConfigAllowed(filePath: string): Promise<boolean>;
|
|
79
|
-
/**
|
|
80
|
-
* Read a file with validation and size limits
|
|
81
|
-
*/
|
|
82
|
-
readFile(filePath: string, options?: ReadFileOptions): Promise<FileContent>;
|
|
83
|
-
/**
|
|
84
|
-
* Find files matching a glob pattern
|
|
85
|
-
*/
|
|
86
|
-
globFiles(pattern: string, options?: GlobOptions): Promise<GlobResult>;
|
|
87
|
-
/**
|
|
88
|
-
* Search for content in files (grep-like functionality)
|
|
89
|
-
*/
|
|
90
|
-
searchContent(pattern: string, options?: GrepOptions): Promise<SearchResult>;
|
|
91
|
-
/**
|
|
92
|
-
* Write content to a file
|
|
93
|
-
*/
|
|
94
|
-
writeFile(filePath: string, content: string, options?: WriteFileOptions): Promise<WriteResult>;
|
|
95
|
-
/**
|
|
96
|
-
* Edit a file by replacing text
|
|
97
|
-
*/
|
|
98
|
-
editFile(filePath: string, operation: EditOperation, options?: EditFileOptions): Promise<EditResult>;
|
|
99
|
-
/**
|
|
100
|
-
* Create a backup of a file
|
|
101
|
-
*/
|
|
102
|
-
private createBackup;
|
|
103
|
-
/**
|
|
104
|
-
* Clean up old backup files based on retention policy
|
|
105
|
-
*/
|
|
106
|
-
cleanupOldBackups(): Promise<number>;
|
|
107
|
-
/**
|
|
108
|
-
* Get service configuration
|
|
109
|
-
*/
|
|
110
|
-
getConfig(): Readonly<FileSystemConfig>;
|
|
111
|
-
/**
|
|
112
|
-
* Check if a path is allowed (async for non-blocking symlink resolution)
|
|
113
|
-
*/
|
|
114
|
-
isPathAllowed(filePath: string): Promise<boolean>;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export { FileSystemService };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { Tool } from '@dexto/core';
|
|
3
|
-
import { FileSystemServiceGetter } from './file-tool-types.cjs';
|
|
4
|
-
import './filesystem-service.cjs';
|
|
5
|
-
import './types.cjs';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Glob Files Tool
|
|
9
|
-
*
|
|
10
|
-
* Internal tool for finding files using glob patterns
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
declare const GlobFilesInputSchema: z.ZodObject<{
|
|
14
|
-
pattern: z.ZodString;
|
|
15
|
-
path: z.ZodOptional<z.ZodString>;
|
|
16
|
-
max_results: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
17
|
-
}, "strict", z.ZodTypeAny, {
|
|
18
|
-
pattern: string;
|
|
19
|
-
max_results: number;
|
|
20
|
-
path?: string | undefined;
|
|
21
|
-
}, {
|
|
22
|
-
pattern: string;
|
|
23
|
-
path?: string | undefined;
|
|
24
|
-
max_results?: number | undefined;
|
|
25
|
-
}>;
|
|
26
|
-
/**
|
|
27
|
-
* Create the glob_files internal tool with directory approval support
|
|
28
|
-
*/
|
|
29
|
-
declare function createGlobFilesTool(getFileSystemService: FileSystemServiceGetter): Tool<typeof GlobFilesInputSchema>;
|
|
30
|
-
|
|
31
|
-
export { createGlobFilesTool };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { Tool } from '@dexto/core';
|
|
3
|
-
import { FileSystemServiceGetter } from './file-tool-types.cjs';
|
|
4
|
-
import './filesystem-service.cjs';
|
|
5
|
-
import './types.cjs';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Grep Content Tool
|
|
9
|
-
*
|
|
10
|
-
* Internal tool for searching file contents using regex patterns
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
declare const GrepContentInputSchema: z.ZodObject<{
|
|
14
|
-
pattern: z.ZodString;
|
|
15
|
-
path: z.ZodOptional<z.ZodString>;
|
|
16
|
-
glob: z.ZodOptional<z.ZodString>;
|
|
17
|
-
context_lines: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
18
|
-
case_insensitive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
19
|
-
max_results: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
20
|
-
}, "strict", z.ZodTypeAny, {
|
|
21
|
-
pattern: string;
|
|
22
|
-
max_results: number;
|
|
23
|
-
context_lines: number;
|
|
24
|
-
case_insensitive: boolean;
|
|
25
|
-
path?: string | undefined;
|
|
26
|
-
glob?: string | undefined;
|
|
27
|
-
}, {
|
|
28
|
-
pattern: string;
|
|
29
|
-
path?: string | undefined;
|
|
30
|
-
max_results?: number | undefined;
|
|
31
|
-
glob?: string | undefined;
|
|
32
|
-
context_lines?: number | undefined;
|
|
33
|
-
case_insensitive?: boolean | undefined;
|
|
34
|
-
}>;
|
|
35
|
-
/**
|
|
36
|
-
* Create the grep_content internal tool with directory approval support
|
|
37
|
-
*/
|
|
38
|
-
declare function createGrepContentTool(getFileSystemService: FileSystemServiceGetter): Tool<typeof GrepContentInputSchema>;
|
|
39
|
-
|
|
40
|
-
export { createGrepContentTool };
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { FileSystemConfig, PathValidation } from './types.cjs';
|
|
2
|
-
import { Logger } from '@dexto/core';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Path Validator
|
|
6
|
-
*
|
|
7
|
-
* Security-focused path validation for file system operations
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Callback type for checking if a path is in an approved directory.
|
|
12
|
-
* Used to consult ApprovalManager without creating a direct dependency.
|
|
13
|
-
*/
|
|
14
|
-
type DirectoryApprovalChecker = (filePath: string) => boolean;
|
|
15
|
-
/**
|
|
16
|
-
* PathValidator - Validates file paths for security and policy compliance
|
|
17
|
-
*
|
|
18
|
-
* Security checks:
|
|
19
|
-
* 1. Path traversal detection (../, symbolic links)
|
|
20
|
-
* 2. Allowed paths enforcement (whitelist + approved directories)
|
|
21
|
-
* 3. Blocked paths detection (blacklist)
|
|
22
|
-
* 4. File extension restrictions
|
|
23
|
-
* 5. Absolute path normalization
|
|
24
|
-
*
|
|
25
|
-
* PathValidator can optionally consult an external approval checker (e.g., ApprovalManager)
|
|
26
|
-
* to determine if paths outside the config's allowed paths are accessible.
|
|
27
|
-
*/
|
|
28
|
-
declare class PathValidator {
|
|
29
|
-
private config;
|
|
30
|
-
private normalizedAllowedPaths;
|
|
31
|
-
private normalizedBlockedPaths;
|
|
32
|
-
private normalizedBlockedExtensions;
|
|
33
|
-
private logger;
|
|
34
|
-
private directoryApprovalChecker;
|
|
35
|
-
constructor(config: FileSystemConfig, logger: Logger);
|
|
36
|
-
/**
|
|
37
|
-
* Set a callback to check if a path is in an approved directory.
|
|
38
|
-
* This allows PathValidator to consult ApprovalManager without a direct dependency.
|
|
39
|
-
*
|
|
40
|
-
* @param checker Function that returns true if path is in an approved directory
|
|
41
|
-
*/
|
|
42
|
-
setDirectoryApprovalChecker(checker: DirectoryApprovalChecker): void;
|
|
43
|
-
/**
|
|
44
|
-
* Validate a file path for security and policy compliance
|
|
45
|
-
*/
|
|
46
|
-
validatePath(filePath: string): Promise<PathValidation>;
|
|
47
|
-
/**
|
|
48
|
-
* Check if path contains traversal attempts
|
|
49
|
-
*/
|
|
50
|
-
private hasPathTraversal;
|
|
51
|
-
/**
|
|
52
|
-
* Check if path is within allowed paths (whitelist check)
|
|
53
|
-
* Also consults the directory approval checker if configured.
|
|
54
|
-
* Uses the sync version since the path is already normalized at this point.
|
|
55
|
-
*/
|
|
56
|
-
private isPathAllowed;
|
|
57
|
-
/**
|
|
58
|
-
* Check if path matches blocked patterns (blacklist check)
|
|
59
|
-
*/
|
|
60
|
-
private isPathBlocked;
|
|
61
|
-
/**
|
|
62
|
-
* Quick check if a path is allowed (for internal use)
|
|
63
|
-
* Note: This assumes the path is already normalized/canonicalized
|
|
64
|
-
*/
|
|
65
|
-
isPathAllowedQuick(normalizedPath: string): boolean;
|
|
66
|
-
/**
|
|
67
|
-
* Synchronous path allowed check (for already-normalized paths)
|
|
68
|
-
* This is used internally when we already have a canonicalized path
|
|
69
|
-
*/
|
|
70
|
-
private isPathAllowedSync;
|
|
71
|
-
/**
|
|
72
|
-
* Check if a file path is within the configured allowed paths (from config only).
|
|
73
|
-
* This method does NOT consult ApprovalManager - it only checks the static config paths.
|
|
74
|
-
*
|
|
75
|
-
* This is used by file tools to determine if a path needs directory approval.
|
|
76
|
-
* Paths within config-allowed directories don't need directory approval prompts.
|
|
77
|
-
*
|
|
78
|
-
* @param filePath The file path to check (can be relative or absolute)
|
|
79
|
-
* @returns true if the path is within config-allowed paths, false otherwise
|
|
80
|
-
*/
|
|
81
|
-
isPathWithinAllowed(filePath: string): Promise<boolean>;
|
|
82
|
-
/**
|
|
83
|
-
* Check if path is within config-allowed paths only (no approval checker).
|
|
84
|
-
* Used for prompting decisions.
|
|
85
|
-
*/
|
|
86
|
-
private isInConfigAllowedPaths;
|
|
87
|
-
/**
|
|
88
|
-
* Get normalized allowed paths
|
|
89
|
-
*/
|
|
90
|
-
getAllowedPaths(): string[];
|
|
91
|
-
/**
|
|
92
|
-
* Get blocked paths
|
|
93
|
-
*/
|
|
94
|
-
getBlockedPaths(): string[];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export { type DirectoryApprovalChecker, PathValidator };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { Tool } from '@dexto/core';
|
|
3
|
-
import { FileSystemServiceGetter } from './file-tool-types.cjs';
|
|
4
|
-
import './filesystem-service.cjs';
|
|
5
|
-
import './types.cjs';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Read File Tool
|
|
9
|
-
*
|
|
10
|
-
* Internal tool for reading file contents with size limits and pagination
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
declare const ReadFileInputSchema: z.ZodObject<{
|
|
14
|
-
file_path: z.ZodString;
|
|
15
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
16
|
-
offset: z.ZodOptional<z.ZodNumber>;
|
|
17
|
-
}, "strict", z.ZodTypeAny, {
|
|
18
|
-
file_path: string;
|
|
19
|
-
limit?: number | undefined;
|
|
20
|
-
offset?: number | undefined;
|
|
21
|
-
}, {
|
|
22
|
-
file_path: string;
|
|
23
|
-
limit?: number | undefined;
|
|
24
|
-
offset?: number | undefined;
|
|
25
|
-
}>;
|
|
26
|
-
/**
|
|
27
|
-
* Create the read_file internal tool with directory approval support
|
|
28
|
-
*/
|
|
29
|
-
declare function createReadFileTool(getFileSystemService: FileSystemServiceGetter): Tool<typeof ReadFileInputSchema>;
|
|
30
|
-
|
|
31
|
-
export { createReadFileTool };
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* FileSystem Tools Factory
|
|
5
|
-
*
|
|
6
|
-
* Provides file operation tools by wrapping FileSystemService.
|
|
7
|
-
* When registered, the factory initializes FileSystemService and creates tools
|
|
8
|
-
* for file operations (read, write, edit, glob, grep).
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Available filesystem tool names for enabledTools configuration.
|
|
13
|
-
*/
|
|
14
|
-
declare const FILESYSTEM_TOOL_NAMES: readonly ["read_file", "write_file", "edit_file", "glob_files", "grep_content"];
|
|
15
|
-
/**
|
|
16
|
-
* Configuration schema for FileSystem tools factory.
|
|
17
|
-
*
|
|
18
|
-
* This is the SINGLE SOURCE OF TRUTH for all configuration:
|
|
19
|
-
* - Validation rules
|
|
20
|
-
* - Default values (using constants above)
|
|
21
|
-
* - Documentation
|
|
22
|
-
* - Type definitions
|
|
23
|
-
*
|
|
24
|
-
* Services receive fully-validated config from this schema and use it as-is,
|
|
25
|
-
* with no additional defaults or fallbacks needed.
|
|
26
|
-
*/
|
|
27
|
-
declare const FileSystemToolsConfigSchema: z.ZodObject<{
|
|
28
|
-
type: z.ZodLiteral<"filesystem-tools">;
|
|
29
|
-
allowedPaths: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
30
|
-
blockedPaths: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
31
|
-
blockedExtensions: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
32
|
-
maxFileSize: z.ZodDefault<z.ZodNumber>;
|
|
33
|
-
workingDirectory: z.ZodOptional<z.ZodString>;
|
|
34
|
-
enableBackups: z.ZodDefault<z.ZodBoolean>;
|
|
35
|
-
backupPath: z.ZodOptional<z.ZodString>;
|
|
36
|
-
backupRetentionDays: z.ZodDefault<z.ZodNumber>;
|
|
37
|
-
enabledTools: z.ZodOptional<z.ZodArray<z.ZodEnum<["read_file", "write_file", "edit_file", "glob_files", "grep_content"]>, "many">>;
|
|
38
|
-
}, "strict", z.ZodTypeAny, {
|
|
39
|
-
type: "filesystem-tools";
|
|
40
|
-
allowedPaths: string[];
|
|
41
|
-
blockedExtensions: string[];
|
|
42
|
-
blockedPaths: string[];
|
|
43
|
-
maxFileSize: number;
|
|
44
|
-
enableBackups: boolean;
|
|
45
|
-
backupRetentionDays: number;
|
|
46
|
-
backupPath?: string | undefined;
|
|
47
|
-
workingDirectory?: string | undefined;
|
|
48
|
-
enabledTools?: ("edit_file" | "glob_files" | "grep_content" | "read_file" | "write_file")[] | undefined;
|
|
49
|
-
}, {
|
|
50
|
-
type: "filesystem-tools";
|
|
51
|
-
allowedPaths?: string[] | undefined;
|
|
52
|
-
blockedExtensions?: string[] | undefined;
|
|
53
|
-
backupPath?: string | undefined;
|
|
54
|
-
blockedPaths?: string[] | undefined;
|
|
55
|
-
maxFileSize?: number | undefined;
|
|
56
|
-
enableBackups?: boolean | undefined;
|
|
57
|
-
backupRetentionDays?: number | undefined;
|
|
58
|
-
workingDirectory?: string | undefined;
|
|
59
|
-
enabledTools?: ("edit_file" | "glob_files" | "grep_content" | "read_file" | "write_file")[] | undefined;
|
|
60
|
-
}>;
|
|
61
|
-
type FileSystemToolsConfig = z.output<typeof FileSystemToolsConfigSchema>;
|
|
62
|
-
|
|
63
|
-
export { FILESYSTEM_TOOL_NAMES, type FileSystemToolsConfig, FileSystemToolsConfigSchema };
|
package/dist/tool-factory.d.cts
DELETED