@n8n/fs-proxy 0.1.0-rc1

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.
Files changed (106) hide show
  1. package/LICENSE.md +88 -0
  2. package/README.md +267 -0
  3. package/dist/build.tsbuildinfo +1 -0
  4. package/dist/cli.d.ts +2 -0
  5. package/dist/cli.js +189 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/config-templates.d.ts +10 -0
  8. package/dist/config-templates.js +39 -0
  9. package/dist/config-templates.js.map +1 -0
  10. package/dist/config.d.ts +67 -0
  11. package/dist/config.js +285 -0
  12. package/dist/config.js.map +1 -0
  13. package/dist/confirm-resource-cli.d.ts +4 -0
  14. package/dist/confirm-resource-cli.js +28 -0
  15. package/dist/confirm-resource-cli.js.map +1 -0
  16. package/dist/daemon.d.ts +11 -0
  17. package/dist/daemon.js +249 -0
  18. package/dist/daemon.js.map +1 -0
  19. package/dist/gateway-client.d.ts +38 -0
  20. package/dist/gateway-client.js +401 -0
  21. package/dist/gateway-client.js.map +1 -0
  22. package/dist/logger.d.ts +26 -0
  23. package/dist/logger.js +350 -0
  24. package/dist/logger.js.map +1 -0
  25. package/dist/settings-store.d.ts +29 -0
  26. package/dist/settings-store.js +224 -0
  27. package/dist/settings-store.js.map +1 -0
  28. package/dist/startup-config-cli.d.ts +5 -0
  29. package/dist/startup-config-cli.js +185 -0
  30. package/dist/startup-config-cli.js.map +1 -0
  31. package/dist/tools/browser/index.d.ts +14 -0
  32. package/dist/tools/browser/index.js +72 -0
  33. package/dist/tools/browser/index.js.map +1 -0
  34. package/dist/tools/filesystem/constants.d.ts +1 -0
  35. package/dist/tools/filesystem/constants.js +5 -0
  36. package/dist/tools/filesystem/constants.js.map +1 -0
  37. package/dist/tools/filesystem/copy-file.d.ts +14 -0
  38. package/dist/tools/filesystem/copy-file.js +65 -0
  39. package/dist/tools/filesystem/copy-file.js.map +1 -0
  40. package/dist/tools/filesystem/create-directory.d.ts +11 -0
  41. package/dist/tools/filesystem/create-directory.js +60 -0
  42. package/dist/tools/filesystem/create-directory.js.map +1 -0
  43. package/dist/tools/filesystem/delete.d.ts +11 -0
  44. package/dist/tools/filesystem/delete.js +64 -0
  45. package/dist/tools/filesystem/delete.js.map +1 -0
  46. package/dist/tools/filesystem/edit-file.d.ts +17 -0
  47. package/dist/tools/filesystem/edit-file.js +71 -0
  48. package/dist/tools/filesystem/edit-file.js.map +1 -0
  49. package/dist/tools/filesystem/fs-utils.d.ts +15 -0
  50. package/dist/tools/filesystem/fs-utils.js +178 -0
  51. package/dist/tools/filesystem/fs-utils.js.map +1 -0
  52. package/dist/tools/filesystem/get-file-tree.d.ts +14 -0
  53. package/dist/tools/filesystem/get-file-tree.js +38 -0
  54. package/dist/tools/filesystem/get-file-tree.js.map +1 -0
  55. package/dist/tools/filesystem/index.d.ts +3 -0
  56. package/dist/tools/filesystem/index.js +28 -0
  57. package/dist/tools/filesystem/index.js.map +1 -0
  58. package/dist/tools/filesystem/list-files.d.ts +17 -0
  59. package/dist/tools/filesystem/list-files.js +76 -0
  60. package/dist/tools/filesystem/list-files.js.map +1 -0
  61. package/dist/tools/filesystem/move.d.ts +14 -0
  62. package/dist/tools/filesystem/move.js +65 -0
  63. package/dist/tools/filesystem/move.js.map +1 -0
  64. package/dist/tools/filesystem/read-file.d.ts +17 -0
  65. package/dist/tools/filesystem/read-file.js +86 -0
  66. package/dist/tools/filesystem/read-file.js.map +1 -0
  67. package/dist/tools/filesystem/search-files.d.ts +23 -0
  68. package/dist/tools/filesystem/search-files.js +128 -0
  69. package/dist/tools/filesystem/search-files.js.map +1 -0
  70. package/dist/tools/filesystem/write-file.d.ts +14 -0
  71. package/dist/tools/filesystem/write-file.js +68 -0
  72. package/dist/tools/filesystem/write-file.js.map +1 -0
  73. package/dist/tools/monitor-utils.d.ts +2 -0
  74. package/dist/tools/monitor-utils.js +11 -0
  75. package/dist/tools/monitor-utils.js.map +1 -0
  76. package/dist/tools/mouse-keyboard/index.d.ts +2 -0
  77. package/dist/tools/mouse-keyboard/index.js +70 -0
  78. package/dist/tools/mouse-keyboard/index.js.map +1 -0
  79. package/dist/tools/mouse-keyboard/mouse-keyboard.d.ts +130 -0
  80. package/dist/tools/mouse-keyboard/mouse-keyboard.js +249 -0
  81. package/dist/tools/mouse-keyboard/mouse-keyboard.js.map +1 -0
  82. package/dist/tools/screenshot/index.d.ts +2 -0
  83. package/dist/tools/screenshot/index.js +26 -0
  84. package/dist/tools/screenshot/index.js.map +1 -0
  85. package/dist/tools/screenshot/screenshot.d.ts +22 -0
  86. package/dist/tools/screenshot/screenshot.js +91 -0
  87. package/dist/tools/screenshot/screenshot.js.map +1 -0
  88. package/dist/tools/shell/build-shell-resource.d.ts +1 -0
  89. package/dist/tools/shell/build-shell-resource.js +70 -0
  90. package/dist/tools/shell/build-shell-resource.js.map +1 -0
  91. package/dist/tools/shell/index.d.ts +2 -0
  92. package/dist/tools/shell/index.js +11 -0
  93. package/dist/tools/shell/index.js.map +1 -0
  94. package/dist/tools/shell/shell-execute.d.ts +17 -0
  95. package/dist/tools/shell/shell-execute.js +88 -0
  96. package/dist/tools/shell/shell-execute.js.map +1 -0
  97. package/dist/tools/test-utils.d.ts +3 -0
  98. package/dist/tools/test-utils.js +16 -0
  99. package/dist/tools/test-utils.js.map +1 -0
  100. package/dist/tools/types.d.ts +43 -0
  101. package/dist/tools/types.js +3 -0
  102. package/dist/tools/types.js.map +1 -0
  103. package/dist/tools/utils.d.ts +3 -0
  104. package/dist/tools/utils.js +19 -0
  105. package/dist/tools/utils.js.map +1 -0
  106. package/package.json +55 -0
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.EXCLUDED_DIRS = void 0;
37
+ exports.scanDirectory = scanDirectory;
38
+ exports.resolveSafePath = resolveSafePath;
39
+ exports.buildFilesystemResource = buildFilesystemResource;
40
+ const fs = __importStar(require("node:fs/promises"));
41
+ const path = __importStar(require("node:path"));
42
+ const MAX_ENTRIES = 10_000;
43
+ const DEFAULT_MAX_DEPTH = 8;
44
+ exports.EXCLUDED_DIRS = new Set([
45
+ 'node_modules',
46
+ '.git',
47
+ 'dist',
48
+ 'build',
49
+ 'coverage',
50
+ '__pycache__',
51
+ '.venv',
52
+ 'venv',
53
+ '.vscode',
54
+ '.idea',
55
+ '.next',
56
+ '.nuxt',
57
+ '.cache',
58
+ '.turbo',
59
+ '.output',
60
+ '.svelte-kit',
61
+ ]);
62
+ async function scanDirectory(dirPath, maxDepth = DEFAULT_MAX_DEPTH) {
63
+ const rootName = path.resolve(dirPath);
64
+ const entries = [];
65
+ let truncated = false;
66
+ const queue = [[dirPath, '', 0]];
67
+ while (queue.length > 0) {
68
+ if (entries.length >= MAX_ENTRIES) {
69
+ truncated = true;
70
+ break;
71
+ }
72
+ const [fullPath, relativePath, depth] = queue.shift();
73
+ let dirEntries;
74
+ try {
75
+ dirEntries = await fs.readdir(fullPath, { withFileTypes: true });
76
+ }
77
+ catch {
78
+ continue;
79
+ }
80
+ const sorted = dirEntries.sort((a, b) => {
81
+ if (a.isDirectory() && !b.isDirectory())
82
+ return -1;
83
+ if (!a.isDirectory() && b.isDirectory())
84
+ return 1;
85
+ return a.name.localeCompare(b.name);
86
+ });
87
+ for (const entry of sorted) {
88
+ if (entries.length >= MAX_ENTRIES) {
89
+ truncated = true;
90
+ break;
91
+ }
92
+ if (exports.EXCLUDED_DIRS.has(entry.name) && entry.isDirectory())
93
+ continue;
94
+ if (entry.name.startsWith('.') && !isAllowedDotFile(entry.name))
95
+ continue;
96
+ const entryRelPath = relativePath ? `${relativePath}/${entry.name}` : entry.name;
97
+ if (entry.isDirectory()) {
98
+ entries.push({ path: entryRelPath, type: 'directory' });
99
+ if (depth < maxDepth) {
100
+ queue.push([path.join(fullPath, entry.name), entryRelPath, depth + 1]);
101
+ }
102
+ else {
103
+ truncated = true;
104
+ }
105
+ }
106
+ else if (entry.isFile()) {
107
+ try {
108
+ const fullEntryPath = path.join(fullPath, entry.name);
109
+ const stat = await fs.stat(fullEntryPath);
110
+ entries.push({ path: entryRelPath, type: 'file', sizeBytes: stat.size });
111
+ }
112
+ catch {
113
+ entries.push({ path: entryRelPath, type: 'file' });
114
+ }
115
+ }
116
+ }
117
+ }
118
+ return { rootPath: rootName, tree: entries, truncated };
119
+ }
120
+ function isAllowedDotFile(name) {
121
+ const allowed = new Set([
122
+ '.env',
123
+ '.env.example',
124
+ '.eslintrc',
125
+ '.eslintrc.js',
126
+ '.eslintrc.json',
127
+ '.prettierrc',
128
+ '.prettierrc.js',
129
+ '.prettierrc.json',
130
+ '.editorconfig',
131
+ '.gitignore',
132
+ '.dockerignore',
133
+ '.nvmrc',
134
+ '.node-version',
135
+ '.npmrc',
136
+ '.babelrc',
137
+ '.browserslistrc',
138
+ ]);
139
+ return allowed.has(name);
140
+ }
141
+ async function resolveSafePath(basePath, relativePath) {
142
+ const realBase = await fs.realpath(basePath);
143
+ const absolute = path.resolve(basePath, relativePath);
144
+ const root = path.parse(absolute).root;
145
+ const parts = path.relative(root, absolute).split(path.sep).filter(Boolean);
146
+ let current = root;
147
+ for (let i = 0; i < parts.length; i++) {
148
+ const next = path.join(current, parts[i]);
149
+ try {
150
+ current = await fs.realpath(next);
151
+ }
152
+ catch (realpathError) {
153
+ if (realpathError.code !== 'ENOENT')
154
+ throw realpathError;
155
+ try {
156
+ const lstat = await fs.lstat(next);
157
+ if (lstat.isSymbolicLink()) {
158
+ const target = await fs.readlink(next);
159
+ current = path.resolve(current, target);
160
+ continue;
161
+ }
162
+ }
163
+ catch {
164
+ }
165
+ current = path.join(current, ...parts.slice(i));
166
+ break;
167
+ }
168
+ }
169
+ if (!current.startsWith(realBase + path.sep) && current !== realBase) {
170
+ throw new Error(`Path "${relativePath}" escapes the base directory`);
171
+ }
172
+ return absolute;
173
+ }
174
+ async function buildFilesystemResource(dir, inputPath, toolGroup, description) {
175
+ const absolutePath = await resolveSafePath(dir, inputPath);
176
+ return { toolGroup, resource: absolutePath, description };
177
+ }
178
+ //# sourceMappingURL=fs-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-utils.js","sourceRoot":"","sources":["../../../src/tools/filesystem/fs-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,sCAgEC;AA2CD,0CA2CC;AAOD,0DAQC;AAjND,qDAAuC;AACvC,gDAAkC;AAIlC,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEf,QAAA,aAAa,GAAG,IAAI,GAAG,CAAC;IACpC,cAAc;IACd,MAAM;IACN,M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GAAG,MAAM,eAAe,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC3D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ import type { ToolDefinition } from '../types';
3
+ declare const inputSchema: z.ZodObject<{
4
+ dirPath: z.ZodString;
5
+ maxDepth: z.ZodOptional<z.ZodNumber>;
6
+ }, "strip", z.ZodTypeAny, {
7
+ dirPath: string;
8
+ maxDepth?: number | undefined;
9
+ }, {
10
+ dirPath: string;
11
+ maxDepth?: number | undefined;
12
+ }>;
13
+ export declare const getFileTreeTool: ToolDefinition<typeof inputSchema>;
14
+ export {};
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFileTreeTool = void 0;
4
+ const zod_1 = require("zod");
5
+ const fs_utils_1 = require("./fs-utils");
6
+ const inputSchema = zod_1.z.object({
7
+ dirPath: zod_1.z.string().describe('Directory path relative to root (use "." for root)'),
8
+ maxDepth: zod_1.z.number().int().optional().describe('Maximum depth to traverse (default: 2)'),
9
+ });
10
+ exports.getFileTreeTool = {
11
+ name: 'get_file_tree',
12
+ description: 'Get an indented directory tree',
13
+ inputSchema,
14
+ annotations: { readOnlyHint: true },
15
+ async getAffectedResources({ dirPath }, { dir }) {
16
+ return [
17
+ await (0, fs_utils_1.buildFilesystemResource)(dir, dirPath ?? '.', 'filesystemRead', `List directory tree: ${dirPath ?? '.'}`),
18
+ ];
19
+ },
20
+ async execute({ dirPath, maxDepth }, { dir }) {
21
+ const resolvedDir = await (0, fs_utils_1.resolveSafePath)(dir, dirPath || '.');
22
+ const depth = maxDepth ?? 2;
23
+ const { rootPath, tree, truncated } = await (0, fs_utils_1.scanDirectory)(resolvedDir, depth);
24
+ const lines = [`${rootPath}/`];
25
+ for (const entry of tree) {
26
+ const entryDepth = entry.path.split('/').length;
27
+ const indent = ' '.repeat(entryDepth);
28
+ const name = entry.path.split('/').pop() ?? entry.path;
29
+ lines.push(`${indent}${name}${entry.type === 'directory' ? '/' : ''}`);
30
+ }
31
+ const parts = [lines.join('\n')];
32
+ if (truncated) {
33
+ parts.push('(Tree truncated — increase maxDepth or explore subdirectories)');
34
+ }
35
+ return { content: [{ type: 'text', text: parts.join('\n\n') }] };
36
+ },
37
+ };
38
+ //# sourceMappingURL=get-file-tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-file-tree.js","sourceRoot":"","sources":["../../../src/tools/filesystem/get-file-tree.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAGxB,yCAAqF;AAErF,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5B,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oDAAoD,CAAC;IAClF,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wCAAwC,CAAC;CACxF,CAAC,CAAC;AAEU,QAAA,eAAe,GAAuC;IAClE,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,gCAAgC;IAC7C,WAAW;IACX,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE;IACnC,KAAK,CAAC,oBAAoB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE;QAC9C,OAAO;YACN,MAAM,IAAA,kCAAuB,EAC5B,GAAG,EACH,OAAO,IAAI,GAAG,EACd,gBAAgB,EAChB,wBAAwB,OAAO,IAAI,GAAG,EAAE,CACxC;SACD,CAAC;IACH,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,EAAE;QAC3C,MAAM,WAAW,GAAG,MAAM,IAAA,0BAAe,EAAC,GAAG,EAAE,OAAO,IAAI,GAAG,CAAC,CAAC;QAC/D,MAAM,KAAK,GAAG,QAAQ,IAAI,CAAC,CAAC;QAC5B,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,MAAM,IAAA,wBAAa,EAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QAE9E,MAAM,KAAK,GAAa,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC;QACzC,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;YAC1B,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;YAChD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YACvC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC;YACvD,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACjC,IAAI,SAAS,EAAE,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAC;QAC9E,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;IAClE,CAAC;CACD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ToolDefinition } from '../types';
2
+ export declare const filesystemReadTools: ToolDefinition[];
3
+ export declare const filesystemWriteTools: ToolDefinition[];
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filesystemWriteTools = exports.filesystemReadTools = void 0;
4
+ const copy_file_1 = require("./copy-file");
5
+ const create_directory_1 = require("./create-directory");
6
+ const delete_1 = require("./delete");
7
+ const edit_file_1 = require("./edit-file");
8
+ const get_file_tree_1 = require("./get-file-tree");
9
+ const list_files_1 = require("./list-files");
10
+ const move_1 = require("./move");
11
+ const read_file_1 = require("./read-file");
12
+ const search_files_1 = require("./search-files");
13
+ const write_file_1 = require("./write-file");
14
+ exports.filesystemReadTools = [
15
+ get_file_tree_1.getFileTreeTool,
16
+ list_files_1.listFilesTool,
17
+ read_file_1.readFileTool,
18
+ search_files_1.searchFilesTool,
19
+ ];
20
+ exports.filesystemWriteTools = [
21
+ write_file_1.writeFileTool,
22
+ edit_file_1.editFileTool,
23
+ create_directory_1.createDirectoryTool,
24
+ delete_1.deleteTool,
25
+ move_1.moveFileTool,
26
+ copy_file_1.copyFileTool,
27
+ ];
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/filesystem/index.ts"],"names":[],"mappings":";;;AACA,2CAA2C;AAC3C,yDAAyD;AACzD,qCAAsC;AACtC,2CAA2C;AAC3C,mDAAkD;AAClD,6CAA6C;AAC7C,iCAAsC;AACtC,2CAA2C;AAC3C,iDAAiD;AACjD,6CAA6C;AAEhC,QAAA,mBAAmB,GAAqB;IACpD,+BAAe;IACf,0BAAa;IACb,wBAAY;IACZ,8BAAe;CACf,CAAC;AAEW,QAAA,oBAAoB,GAAqB;IACrD,0BAAa;IACb,wBAAY;IACZ,sCAAmB;IACnB,mBAAU;IACV,mBAAY;IACZ,wBAAY;CACZ,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+ import type { ToolDefinition } from '../types';
3
+ declare const inputSchema: z.ZodObject<{
4
+ dirPath: z.ZodString;
5
+ type: z.ZodOptional<z.ZodEnum<["file", "directory", "all"]>>;
6
+ maxResults: z.ZodOptional<z.ZodNumber>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ dirPath: string;
9
+ type?: "file" | "directory" | "all" | undefined;
10
+ maxResults?: number | undefined;
11
+ }, {
12
+ dirPath: string;
13
+ type?: "file" | "directory" | "all" | undefined;
14
+ maxResults?: number | undefined;
15
+ }>;
16
+ export declare const listFilesTool: ToolDefinition<typeof inputSchema>;
17
+ export {};
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.listFilesTool = void 0;
37
+ const path = __importStar(require("node:path"));
38
+ const zod_1 = require("zod");
39
+ const fs_utils_1 = require("./fs-utils");
40
+ const inputSchema = zod_1.z.object({
41
+ dirPath: zod_1.z.string().describe('Directory path relative to root'),
42
+ type: zod_1.z
43
+ .enum(['file', 'directory', 'all'])
44
+ .optional()
45
+ .describe('Filter by entry type (default: all)'),
46
+ maxResults: zod_1.z.number().int().optional().describe('Maximum number of results (default: 200)'),
47
+ });
48
+ exports.listFilesTool = {
49
+ name: 'list_files',
50
+ description: 'List immediate children of a directory',
51
+ inputSchema,
52
+ annotations: { readOnlyHint: true },
53
+ async getAffectedResources({ dirPath }, { dir }) {
54
+ return [
55
+ await (0, fs_utils_1.buildFilesystemResource)(dir, dirPath ?? '.', 'filesystemRead', `List files: ${dirPath ?? '.'}`),
56
+ ];
57
+ },
58
+ async execute({ dirPath, type, maxResults }, { dir }) {
59
+ const resolvedDir = await (0, fs_utils_1.resolveSafePath)(dir, dirPath || '.');
60
+ const { tree } = await (0, fs_utils_1.scanDirectory)(resolvedDir, 0);
61
+ const typeFilter = type ?? 'all';
62
+ const filtered = typeFilter === 'all' ? tree : tree.filter((e) => e.type === typeFilter);
63
+ const limit = maxResults ?? 200;
64
+ const relativeDir = path.relative(dir, resolvedDir);
65
+ const entries = filtered.slice(0, limit).map((e) => ({
66
+ path: relativeDir ? `${relativeDir}/${e.path}` : e.path,
67
+ type: e.type,
68
+ sizeBytes: e.sizeBytes,
69
+ }));
70
+ return {
71
+ content: [{ type: 'text', text: JSON.stringify(entries) }],
72
+ structuredContent: { entries },
73
+ };
74
+ },
75
+ };
76
+ //# sourceMappingURL=list-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-files.js","sourceRoot":"","sources":["../../../src/tools/filesystem/list-files.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,6BAAwB;AAGxB,yCAAqF;AAErF,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5B,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;IAC/D,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AAC,GAAG,EAAE,WAAW,CAAC,CAAC;QACpD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACpD,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;YACvD,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,SAAS,EAAE,CAAC,CAAC,SAAS;SACtB,CAAC,CAAC,CAAC;QAEJ,OAAO;YACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1D,iBAAiB,EAAE,EAAE,OAAO,EAAE;SAC9B,CAAC;IACH,CAAC;CACD,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ import type { ToolDefinition } from '../types';
3
+ declare const inputSchema: z.ZodObject<{
4
+ sourcePath: z.ZodString;
5
+ destinationPath: z.ZodString;
6
+ }, "strip", z.ZodTypeAny, {
7
+ sourcePath: string;
8
+ destinationPath: string;
9
+ }, {
10
+ sourcePath: string;
11
+ destinationPath: string;
12
+ }>;
13
+ export declare const moveFileTool: ToolDefinition<typeof inputSchema>;
14
+ export {};
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.moveFileTool = void 0;
37
+ const fs = __importStar(require("node:fs/promises"));
38
+ const path = __importStar(require("node:path"));
39
+ const zod_1 = require("zod");
40
+ const utils_1 = require("../utils");
41
+ const fs_utils_1 = require("./fs-utils");
42
+ const inputSchema = zod_1.z.object({
43
+ sourcePath: zod_1.z.string().describe('Source path relative to root (file or directory)'),
44
+ destinationPath: zod_1.z.string().describe('Destination path relative to root'),
45
+ });
46
+ exports.moveFileTool = {
47
+ name: 'move',
48
+ description: 'Move or rename a file or directory. Overwrites the destination if it already exists. Parent directories at the destination are created automatically.',
49
+ inputSchema,
50
+ annotations: { destructiveHint: true },
51
+ async getAffectedResources({ sourcePath, destinationPath }, { dir }) {
52
+ return [
53
+ await (0, fs_utils_1.buildFilesystemResource)(dir, sourcePath, 'filesystemRead', `Move source: ${sourcePath}`),
54
+ await (0, fs_utils_1.buildFilesystemResource)(dir, destinationPath, 'filesystemWrite', `Move destination: ${destinationPath}`),
55
+ ];
56
+ },
57
+ async execute({ sourcePath, destinationPath }, { dir }) {
58
+ const resolvedSrc = await (0, fs_utils_1.resolveSafePath)(dir, sourcePath);
59
+ const resolvedDest = await (0, fs_utils_1.resolveSafePath)(dir, destinationPath);
60
+ await fs.mkdir(path.dirname(resolvedDest), { recursive: true });
61
+ await fs.rename(resolvedSrc, resolvedDest);
62
+ return (0, utils_1.formatCallToolResult)({ sourcePath, destinationPath });
63
+ },
64
+ };
65
+ //# sourceMappingURL=move.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"move.js","sourceRoot":"","sources":["../../../src/tools/filesystem/move.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,gDAAkC;AAClC,6BAAwB;AAGxB,oCAAgD;AAChD,yCAAsE;AAEtE,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5B,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kDAAkD,CAAC;IACnF,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;CACzE,CAAC,CAAC;AAEU,QAAA,YAAY,GAAuC;IAC/D,IAAI,EAAE,MAAM;IACZ,WAAW,EACV,uJAAuJ;IACxJ,WAAW;IACX,WAAW,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE;IACtC,KAAK,CAAC,oBAAoB,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE,EAAE,GAAG,EAAE;QAClE,OAAO;YACN,MAAM,IAAA,kCAAuB,EAC5B,GAAG,EACH,UAAU,EACV,gBAAgB,EAChB,gBAAgB,UAAU,EAAE,CAC5B;YACD,MAAM,IAAA,kCAAuB,EAC5B,GAAG,EACH,eAAe,EACf,iBAAiB,EACjB,qBAAqB,eAAe,EAAE,CACtC;SACD,CAAC;IACH,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE,EAAE,GAAG,EAAE;QACrD,MAAM,WAAW,GAAG,MAAM,IAAA,0BAAe,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAC3D,MAAM,YAAY,GAAG,MAAM,IAAA,0BAAe,EAAC,GAAG,EAAE,eAAe,CAAC,CAAC;QAEjE,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAChE,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;QAE3C,OAAO,IAAA,4BAAoB,EAAC,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,CAAC;IAC9D,CAAC;CACD,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+ import type { ToolDefinition } from '../types';
3
+ declare const inputSchema: z.ZodObject<{
4
+ filePath: z.ZodString;
5
+ startLine: z.ZodOptional<z.ZodNumber>;
6
+ maxLines: z.ZodOptional<z.ZodNumber>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ filePath: string;
9
+ startLine?: number | undefined;
10
+ maxLines?: number | undefined;
11
+ }, {
12
+ filePath: string;
13
+ startLine?: number | undefined;
14
+ maxLines?: number | undefined;
15
+ }>;
16
+ export declare const readFileTool: ToolDefinition<typeof inputSchema>;
17
+ export {};
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.readFileTool = void 0;
37
+ const fs = __importStar(require("node:fs/promises"));
38
+ const zod_1 = require("zod");
39
+ const utils_1 = require("../utils");
40
+ const constants_1 = require("./constants");
41
+ const fs_utils_1 = require("./fs-utils");
42
+ const DEFAULT_MAX_LINES = 200;
43
+ const BINARY_CHECK_SIZE = 8192;
44
+ const inputSchema = zod_1.z.object({
45
+ filePath: zod_1.z.string().describe('File path relative to root'),
46
+ startLine: zod_1.z.number().int().optional().describe('Starting line number (1-based, default: 1)'),
47
+ maxLines: zod_1.z.number().int().optional().describe('Maximum number of lines (default: 200)'),
48
+ });
49
+ exports.readFileTool = {
50
+ name: 'read_file',
51
+ description: 'Read the contents of a file',
52
+ inputSchema,
53
+ annotations: { readOnlyHint: true },
54
+ async getAffectedResources({ filePath }, { dir }) {
55
+ return [
56
+ await (0, fs_utils_1.buildFilesystemResource)(dir, filePath, 'filesystemRead', `Read file: ${filePath}`),
57
+ ];
58
+ },
59
+ async execute({ filePath, startLine, maxLines }, { dir }) {
60
+ const resolvedPath = await (0, fs_utils_1.resolveSafePath)(dir, filePath);
61
+ const stat = await fs.stat(resolvedPath);
62
+ if (stat.size > constants_1.MAX_FILE_SIZE) {
63
+ throw new Error(`File too large: ${stat.size} bytes (max ${constants_1.MAX_FILE_SIZE} bytes). Use searchFiles for specific content.`);
64
+ }
65
+ const buffer = await fs.readFile(resolvedPath);
66
+ const checkSlice = buffer.subarray(0, Math.min(BINARY_CHECK_SIZE, buffer.length));
67
+ if (checkSlice.includes(0)) {
68
+ throw new Error('Binary file detected — cannot read binary files');
69
+ }
70
+ const fullContent = buffer.toString('utf-8');
71
+ const allLines = fullContent.split('\n');
72
+ const lines = maxLines ?? DEFAULT_MAX_LINES;
73
+ const start = startLine ?? 1;
74
+ const startIndex = Math.max(0, start - 1);
75
+ const slicedLines = allLines.slice(startIndex, startIndex + lines);
76
+ const truncated = allLines.length > startIndex + lines;
77
+ const result = {
78
+ path: filePath,
79
+ content: slicedLines.join('\n'),
80
+ truncated,
81
+ totalLines: allLines.length,
82
+ };
83
+ return (0, utils_1.formatCallToolResult)(result);
84
+ },
85
+ };
86
+ //# sourceMappingURL=read-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-file.js","sourceRoot":"","sources":["../../../src/tools/filesystem/read-file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,6BAAwB;AAGxB,oCAAgD;AAChD,2CAA4C;AAC5C,yCAAsE;AACtE,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;IAC3D,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,4CAA4C,CAAC;IAC7F,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wCAAwC,CAAC;CACxF,CAAC,CAAC;AAEU,QAAA,YAAY,GAAuC;IAC/D,I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B,CAAC;QAC5C,MAAM,KAAK,GAAG,SAAS,IAAI,CAAC,CAAC;QAC7B,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;QAC1C,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAE,UAAU,GAAG,KAAK,CAAC,CAAC;QACnE,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,GAAG,UAAU,GAAG,KAAK,CAAC;QAEvD,MAAM,MAAM,GAAG;YACd,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;YAC/B,SAAS;YACT,UAAU,EAAE,QAAQ,CAAC,MAAM;SAC3B,CAAC;QAEF,OAAO,IAAA,4BAAoB,EAAC,MAAM,CAAC,CAAC;IACrC,CAAC;CACD,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ import type { ToolDefinition } from '../types';
3
+ declare const inputSchema: z.ZodObject<{
4
+ dirPath: z.ZodString;
5
+ query: z.ZodString;
6
+ filePattern: z.ZodOptional<z.ZodString>;
7
+ ignoreCase: z.ZodOptional<z.ZodBoolean>;
8
+ maxResults: z.ZodOptional<z.ZodNumber>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ dirPath: string;
11
+ query: string;
12
+ maxResults?: number | undefined;
13
+ filePattern?: string | undefined;
14
+ ignoreCase?: boolean | undefined;
15
+ }, {
16
+ dirPath: string;
17
+ query: string;
18
+ maxResults?: number | undefined;
19
+ filePattern?: string | undefined;
20
+ ignoreCase?: boolean | undefined;
21
+ }>;
22
+ export declare const searchFilesTool: ToolDefinition<typeof inputSchema>;
23
+ export {};