@j0hanz/filesystem-mcp 1.19.1 → 2.0.0
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 +333 -838
- package/dist/cli-help.d.ts +3 -0
- package/dist/cli-help.d.ts.map +1 -0
- package/dist/cli-help.js +169 -0
- package/dist/cli-help.js.map +1 -0
- package/dist/cli.d.ts +28 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +168 -123
- package/dist/cli.js.map +1 -0
- package/dist/core/concurrency.d.ts +70 -0
- package/dist/core/concurrency.d.ts.map +1 -0
- package/dist/core/concurrency.js +173 -0
- package/dist/core/concurrency.js.map +1 -0
- package/dist/core/config.d.ts +19 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +11 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/cursor.d.ts +23 -0
- package/dist/core/cursor.d.ts.map +1 -0
- package/dist/core/cursor.js +62 -0
- package/dist/core/cursor.js.map +1 -0
- package/dist/core/errors.d.ts +96 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +356 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/file-uri.d.ts +24 -0
- package/dist/core/file-uri.d.ts.map +1 -0
- package/dist/core/file-uri.js +52 -0
- package/dist/core/file-uri.js.map +1 -0
- package/dist/core/fmt.d.ts +38 -0
- package/dist/core/fmt.d.ts.map +1 -0
- package/dist/core/fmt.js +109 -0
- package/dist/core/fmt.js.map +1 -0
- package/dist/core/fs.d.ts +108 -0
- package/dist/core/fs.d.ts.map +1 -0
- package/dist/core/fs.js +243 -0
- package/dist/core/fs.js.map +1 -0
- package/dist/core/glob.d.ts +41 -0
- package/dist/core/glob.d.ts.map +1 -0
- package/dist/core/glob.js +399 -0
- package/dist/core/glob.js.map +1 -0
- package/dist/core/input-required.d.ts +147 -0
- package/dist/core/input-required.d.ts.map +1 -0
- package/dist/core/input-required.js +261 -0
- package/dist/core/input-required.js.map +1 -0
- package/dist/core/mime.d.ts +15 -0
- package/dist/core/mime.d.ts.map +1 -0
- package/dist/core/mime.js +188 -0
- package/dist/core/mime.js.map +1 -0
- package/dist/core/observability.d.ts +10 -0
- package/dist/core/observability.d.ts.map +1 -0
- package/dist/core/observability.js +76 -0
- package/dist/core/observability.js.map +1 -0
- package/dist/core/page-store.d.ts +41 -0
- package/dist/core/page-store.d.ts.map +1 -0
- package/dist/core/page-store.js +74 -0
- package/dist/core/page-store.js.map +1 -0
- package/dist/core/path-completer.d.ts +10 -0
- package/dist/core/path-completer.d.ts.map +1 -0
- package/dist/core/path-completer.js +227 -0
- package/dist/core/path-completer.js.map +1 -0
- package/dist/core/path-discovery.d.ts +8 -0
- package/dist/core/path-discovery.d.ts.map +1 -0
- package/dist/core/path-discovery.js +105 -0
- package/dist/core/path-discovery.js.map +1 -0
- package/dist/core/path-utils.d.ts +9 -0
- package/dist/core/path-utils.d.ts.map +1 -0
- package/dist/core/path-utils.js +121 -0
- package/dist/core/path-utils.js.map +1 -0
- package/dist/core/path.d.ts +148 -0
- package/dist/core/path.d.ts.map +1 -0
- package/dist/core/path.js +674 -0
- package/dist/core/path.js.map +1 -0
- package/dist/core/primitives.d.ts +23 -0
- package/dist/core/primitives.d.ts.map +1 -0
- package/dist/core/primitives.js +54 -0
- package/dist/core/primitives.js.map +1 -0
- package/dist/core/read.d.ts +74 -0
- package/dist/core/read.d.ts.map +1 -0
- package/dist/core/read.js +562 -0
- package/dist/core/read.js.map +1 -0
- package/dist/core/schema.d.ts +139 -0
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/core/schema.js +345 -0
- package/dist/core/schema.js.map +1 -0
- package/dist/core/search.d.ts +100 -0
- package/dist/core/search.d.ts.map +1 -0
- package/dist/core/search.js +248 -0
- package/dist/core/search.js.map +1 -0
- package/dist/core/sensitive.d.ts +6 -0
- package/dist/core/sensitive.d.ts.map +1 -0
- package/dist/core/sensitive.js +142 -0
- package/dist/core/sensitive.js.map +1 -0
- package/dist/core/store.d.ts +57 -0
- package/dist/core/store.d.ts.map +1 -0
- package/dist/core/store.js +162 -0
- package/dist/core/store.js.map +1 -0
- package/dist/core/util.d.ts +26 -0
- package/dist/core/util.d.ts.map +1 -0
- package/dist/core/util.js +66 -0
- package/dist/core/util.js.map +1 -0
- package/dist/core/watcher-registry.d.ts +68 -0
- package/dist/core/watcher-registry.d.ts.map +1 -0
- package/dist/core/watcher-registry.js +312 -0
- package/dist/core/watcher-registry.js.map +1 -0
- package/dist/http-policy.d.ts +121 -0
- package/dist/http-policy.d.ts.map +1 -0
- package/dist/http-policy.js +340 -0
- package/dist/http-policy.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +77 -41
- package/dist/index.js.map +1 -0
- package/dist/instructions.d.ts +12 -0
- package/dist/instructions.d.ts.map +1 -0
- package/dist/instructions.js +71 -0
- package/dist/instructions.js.map +1 -0
- package/dist/prompts.d.ts +8 -6
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +74 -168
- package/dist/prompts.js.map +1 -0
- package/dist/resources.d.ts +73 -9
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +392 -163
- package/dist/resources.js.map +1 -0
- package/dist/server.d.ts +62 -1
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +139 -1
- package/dist/server.js.map +1 -0
- package/dist/tools/batch.d.ts +89 -0
- package/dist/tools/batch.d.ts.map +1 -0
- package/dist/tools/batch.js +157 -0
- package/dist/tools/batch.js.map +1 -0
- package/dist/tools/create.d.ts +2 -0
- package/dist/tools/create.d.ts.map +1 -0
- package/dist/tools/create.js +142 -0
- package/dist/tools/create.js.map +1 -0
- package/dist/tools/define.d.ts +110 -0
- package/dist/tools/define.d.ts.map +1 -0
- package/dist/tools/define.js +394 -0
- package/dist/tools/define.js.map +1 -0
- package/dist/tools/delete-file.d.ts +2 -4
- package/dist/tools/delete-file.d.ts.map +1 -0
- package/dist/tools/delete-file.js +330 -87
- package/dist/tools/delete-file.js.map +1 -0
- package/dist/tools/diff.d.ts +2 -0
- package/dist/tools/diff.d.ts.map +1 -0
- package/dist/tools/diff.js +94 -0
- package/dist/tools/diff.js.map +1 -0
- package/dist/tools/edit.d.ts +2 -0
- package/dist/tools/edit.d.ts.map +1 -0
- package/dist/tools/edit.js +442 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/index.d.ts +26 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +52 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list.d.ts +2 -0
- package/dist/tools/list.d.ts.map +1 -0
- package/dist/tools/list.js +291 -0
- package/dist/tools/list.js.map +1 -0
- package/dist/tools/move.d.ts +2 -0
- package/dist/tools/move.d.ts.map +1 -0
- package/dist/tools/move.js +321 -0
- package/dist/tools/move.js.map +1 -0
- package/dist/tools/patch.d.ts +2 -0
- package/dist/tools/patch.d.ts.map +1 -0
- package/dist/tools/patch.js +155 -0
- package/dist/tools/patch.js.map +1 -0
- package/dist/tools/progress.d.ts +52 -0
- package/dist/tools/progress.d.ts.map +1 -0
- package/dist/tools/progress.js +172 -0
- package/dist/tools/progress.js.map +1 -0
- package/dist/tools/read.d.ts +2 -4
- package/dist/tools/read.d.ts.map +1 -0
- package/dist/tools/read.js +398 -152
- package/dist/tools/read.js.map +1 -0
- package/dist/tools/replace-in-files.d.ts +2 -4
- package/dist/tools/replace-in-files.d.ts.map +1 -0
- package/dist/tools/replace-in-files.js +435 -264
- package/dist/tools/replace-in-files.js.map +1 -0
- package/dist/tools/roots.d.ts +2 -4
- package/dist/tools/roots.d.ts.map +1 -0
- package/dist/tools/roots.js +29 -52
- package/dist/tools/roots.js.map +1 -0
- package/dist/tools/search-content.d.ts +2 -4
- package/dist/tools/search-content.d.ts.map +1 -0
- package/dist/tools/search-content.js +262 -228
- package/dist/tools/search-content.js.map +1 -0
- package/dist/tools/search-files.d.ts +2 -4
- package/dist/tools/search-files.d.ts.map +1 -0
- package/dist/tools/search-files.js +162 -161
- package/dist/tools/search-files.js.map +1 -0
- package/dist/tools/stat.d.ts +2 -4
- package/dist/tools/stat.d.ts.map +1 -0
- package/dist/tools/stat.js +202 -62
- package/dist/tools/stat.js.map +1 -0
- package/dist/transport/http.d.ts +5 -0
- package/dist/transport/http.d.ts.map +1 -0
- package/dist/transport/http.js +276 -0
- package/dist/transport/http.js.map +1 -0
- package/dist/transport/shared.d.ts +45 -0
- package/dist/transport/shared.d.ts.map +1 -0
- package/dist/transport/shared.js +65 -0
- package/dist/transport/shared.js.map +1 -0
- package/dist/transport/stdio.d.ts +32 -0
- package/dist/transport/stdio.d.ts.map +1 -0
- package/dist/transport/stdio.js +279 -0
- package/dist/transport/stdio.js.map +1 -0
- package/dist/transport.d.ts +5 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +4 -0
- package/dist/transport.js.map +1 -0
- package/package.json +37 -46
- package/dist/assets/logo.svg +0 -35
- package/dist/completions.d.ts +0 -2
- package/dist/completions.js +0 -572
- package/dist/config.d.ts +0 -119
- package/dist/config.js +0 -31
- package/dist/lib/abort.d.ts +0 -7
- package/dist/lib/abort.js +0 -81
- package/dist/lib/constants.d.ts +0 -42
- package/dist/lib/constants.js +0 -313
- package/dist/lib/errors.d.ts +0 -28
- package/dist/lib/errors.js +0 -301
- package/dist/lib/file-operations/core.d.ts +0 -53
- package/dist/lib/file-operations/core.js +0 -144
- package/dist/lib/file-operations/metadata.d.ts +0 -77
- package/dist/lib/file-operations/metadata.js +0 -878
- package/dist/lib/file-operations/search.d.ts +0 -46
- package/dist/lib/file-operations/search.js +0 -1194
- package/dist/lib/file-operations/traversal.d.ts +0 -40
- package/dist/lib/file-operations/traversal.js +0 -310
- package/dist/lib/fs-helpers.d.ts +0 -46
- package/dist/lib/fs-helpers.js +0 -606
- package/dist/lib/globs.d.ts +0 -2
- package/dist/lib/globs.js +0 -19
- package/dist/lib/logger.d.ts +0 -27
- package/dist/lib/logger.js +0 -91
- package/dist/lib/observability.d.ts +0 -33
- package/dist/lib/observability.js +0 -373
- package/dist/lib/paths.d.ts +0 -35
- package/dist/lib/paths.js +0 -634
- package/dist/lib/resource-store.d.ts +0 -28
- package/dist/lib/resource-store.js +0 -195
- package/dist/lib/utils.d.ts +0 -7
- package/dist/lib/utils.js +0 -37
- package/dist/lib/zod-codecs.d.ts +0 -2
- package/dist/lib/zod-codecs.js +0 -18
- package/dist/pkg-info.d.ts +0 -7
- package/dist/pkg-info.js +0 -9
- package/dist/resources/generated-instructions.d.ts +0 -1
- package/dist/resources/generated-instructions.js +0 -105
- package/dist/resources/tool-catalog.d.ts +0 -2
- package/dist/resources/tool-catalog.js +0 -78
- package/dist/resources/tool-info.d.ts +0 -9
- package/dist/resources/tool-info.js +0 -206
- package/dist/resources/workflows.d.ts +0 -1
- package/dist/resources/workflows.js +0 -72
- package/dist/schemas.d.ts +0 -505
- package/dist/schemas.js +0 -676
- package/dist/server/bootstrap.d.ts +0 -6
- package/dist/server/bootstrap.js +0 -585
- package/dist/server/event-store.d.ts +0 -18
- package/dist/server/event-store.js +0 -71
- package/dist/server/roots-manager.d.ts +0 -28
- package/dist/server/roots-manager.js +0 -227
- package/dist/server/task-store.d.ts +0 -10
- package/dist/server/task-store.js +0 -91
- package/dist/tools/apply-patch.d.ts +0 -4
- package/dist/tools/apply-patch.js +0 -235
- package/dist/tools/calculate-hash.d.ts +0 -4
- package/dist/tools/calculate-hash.js +0 -187
- package/dist/tools/contract.d.ts +0 -50
- package/dist/tools/contract.js +0 -1
- package/dist/tools/create-directory.d.ts +0 -4
- package/dist/tools/create-directory.js +0 -68
- package/dist/tools/diff-files.d.ts +0 -4
- package/dist/tools/diff-files.js +0 -136
- package/dist/tools/edit-file.d.ts +0 -4
- package/dist/tools/edit-file.js +0 -256
- package/dist/tools/icons.d.ts +0 -15
- package/dist/tools/icons.js +0 -24
- package/dist/tools/list-directory.d.ts +0 -4
- package/dist/tools/list-directory.js +0 -218
- package/dist/tools/move-file.d.ts +0 -4
- package/dist/tools/move-file.js +0 -178
- package/dist/tools/read-multiple.d.ts +0 -4
- package/dist/tools/read-multiple.js +0 -207
- package/dist/tools/shared.d.ts +0 -172
- package/dist/tools/shared.js +0 -599
- package/dist/tools/stat-many.d.ts +0 -4
- package/dist/tools/stat-many.js +0 -104
- package/dist/tools/task-support.d.ts +0 -29
- package/dist/tools/task-support.js +0 -473
- package/dist/tools/tree.d.ts +0 -4
- package/dist/tools/tree.js +0 -102
- package/dist/tools/write-file.d.ts +0 -4
- package/dist/tools/write-file.js +0 -60
- package/dist/tools.d.ts +0 -5
- package/dist/tools.js +0 -54
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function getReservedDeviceNameForPath(requestedPath: string): string | undefined;
|
|
2
|
+
export declare function isWindowsDriveRelativePath(requestedPath: string): boolean;
|
|
3
|
+
export declare function normalizePath(p: string): string;
|
|
4
|
+
export declare const IS_CASE_INSENSITIVE_FS: boolean;
|
|
5
|
+
export declare function isSamePath(left: string, right: string): boolean;
|
|
6
|
+
export declare function normalizeAllowedDirectory(dir: string): string;
|
|
7
|
+
export declare function isPathInsideDirectory(normalizedDirectory: string, normalizedCandidate: string): boolean;
|
|
8
|
+
export declare function isPathWithinDirectories(normalizedPath: string, allowedDirs: readonly string[]): boolean;
|
|
9
|
+
//# sourceMappingURL=path-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-utils.d.ts","sourceRoot":"","sources":["../../src/core/path-utils.ts"],"names":[],"mappings":"AAwCA,wBAAgB,4BAA4B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAStF;AAED,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAkBzE;AAUD,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAa/C;AAED,eAAO,MAAM,sBAAsB,SAAwC,CAAC;AAM5E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAO/D;AAED,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAa7D;AAED,wBAAgB,qBAAqB,CACnC,mBAAmB,EAAE,MAAM,EAC3B,mBAAmB,EAAE,MAAM,GAC1B,OAAO,CAST;AAED,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,SAAS,MAAM,EAAE,GAC7B,OAAO,CAET"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { homedir, platform } from 'node:os';
|
|
2
|
+
import { join, parse, resolve, sep } from 'node:path';
|
|
3
|
+
import { IS_WINDOWS, isAlpha, isSlash } from './primitives.js';
|
|
4
|
+
const CHAR_COLON = 58;
|
|
5
|
+
const HOMEDIR = homedir();
|
|
6
|
+
const RESERVED_DEVICE_NAMES = new Set([
|
|
7
|
+
'CON',
|
|
8
|
+
'PRN',
|
|
9
|
+
'AUX',
|
|
10
|
+
'NUL',
|
|
11
|
+
'COM1',
|
|
12
|
+
'COM2',
|
|
13
|
+
'COM3',
|
|
14
|
+
'COM4',
|
|
15
|
+
'COM5',
|
|
16
|
+
'COM6',
|
|
17
|
+
'COM7',
|
|
18
|
+
'COM8',
|
|
19
|
+
'COM9',
|
|
20
|
+
'LPT1',
|
|
21
|
+
'LPT2',
|
|
22
|
+
'LPT3',
|
|
23
|
+
'LPT4',
|
|
24
|
+
'LPT5',
|
|
25
|
+
'LPT6',
|
|
26
|
+
'LPT7',
|
|
27
|
+
'LPT8',
|
|
28
|
+
'LPT9',
|
|
29
|
+
]);
|
|
30
|
+
function getReservedDeviceName(segment) {
|
|
31
|
+
const trimmed = segment.replace(/[. ]+$/, '');
|
|
32
|
+
const withoutStream = trimmed.split(':')[0] ?? '';
|
|
33
|
+
const baseName = (withoutStream.split('.')[0] ?? '').toUpperCase();
|
|
34
|
+
return RESERVED_DEVICE_NAMES.has(baseName) ? baseName : undefined;
|
|
35
|
+
}
|
|
36
|
+
export function getReservedDeviceNameForPath(requestedPath) {
|
|
37
|
+
const segments = requestedPath.split(/[\\/]/u);
|
|
38
|
+
for (const segment of segments) {
|
|
39
|
+
const reserved = getReservedDeviceName(segment);
|
|
40
|
+
if (reserved) {
|
|
41
|
+
return reserved;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
export function isWindowsDriveRelativePath(requestedPath) {
|
|
47
|
+
// Check on all platforms so cross-platform clients cannot smuggle drive-relative
|
|
48
|
+
// inputs (e.g. C:relative) to a POSIX-hosted server where path.resolve would
|
|
49
|
+
// silently expand them relative to CWD.
|
|
50
|
+
if (requestedPath.length < 2) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
if (requestedPath.charCodeAt(1) !== CHAR_COLON) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if (!isAlpha(requestedPath.charCodeAt(0))) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (requestedPath.length === 2) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
return !isSlash(requestedPath.charCodeAt(2));
|
|
63
|
+
}
|
|
64
|
+
function expandHome(filepath) {
|
|
65
|
+
if (filepath === '~' || filepath.startsWith('~/') || filepath.startsWith('~\\')) {
|
|
66
|
+
const rest = filepath.slice(1).replace(/^[/\\]+/, '');
|
|
67
|
+
return rest ? join(HOMEDIR, rest) : HOMEDIR;
|
|
68
|
+
}
|
|
69
|
+
return filepath;
|
|
70
|
+
}
|
|
71
|
+
export function normalizePath(p) {
|
|
72
|
+
const resolved = resolve(expandHome(p));
|
|
73
|
+
// On Windows only the drive letter is lowercased (e.g. "C:\Foo\Bar").
|
|
74
|
+
// The rest of the path retains its original casing.
|
|
75
|
+
// IMPORTANT: callers must use isSamePath / isPathInsideDirectory for all
|
|
76
|
+
// equality and containment checks — never raw string equality — because
|
|
77
|
+
// those helpers apply full case-folding before comparing.
|
|
78
|
+
if (IS_WINDOWS && resolved.length >= 2 && resolved.charCodeAt(1) === CHAR_COLON) {
|
|
79
|
+
return resolved.charAt(0).toLowerCase() + resolved.slice(1);
|
|
80
|
+
}
|
|
81
|
+
return resolved;
|
|
82
|
+
}
|
|
83
|
+
export const IS_CASE_INSENSITIVE_FS = IS_WINDOWS || platform() === 'darwin';
|
|
84
|
+
function normalizeCaseForComparison(value) {
|
|
85
|
+
return IS_CASE_INSENSITIVE_FS ? value.toLowerCase() : value;
|
|
86
|
+
}
|
|
87
|
+
export function isSamePath(left, right) {
|
|
88
|
+
if (left === right) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
const leftResolved = normalizeCaseForComparison(resolve(left));
|
|
92
|
+
const rightResolved = normalizeCaseForComparison(resolve(right));
|
|
93
|
+
return leftResolved === rightResolved;
|
|
94
|
+
}
|
|
95
|
+
export function normalizeAllowedDirectory(dir) {
|
|
96
|
+
const trimmed = dir.trim();
|
|
97
|
+
if (trimmed.length === 0)
|
|
98
|
+
return '';
|
|
99
|
+
const normalized = normalizePath(trimmed);
|
|
100
|
+
const { root } = parse(normalized);
|
|
101
|
+
// Keep filesystem roots as-is ("/", "c:\\", "\\\\server\\share\\").
|
|
102
|
+
if (isSamePath(normalized, root)) {
|
|
103
|
+
return root;
|
|
104
|
+
}
|
|
105
|
+
return normalized.length > 1 && normalized.endsWith(sep) ? normalized.slice(0, -1) : normalized;
|
|
106
|
+
}
|
|
107
|
+
export function isPathInsideDirectory(normalizedDirectory, normalizedCandidate) {
|
|
108
|
+
const root = normalizeCaseForComparison(normalizedDirectory);
|
|
109
|
+
const candidate = normalizeCaseForComparison(normalizedCandidate);
|
|
110
|
+
if (root === candidate)
|
|
111
|
+
return true;
|
|
112
|
+
if (!candidate.startsWith(root))
|
|
113
|
+
return false;
|
|
114
|
+
if (isSlash(root.charCodeAt(root.length - 1)))
|
|
115
|
+
return true;
|
|
116
|
+
return isSlash(candidate.charCodeAt(root.length));
|
|
117
|
+
}
|
|
118
|
+
export function isPathWithinDirectories(normalizedPath, allowedDirs) {
|
|
119
|
+
return allowedDirs.some((dir) => isPathInsideDirectory(dir, normalizedPath));
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=path-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../../src/core/path-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/D,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,OAAO,GAAG,OAAO,EAAE,CAAC;AAE1B,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAS;IAC5C,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;CACP,CAAC,CAAC;AAEH,SAAS,qBAAqB,CAAC,OAAe;IAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC9C,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAClD,MAAM,QAAQ,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IACnE,OAAO,qBAAqB,CAAC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cAAc,CAAC,CAAC,CAAC;AAC/E,CAAC","sourcesContent":["import { homedir, platform } from 'node:os';\nimport { join, parse, resolve, sep } from 'node:path';\n\nimport { IS_WINDOWS, isAlpha, isSlash } from './primitives.js';\n\nconst CHAR_COLON = 58;\nconst HOMEDIR = homedir();\n\nconst RESERVED_DEVICE_NAMES = new Set<string>([\n 'CON',\n 'PRN',\n 'AUX',\n 'NUL',\n 'COM1',\n 'COM2',\n 'COM3',\n 'COM4',\n 'COM5',\n 'COM6',\n 'COM7',\n 'COM8',\n 'COM9',\n 'LPT1',\n 'LPT2',\n 'LPT3',\n 'LPT4',\n 'LPT5',\n 'LPT6',\n 'LPT7',\n 'LPT8',\n 'LPT9',\n]);\n\nfunction getReservedDeviceName(segment: string): string | undefined {\n const trimmed = segment.replace(/[. ]+$/, '');\n const withoutStream = trimmed.split(':')[0] ?? '';\n const baseName = (withoutStream.split('.')[0] ?? '').toUpperCase();\n return RESERVED_DEVICE_NAMES.has(baseName) ? baseName : undefined;\n}\n\nexport function getReservedDeviceNameForPath(requestedPath: string): string | undefined {\n const segments = requestedPath.split(/[\\\\/]/u);\n for (const segment of segments) {\n const reserved = getReservedDeviceName(segment);\n if (reserved) {\n return reserved;\n }\n }\n return undefined;\n}\n\nexport function isWindowsDriveRelativePath(requestedPath: string): boolean {\n // Check on all platforms so cross-platform clients cannot smuggle drive-relative\n // inputs (e.g. C:relative) to a POSIX-hosted server where path.resolve would\n // silently expand them relative to CWD.\n if (requestedPath.length < 2) {\n return false;\n }\n if (requestedPath.charCodeAt(1) !== CHAR_COLON) {\n return false;\n }\n if (!isAlpha(requestedPath.charCodeAt(0))) {\n return false;\n }\n\n if (requestedPath.length === 2) {\n return true;\n }\n return !isSlash(requestedPath.charCodeAt(2));\n}\n\nfunction expandHome(filepath: string): string {\n if (filepath === '~' || filepath.startsWith('~/') || filepath.startsWith('~\\\\')) {\n const rest = filepath.slice(1).replace(/^[/\\\\]+/, '');\n return rest ? join(HOMEDIR, rest) : HOMEDIR;\n }\n return filepath;\n}\n\nexport function normalizePath(p: string): string {\n const resolved = resolve(expandHome(p));\n\n // On Windows only the drive letter is lowercased (e.g. \"C:\\Foo\\Bar\").\n // The rest of the path retains its original casing.\n // IMPORTANT: callers must use isSamePath / isPathInsideDirectory for all\n // equality and containment checks — never raw string equality — because\n // those helpers apply full case-folding before comparing.\n if (IS_WINDOWS && resolved.length >= 2 && resolved.charCodeAt(1) === CHAR_COLON) {\n return resolved.charAt(0).toLowerCase() + resolved.slice(1);\n }\n\n return resolved;\n}\n\nexport const IS_CASE_INSENSITIVE_FS = IS_WINDOWS || platform() === 'darwin';\n\nfunction normalizeCaseForComparison(value: string): string {\n return IS_CASE_INSENSITIVE_FS ? value.toLowerCase() : value;\n}\n\nexport function isSamePath(left: string, right: string): boolean {\n if (left === right) {\n return true;\n }\n const leftResolved = normalizeCaseForComparison(resolve(left));\n const rightResolved = normalizeCaseForComparison(resolve(right));\n return leftResolved === rightResolved;\n}\n\nexport function normalizeAllowedDirectory(dir: string): string {\n const trimmed = dir.trim();\n if (trimmed.length === 0) return '';\n\n const normalized = normalizePath(trimmed);\n const { root } = parse(normalized);\n\n // Keep filesystem roots as-is (\"/\", \"c:\\\\\", \"\\\\\\\\server\\\\share\\\\\").\n if (isSamePath(normalized, root)) {\n return root;\n }\n\n return normalized.length > 1 && normalized.endsWith(sep) ? normalized.slice(0, -1) : normalized;\n}\n\nexport function isPathInsideDirectory(\n normalizedDirectory: string,\n normalizedCandidate: string,\n): boolean {\n const root = normalizeCaseForComparison(normalizedDirectory);\n const candidate = normalizeCaseForComparison(normalizedCandidate);\n\n if (root === candidate) return true;\n if (!candidate.startsWith(root)) return false;\n\n if (isSlash(root.charCodeAt(root.length - 1))) return true;\n return isSlash(candidate.charCodeAt(root.length));\n}\n\nexport function isPathWithinDirectories(\n normalizedPath: string,\n allowedDirs: readonly string[],\n): boolean {\n return allowedDirs.some((dir) => isPathInsideDirectory(dir, normalizedPath));\n}\n"]}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { isSlash, toPosixPath } from './primitives.js';
|
|
2
|
+
import type { EntryType } from './primitives.js';
|
|
3
|
+
export { isSlash, toPosixPath };
|
|
4
|
+
declare const ValidatedPathBrand: unique symbol;
|
|
5
|
+
export type ValidatedPath = string & {
|
|
6
|
+
readonly [ValidatedPathBrand]: true;
|
|
7
|
+
};
|
|
8
|
+
export interface ValidatedPathDetails {
|
|
9
|
+
requestedPath: string;
|
|
10
|
+
resolvedPath: string;
|
|
11
|
+
isSymlink: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface ServerOptions {
|
|
14
|
+
allowCwd?: boolean;
|
|
15
|
+
cliAllowedDirs?: string[];
|
|
16
|
+
readOnly?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** `path.relative` with forward slashes, so displayed paths match across platforms. */
|
|
19
|
+
export declare function toPosixRelative(from: string, to: string): string;
|
|
20
|
+
export interface AllowedDirectoriesState {
|
|
21
|
+
primary: string[];
|
|
22
|
+
expanded: string[];
|
|
23
|
+
}
|
|
24
|
+
export declare function normalizeAllowedDirectories(dirs: readonly string[]): string[];
|
|
25
|
+
export declare function resolveRealPath(normalized: string, signal?: AbortSignal): Promise<string | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Accepted risk: validation methods resolve/verify a path (symlinks, boundaries,
|
|
28
|
+
* sensitivity) and then return a plain string; the actual fs operation happens
|
|
29
|
+
* afterward as a separate syscall (classic TOCTOU). A symlink swapped in that
|
|
30
|
+
* exact window could redirect the follow-up operation. This is mitigated by
|
|
31
|
+
* re-validating the resolved real path (not just the requested path) and by
|
|
32
|
+
* walking ancestors to catch escapes before the target exists, but it is not
|
|
33
|
+
* eliminated — doing so would require fd-based operations (open with
|
|
34
|
+
* O_NOFOLLOW / operate on the resolved fd) throughout core/fs.ts. Acceptable
|
|
35
|
+
* tradeoff for a local, single-user filesystem server today.
|
|
36
|
+
*/
|
|
37
|
+
export declare class PathGuard {
|
|
38
|
+
#private;
|
|
39
|
+
private allowedDirectoriesState;
|
|
40
|
+
private readonly sensitive;
|
|
41
|
+
/**
|
|
42
|
+
* Directories added by an accepted access grant (R8) — from the tool
|
|
43
|
+
* executor's grant round-trip, or from a client's declared workspace roots on
|
|
44
|
+
* the legacy stdio leg. Held separately from the configured baseline because
|
|
45
|
+
* `recomputeAllowedDirectories` rebuilds that baseline from CLI args and env
|
|
46
|
+
* on every call: anything merged into it would be recomputed away.
|
|
47
|
+
*
|
|
48
|
+
* These are NOT filtered against the baseline. A granted directory is
|
|
49
|
+
* out-of-baseline by definition, so a baseline filter dropped every one while
|
|
50
|
+
* `applyGrant` still reported success — the whole round-trip prompted the
|
|
51
|
+
* user and then changed nothing. FS_ROOT_BOUNDARY and the unsafe-path denylist
|
|
52
|
+
* remain the limits, both checked in `applyGrant` — the only writer of this
|
|
53
|
+
* field — so the recompute can rebuild from it without re-filtering.
|
|
54
|
+
*/
|
|
55
|
+
private grantedDirectories;
|
|
56
|
+
private rootBoundaries;
|
|
57
|
+
readonly options: ServerOptions | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* True when this guard backs a live MCP server rather than a one-shot CLI
|
|
60
|
+
* invocation. Operator-facing configuration warnings are suppressed unless
|
|
61
|
+
* it is set, so `--print-config` and unit construction stay quiet.
|
|
62
|
+
*/
|
|
63
|
+
readonly isServerContext: boolean;
|
|
64
|
+
constructor(options?: ServerOptions, isServerContext?: boolean);
|
|
65
|
+
static fromAllowedDirectories(dirs: readonly string[], signal?: AbortSignal): Promise<PathGuard>;
|
|
66
|
+
initialize(state: AllowedDirectoriesState): void;
|
|
67
|
+
isInitialized(): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Run `fn` as the next holder of the guard's single mutation lock. Every
|
|
70
|
+
* change to the allowed set goes through this so concurrent grants cannot
|
|
71
|
+
* interleave their read-`await`-write and lose a grant (GRANT-1).
|
|
72
|
+
*/
|
|
73
|
+
private runExclusive;
|
|
74
|
+
getAllowedDirectories(): string[];
|
|
75
|
+
getRootBoundaries(): string[];
|
|
76
|
+
isSensitive(filePath: string): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* True when `entryPath` is both within the guard's allowed directories and
|
|
79
|
+
* not sensitive, checking the requested AND resolved paths. EVERY entry is
|
|
80
|
+
* realpath-resolved via validateExistingPathDetailed: a symlinked ancestor
|
|
81
|
+
* directory pointing outside the sandbox would otherwise pass the lexical
|
|
82
|
+
* containment check (fs.glob follows symlinks and yields external entries as
|
|
83
|
+
* non-symlink dirents). validateExistingPathDetailed re-checks containment on
|
|
84
|
+
* the real path against this.allowedDirectoriesState.expanded (the guard's full
|
|
85
|
+
* allowed set — a superset of the single-root `bounds` callers pass) and
|
|
86
|
+
* re-checks sensitivity on the resolved target, throwing ACCESS_DENIED for
|
|
87
|
+
* escapes/sensitive, which the catch below turns into a filter. `_entryType`
|
|
88
|
+
* and `_bounds` are retained for call-site compatibility while the guard's own
|
|
89
|
+
* allowed set is the real gate. Skippable errno/fs errors return false (the
|
|
90
|
+
* entry is filtered, not fatal). The accepted TOCTOU window is documented at
|
|
91
|
+
* the class docstring above.
|
|
92
|
+
*/
|
|
93
|
+
isEntryAccessible(entryPath: string, _entryType: EntryType, _bounds: readonly string[]): Promise<boolean>;
|
|
94
|
+
validateExistingPath(requestedPath: string): Promise<ValidatedPath>;
|
|
95
|
+
/** True when a normalized path equals its own filesystem root (`C:\`, `/`). */
|
|
96
|
+
private isFilesystemRoot;
|
|
97
|
+
/**
|
|
98
|
+
* True when a grant must never admit `targetDir` — a bare filesystem root, or
|
|
99
|
+
* an unsafe path (home, /etc, C:\Windows, ...). Checked on the lexical path
|
|
100
|
+
* AND on the one it resolves to: `expandAllowedDirectories` pushes each root's
|
|
101
|
+
* realpath into the allowed set, so a lexical-only check let a symlink or
|
|
102
|
+
* junction aliasing $HOME/C:\Windows in under an innocuous name — and the
|
|
103
|
+
* confirmation prompt showed the alias, not the target. A target that cannot
|
|
104
|
+
* be resolved is judged lexically; it does not exist to escape into.
|
|
105
|
+
*/
|
|
106
|
+
private isUnsafeGrantTarget;
|
|
107
|
+
/** Walk up from a blocked path to the closest existing ancestor directory. */
|
|
108
|
+
private resolveGrantTargetDir;
|
|
109
|
+
/**
|
|
110
|
+
* Pre-check (no mutation, no callback): given the paths a tool is about to
|
|
111
|
+
* operate on, return the sorted, de-duplicated grant-target directories for
|
|
112
|
+
* those that are outside the allowed roots AND grantable (within FS_ROOT_BOUNDARY
|
|
113
|
+
* when it is configured). A path whose nearest existing ancestor escapes the
|
|
114
|
+
* boundary is NOT grantable and is omitted — the operation will fail with
|
|
115
|
+
* ACCESS_DENIED for it rather than prompt. The caller returns an
|
|
116
|
+
* `input_required` result carrying exactly this set (R7), and on retry applies
|
|
117
|
+
* each accepted grant via {@link applyGrant} (R8). `requestState` binds this
|
|
118
|
+
* set so a grant accepted for X cannot authorize Y (R9).
|
|
119
|
+
*/
|
|
120
|
+
precheckAccess(paths: readonly string[]): Promise<string[]>;
|
|
121
|
+
/**
|
|
122
|
+
* Apply an accepted access grant: enforce FS_ROOT_BOUNDARY again (a TOCTOU
|
|
123
|
+
* re-check against the boundary resolved at config time), then extend the
|
|
124
|
+
* allowed roots for the remainder of the session (R8, A4). Returns false when
|
|
125
|
+
* the boundary or the unsafe-path denylist blocks the grant, AND when the
|
|
126
|
+
* recompute did not actually admit the directory — the return value now
|
|
127
|
+
* reports what the guard's allowed set really holds, not merely that the
|
|
128
|
+
* pre-checks passed. The caller leaves a refused path to fail with
|
|
129
|
+
* ACCESS_DENIED during the operation. Idempotent: re-granting an already
|
|
130
|
+
* allowed directory is a no-op via the dedup in `initialize`.
|
|
131
|
+
*/
|
|
132
|
+
applyGrant(targetDir: string): Promise<boolean>;
|
|
133
|
+
private isWithinBoundary;
|
|
134
|
+
private validateAccessAndSensitivity;
|
|
135
|
+
private validateAccess;
|
|
136
|
+
private handleRealpathError;
|
|
137
|
+
validateExistingPathDetailed(requestedPath: string): Promise<ValidatedPathDetails>;
|
|
138
|
+
validateExistingDirectory(requestedPath: string): Promise<string>;
|
|
139
|
+
resolvePathOrRoot(pathValue: string | undefined): string;
|
|
140
|
+
isAllowedRoot(normalizedPath: string): boolean;
|
|
141
|
+
private assertNotSensitiveFile;
|
|
142
|
+
private throwAccessDenied;
|
|
143
|
+
private resolveNearestExistingAncestor;
|
|
144
|
+
validatePathForWrite(requestedPath: string): Promise<ValidatedPath>;
|
|
145
|
+
validatePathForDelete(requestedPath: string): Promise<ValidatedPath>;
|
|
146
|
+
recomputeAllowedDirectories(): Promise<void>;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/core/path.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAE,OAAO,EAAoB,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAMjD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AAMhC,OAAO,CAAC,MAAM,kBAAkB,EAAE,OAAO,MAAM,CAAC;AAChD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,kBAAkB,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAE7E,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAuDD,uFAAuF;AACvF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,E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