@defai.digital/mcp-server 13.0.3

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 (178) hide show
  1. package/LICENSE +214 -0
  2. package/dist/bin.d.ts +3 -0
  3. package/dist/bin.d.ts.map +1 -0
  4. package/dist/bin.js +7 -0
  5. package/dist/bin.js.map +1 -0
  6. package/dist/bootstrap.d.ts +89 -0
  7. package/dist/bootstrap.d.ts.map +1 -0
  8. package/dist/bootstrap.js +161 -0
  9. package/dist/bootstrap.js.map +1 -0
  10. package/dist/index.d.ts +10 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +17 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/middleware/rate-limiter.d.ts +136 -0
  15. package/dist/middleware/rate-limiter.d.ts.map +1 -0
  16. package/dist/middleware/rate-limiter.js +262 -0
  17. package/dist/middleware/rate-limiter.js.map +1 -0
  18. package/dist/prompts/agent-guide.d.ts +16 -0
  19. package/dist/prompts/agent-guide.d.ts.map +1 -0
  20. package/dist/prompts/agent-guide.js +391 -0
  21. package/dist/prompts/agent-guide.js.map +1 -0
  22. package/dist/prompts/explain-workflow.d.ts +15 -0
  23. package/dist/prompts/explain-workflow.d.ts.map +1 -0
  24. package/dist/prompts/explain-workflow.js +157 -0
  25. package/dist/prompts/explain-workflow.js.map +1 -0
  26. package/dist/prompts/index.d.ts +39 -0
  27. package/dist/prompts/index.d.ts.map +1 -0
  28. package/dist/prompts/index.js +83 -0
  29. package/dist/prompts/index.js.map +1 -0
  30. package/dist/prompts/review-changes.d.ts +15 -0
  31. package/dist/prompts/review-changes.d.ts.map +1 -0
  32. package/dist/prompts/review-changes.js +102 -0
  33. package/dist/prompts/review-changes.js.map +1 -0
  34. package/dist/prompts/troubleshoot-session.d.ts +15 -0
  35. package/dist/prompts/troubleshoot-session.d.ts.map +1 -0
  36. package/dist/prompts/troubleshoot-session.js +156 -0
  37. package/dist/prompts/troubleshoot-session.js.map +1 -0
  38. package/dist/registry-accessor.d.ts +83 -0
  39. package/dist/registry-accessor.d.ts.map +1 -0
  40. package/dist/registry-accessor.js +153 -0
  41. package/dist/registry-accessor.js.map +1 -0
  42. package/dist/resources/agents.d.ts +40 -0
  43. package/dist/resources/agents.d.ts.map +1 -0
  44. package/dist/resources/agents.js +123 -0
  45. package/dist/resources/agents.js.map +1 -0
  46. package/dist/resources/config.d.ts +57 -0
  47. package/dist/resources/config.d.ts.map +1 -0
  48. package/dist/resources/config.js +222 -0
  49. package/dist/resources/config.js.map +1 -0
  50. package/dist/resources/index.d.ts +38 -0
  51. package/dist/resources/index.d.ts.map +1 -0
  52. package/dist/resources/index.js +132 -0
  53. package/dist/resources/index.js.map +1 -0
  54. package/dist/resources/policies.d.ts +40 -0
  55. package/dist/resources/policies.d.ts.map +1 -0
  56. package/dist/resources/policies.js +122 -0
  57. package/dist/resources/policies.js.map +1 -0
  58. package/dist/resources/sessions.d.ts +30 -0
  59. package/dist/resources/sessions.d.ts.map +1 -0
  60. package/dist/resources/sessions.js +64 -0
  61. package/dist/resources/sessions.js.map +1 -0
  62. package/dist/resources/workflows.d.ts +40 -0
  63. package/dist/resources/workflows.d.ts.map +1 -0
  64. package/dist/resources/workflows.js +143 -0
  65. package/dist/resources/workflows.js.map +1 -0
  66. package/dist/schema-registry.d.ts +23 -0
  67. package/dist/schema-registry.d.ts.map +1 -0
  68. package/dist/schema-registry.js +225 -0
  69. package/dist/schema-registry.js.map +1 -0
  70. package/dist/server.d.ts +63 -0
  71. package/dist/server.d.ts.map +1 -0
  72. package/dist/server.js +393 -0
  73. package/dist/server.js.map +1 -0
  74. package/dist/session-accessor.d.ts +23 -0
  75. package/dist/session-accessor.d.ts.map +1 -0
  76. package/dist/session-accessor.js +39 -0
  77. package/dist/session-accessor.js.map +1 -0
  78. package/dist/shared-registry.d.ts +23 -0
  79. package/dist/shared-registry.d.ts.map +1 -0
  80. package/dist/shared-registry.js +235 -0
  81. package/dist/shared-registry.js.map +1 -0
  82. package/dist/stdio.d.ts +6 -0
  83. package/dist/stdio.d.ts.map +1 -0
  84. package/dist/stdio.js +152 -0
  85. package/dist/stdio.js.map +1 -0
  86. package/dist/tool-namespacing.d.ts +28 -0
  87. package/dist/tool-namespacing.d.ts.map +1 -0
  88. package/dist/tool-namespacing.js +80 -0
  89. package/dist/tool-namespacing.js.map +1 -0
  90. package/dist/tools/ability.d.ts +55 -0
  91. package/dist/tools/ability.d.ts.map +1 -0
  92. package/dist/tools/ability.js +560 -0
  93. package/dist/tools/ability.js.map +1 -0
  94. package/dist/tools/agent.d.ts +73 -0
  95. package/dist/tools/agent.d.ts.map +1 -0
  96. package/dist/tools/agent.js +895 -0
  97. package/dist/tools/agent.js.map +1 -0
  98. package/dist/tools/config.d.ts +36 -0
  99. package/dist/tools/config.d.ts.map +1 -0
  100. package/dist/tools/config.js +265 -0
  101. package/dist/tools/config.js.map +1 -0
  102. package/dist/tools/design.d.ts +42 -0
  103. package/dist/tools/design.d.ts.map +1 -0
  104. package/dist/tools/design.js +736 -0
  105. package/dist/tools/design.js.map +1 -0
  106. package/dist/tools/discuss.d.ts +40 -0
  107. package/dist/tools/discuss.d.ts.map +1 -0
  108. package/dist/tools/discuss.js +331 -0
  109. package/dist/tools/discuss.js.map +1 -0
  110. package/dist/tools/file-system.d.ts +63 -0
  111. package/dist/tools/file-system.d.ts.map +1 -0
  112. package/dist/tools/file-system.js +513 -0
  113. package/dist/tools/file-system.js.map +1 -0
  114. package/dist/tools/guard.d.ts +29 -0
  115. package/dist/tools/guard.d.ts.map +1 -0
  116. package/dist/tools/guard.js +311 -0
  117. package/dist/tools/guard.js.map +1 -0
  118. package/dist/tools/index.d.ts +35 -0
  119. package/dist/tools/index.d.ts.map +1 -0
  120. package/dist/tools/index.js +178 -0
  121. package/dist/tools/index.js.map +1 -0
  122. package/dist/tools/memory.d.ts +101 -0
  123. package/dist/tools/memory.d.ts.map +1 -0
  124. package/dist/tools/memory.js +704 -0
  125. package/dist/tools/memory.js.map +1 -0
  126. package/dist/tools/orchestration.d.ts +58 -0
  127. package/dist/tools/orchestration.d.ts.map +1 -0
  128. package/dist/tools/orchestration.js +714 -0
  129. package/dist/tools/orchestration.js.map +1 -0
  130. package/dist/tools/review.d.ts +40 -0
  131. package/dist/tools/review.d.ts.map +1 -0
  132. package/dist/tools/review.js +319 -0
  133. package/dist/tools/review.js.map +1 -0
  134. package/dist/tools/scaffold.d.ts +27 -0
  135. package/dist/tools/scaffold.d.ts.map +1 -0
  136. package/dist/tools/scaffold.js +495 -0
  137. package/dist/tools/scaffold.js.map +1 -0
  138. package/dist/tools/session.d.ts +75 -0
  139. package/dist/tools/session.d.ts.map +1 -0
  140. package/dist/tools/session.js +749 -0
  141. package/dist/tools/session.js.map +1 -0
  142. package/dist/tools/telemetry.d.ts +58 -0
  143. package/dist/tools/telemetry.d.ts.map +1 -0
  144. package/dist/tools/telemetry.js +638 -0
  145. package/dist/tools/telemetry.js.map +1 -0
  146. package/dist/tools/trace.d.ts +29 -0
  147. package/dist/tools/trace.d.ts.map +1 -0
  148. package/dist/tools/trace.js +191 -0
  149. package/dist/tools/trace.js.map +1 -0
  150. package/dist/tools/workflow.d.ts +26 -0
  151. package/dist/tools/workflow.d.ts.map +1 -0
  152. package/dist/tools/workflow.js +269 -0
  153. package/dist/tools/workflow.js.map +1 -0
  154. package/dist/trace-wrapper.d.ts +79 -0
  155. package/dist/trace-wrapper.d.ts.map +1 -0
  156. package/dist/trace-wrapper.js +151 -0
  157. package/dist/trace-wrapper.js.map +1 -0
  158. package/dist/types.d.ts +185 -0
  159. package/dist/types.d.ts.map +1 -0
  160. package/dist/types.js +11 -0
  161. package/dist/types.js.map +1 -0
  162. package/dist/utils/artifact-store.d.ts +49 -0
  163. package/dist/utils/artifact-store.d.ts.map +1 -0
  164. package/dist/utils/artifact-store.js +102 -0
  165. package/dist/utils/artifact-store.js.map +1 -0
  166. package/dist/utils/index.d.ts +6 -0
  167. package/dist/utils/index.d.ts.map +1 -0
  168. package/dist/utils/index.js +10 -0
  169. package/dist/utils/index.js.map +1 -0
  170. package/dist/utils/response.d.ts +139 -0
  171. package/dist/utils/response.d.ts.map +1 -0
  172. package/dist/utils/response.js +293 -0
  173. package/dist/utils/response.js.map +1 -0
  174. package/dist/validation.d.ts +223 -0
  175. package/dist/validation.d.ts.map +1 -0
  176. package/dist/validation.js +372 -0
  177. package/dist/validation.js.map +1 -0
  178. package/package.json +67 -0
@@ -0,0 +1,513 @@
1
+ /**
2
+ * File System MCP Tools
3
+ *
4
+ * Provides secure file and directory operations for scaffold tools.
5
+ * Implements security invariants from INV-FS-* series.
6
+ *
7
+ * @module mcp-server/tools/file-system
8
+ */
9
+ import * as fs from 'node:fs';
10
+ import * as path from 'node:path';
11
+ import { FileSystemErrorCode, validateFileWriteRequest, validateDirectoryCreateRequest, isPathSafe, } from '@defai.digital/contracts';
12
+ // ============================================================================
13
+ // Tool Definitions
14
+ // ============================================================================
15
+ /**
16
+ * File write tool definition
17
+ *
18
+ * Invariants:
19
+ * - INV-FS-001: No path traversal
20
+ * - INV-FS-002: No silent overwrites
21
+ * - INV-FS-003: Atomic writes
22
+ * - INV-FS-004: UTF-8 default
23
+ */
24
+ export const fileWriteTool = {
25
+ name: 'file_write',
26
+ description: 'Write content to a file. Requires explicit overwrite flag for existing files. SIDE EFFECTS: Creates/modifies file on disk. Idempotent with same content.',
27
+ inputSchema: {
28
+ type: 'object',
29
+ properties: {
30
+ path: {
31
+ type: 'string',
32
+ description: 'File path relative to workspace root',
33
+ },
34
+ content: {
35
+ type: 'string',
36
+ description: 'File content to write',
37
+ },
38
+ createDirectories: {
39
+ type: 'boolean',
40
+ description: 'Create parent directories if they don\'t exist',
41
+ default: true,
42
+ },
43
+ overwrite: {
44
+ type: 'boolean',
45
+ description: 'Allow overwriting existing files',
46
+ default: false,
47
+ },
48
+ encoding: {
49
+ type: 'string',
50
+ enum: ['utf-8', 'ascii', 'base64', 'binary'],
51
+ description: 'File encoding',
52
+ default: 'utf-8',
53
+ },
54
+ backup: {
55
+ type: 'boolean',
56
+ description: 'Create backup before overwriting',
57
+ default: false,
58
+ },
59
+ },
60
+ required: ['path', 'content'],
61
+ },
62
+ idempotent: true, // Same content = same result
63
+ retryableErrors: ['WRITE_FAILED'],
64
+ };
65
+ /**
66
+ * Directory create tool definition
67
+ *
68
+ * Invariants:
69
+ * - INV-FS-001: No path traversal
70
+ * - INV-FS-102: Idempotent operation
71
+ */
72
+ export const directoryCreateTool = {
73
+ name: 'directory_create',
74
+ description: 'Create a directory. SIDE EFFECTS: Creates directory on disk. Idempotent - existing directory returns success.',
75
+ inputSchema: {
76
+ type: 'object',
77
+ properties: {
78
+ path: {
79
+ type: 'string',
80
+ description: 'Directory path relative to workspace root',
81
+ },
82
+ recursive: {
83
+ type: 'boolean',
84
+ description: 'Create parent directories if they don\'t exist',
85
+ default: true,
86
+ },
87
+ },
88
+ required: ['path'],
89
+ },
90
+ idempotent: true,
91
+ };
92
+ /**
93
+ * File exists tool definition
94
+ *
95
+ * INV-MCP-004: Idempotent - read-only operation
96
+ */
97
+ export const fileExistsTool = {
98
+ name: 'file_exists',
99
+ description: 'Check if a file or directory exists. Read-only, no side effects.',
100
+ inputSchema: {
101
+ type: 'object',
102
+ properties: {
103
+ path: {
104
+ type: 'string',
105
+ description: 'Path to check relative to workspace root',
106
+ },
107
+ },
108
+ required: ['path'],
109
+ },
110
+ idempotent: true,
111
+ };
112
+ // ============================================================================
113
+ // Helper Functions
114
+ // ============================================================================
115
+ /**
116
+ * Get workspace root from context or use current working directory
117
+ */
118
+ function getWorkspaceRoot() {
119
+ return process.cwd();
120
+ }
121
+ /**
122
+ * Validate and resolve a path within workspace
123
+ *
124
+ * INV-FS-001: Prevents path traversal
125
+ * INV-FS-006: Ensures path stays within workspace
126
+ */
127
+ function resolveSafePath(filePath, workspaceRoot) {
128
+ // INV-FS-001: Check for path traversal in input
129
+ if (!isPathSafe(filePath)) {
130
+ return {
131
+ valid: false,
132
+ error: {
133
+ code: FileSystemErrorCode.PATH_TRAVERSAL,
134
+ message: 'Path contains invalid characters or traversal sequences',
135
+ },
136
+ };
137
+ }
138
+ // Resolve to absolute path
139
+ const resolved = path.resolve(workspaceRoot, filePath);
140
+ // INV-FS-006: Verify path is within workspace
141
+ const relative = path.relative(workspaceRoot, resolved);
142
+ if (relative.startsWith('..') || path.isAbsolute(relative)) {
143
+ return {
144
+ valid: false,
145
+ error: {
146
+ code: FileSystemErrorCode.OUTSIDE_WORKSPACE,
147
+ message: 'Path resolves outside workspace root',
148
+ },
149
+ };
150
+ }
151
+ // INV-FS-005: Check for symlinks
152
+ try {
153
+ // Check each path component for symlinks
154
+ let currentPath = workspaceRoot;
155
+ const parts = relative.split(path.sep);
156
+ for (const part of parts) {
157
+ currentPath = path.join(currentPath, part);
158
+ if (fs.existsSync(currentPath)) {
159
+ const stat = fs.lstatSync(currentPath);
160
+ if (stat.isSymbolicLink()) {
161
+ return {
162
+ valid: false,
163
+ error: {
164
+ code: FileSystemErrorCode.SYMLINK_NOT_ALLOWED,
165
+ message: 'Symlinks are not allowed in path',
166
+ },
167
+ };
168
+ }
169
+ }
170
+ }
171
+ }
172
+ catch {
173
+ // Path component doesn't exist yet, which is fine
174
+ }
175
+ return { valid: true, resolved };
176
+ }
177
+ // ============================================================================
178
+ // Tool Handlers
179
+ // ============================================================================
180
+ /**
181
+ * Handle file_write tool
182
+ *
183
+ * Invariants enforced:
184
+ * - INV-FS-001: Path traversal prevention
185
+ * - INV-FS-002: No silent overwrites
186
+ * - INV-FS-003: Atomic writes
187
+ * - INV-FS-005: No symlink following
188
+ * - INV-FS-006: Workspace boundary
189
+ */
190
+ export const handleFileWrite = async (args) => {
191
+ const workspaceRoot = getWorkspaceRoot();
192
+ try {
193
+ // Validate input against schema
194
+ const request = validateFileWriteRequest(args);
195
+ // INV-FS-001, INV-FS-005, INV-FS-006: Validate and resolve path
196
+ const pathResult = resolveSafePath(request.path, workspaceRoot);
197
+ if (!pathResult.valid) {
198
+ return {
199
+ content: [
200
+ {
201
+ type: 'text',
202
+ text: JSON.stringify({
203
+ success: false,
204
+ path: request.path,
205
+ bytesWritten: 0,
206
+ created: false,
207
+ overwritten: false,
208
+ error: pathResult.error,
209
+ }),
210
+ },
211
+ ],
212
+ isError: true,
213
+ };
214
+ }
215
+ const resolvedPath = pathResult.resolved;
216
+ const fileExists = fs.existsSync(resolvedPath);
217
+ // INV-FS-002: No silent overwrites
218
+ if (fileExists && !request.overwrite) {
219
+ return {
220
+ content: [
221
+ {
222
+ type: 'text',
223
+ text: JSON.stringify({
224
+ success: false,
225
+ path: request.path,
226
+ bytesWritten: 0,
227
+ created: false,
228
+ overwritten: false,
229
+ error: {
230
+ code: FileSystemErrorCode.FILE_EXISTS,
231
+ message: 'File exists. Set overwrite=true to replace.',
232
+ },
233
+ }),
234
+ },
235
+ ],
236
+ isError: true,
237
+ };
238
+ }
239
+ // INV-FS-101: Create parent directories if needed
240
+ if (request.createDirectories) {
241
+ const dir = path.dirname(resolvedPath);
242
+ if (!fs.existsSync(dir)) {
243
+ fs.mkdirSync(dir, { recursive: true });
244
+ }
245
+ }
246
+ // Create backup if requested
247
+ let backupPath;
248
+ if (fileExists && request.backup) {
249
+ backupPath = `${resolvedPath}.backup.${Date.now()}`;
250
+ fs.copyFileSync(resolvedPath, backupPath);
251
+ }
252
+ // INV-FS-003: Atomic write (write to temp, then rename)
253
+ const tempPath = `${resolvedPath}.tmp.${Date.now()}.${process.pid}`;
254
+ try {
255
+ // Write to temp file
256
+ fs.writeFileSync(tempPath, request.content, {
257
+ encoding: request.encoding,
258
+ });
259
+ // Atomic rename
260
+ fs.renameSync(tempPath, resolvedPath);
261
+ }
262
+ catch (writeError) {
263
+ // Clean up temp file if it exists
264
+ try {
265
+ if (fs.existsSync(tempPath)) {
266
+ fs.unlinkSync(tempPath);
267
+ }
268
+ }
269
+ catch {
270
+ // Ignore cleanup errors
271
+ }
272
+ throw writeError;
273
+ }
274
+ return {
275
+ content: [
276
+ {
277
+ type: 'text',
278
+ text: JSON.stringify({
279
+ success: true,
280
+ path: request.path,
281
+ bytesWritten: Buffer.byteLength(request.content, request.encoding),
282
+ created: !fileExists,
283
+ overwritten: fileExists,
284
+ ...(backupPath ? { backupPath: path.relative(workspaceRoot, backupPath) } : {}),
285
+ }),
286
+ },
287
+ ],
288
+ };
289
+ }
290
+ catch (error) {
291
+ const message = error instanceof Error ? error.message : String(error);
292
+ return {
293
+ content: [
294
+ {
295
+ type: 'text',
296
+ text: JSON.stringify({
297
+ success: false,
298
+ path: typeof args.path === 'string' ? args.path : '',
299
+ bytesWritten: 0,
300
+ created: false,
301
+ overwritten: false,
302
+ error: {
303
+ code: FileSystemErrorCode.WRITE_FAILED,
304
+ message,
305
+ },
306
+ }),
307
+ },
308
+ ],
309
+ isError: true,
310
+ };
311
+ }
312
+ };
313
+ /**
314
+ * Handle directory_create tool
315
+ *
316
+ * Invariants enforced:
317
+ * - INV-FS-001: Path traversal prevention
318
+ * - INV-FS-005: No symlink following
319
+ * - INV-FS-006: Workspace boundary
320
+ * - INV-FS-102: Idempotent operation
321
+ */
322
+ export const handleDirectoryCreate = async (args) => {
323
+ const workspaceRoot = getWorkspaceRoot();
324
+ try {
325
+ // Validate input against schema
326
+ const request = validateDirectoryCreateRequest(args);
327
+ // INV-FS-001, INV-FS-005, INV-FS-006: Validate and resolve path
328
+ const pathResult = resolveSafePath(request.path, workspaceRoot);
329
+ if (!pathResult.valid) {
330
+ return {
331
+ content: [
332
+ {
333
+ type: 'text',
334
+ text: JSON.stringify({
335
+ success: false,
336
+ path: request.path,
337
+ created: false,
338
+ existed: false,
339
+ error: pathResult.error,
340
+ }),
341
+ },
342
+ ],
343
+ isError: true,
344
+ };
345
+ }
346
+ const resolvedPath = pathResult.resolved;
347
+ const existed = fs.existsSync(resolvedPath);
348
+ // INV-FS-102: Idempotent - existing directory is success
349
+ if (existed) {
350
+ const stat = fs.statSync(resolvedPath);
351
+ if (!stat.isDirectory()) {
352
+ return {
353
+ content: [
354
+ {
355
+ type: 'text',
356
+ text: JSON.stringify({
357
+ success: false,
358
+ path: request.path,
359
+ created: false,
360
+ existed: true,
361
+ error: {
362
+ code: FileSystemErrorCode.INVALID_PATH,
363
+ message: 'Path exists but is not a directory',
364
+ },
365
+ }),
366
+ },
367
+ ],
368
+ isError: true,
369
+ };
370
+ }
371
+ return {
372
+ content: [
373
+ {
374
+ type: 'text',
375
+ text: JSON.stringify({
376
+ success: true,
377
+ path: request.path,
378
+ created: false,
379
+ existed: true,
380
+ }),
381
+ },
382
+ ],
383
+ };
384
+ }
385
+ // Create directory
386
+ fs.mkdirSync(resolvedPath, { recursive: request.recursive });
387
+ return {
388
+ content: [
389
+ {
390
+ type: 'text',
391
+ text: JSON.stringify({
392
+ success: true,
393
+ path: request.path,
394
+ created: true,
395
+ existed: false,
396
+ }),
397
+ },
398
+ ],
399
+ };
400
+ }
401
+ catch (error) {
402
+ const message = error instanceof Error ? error.message : String(error);
403
+ return {
404
+ content: [
405
+ {
406
+ type: 'text',
407
+ text: JSON.stringify({
408
+ success: false,
409
+ path: typeof args.path === 'string' ? args.path : '',
410
+ created: false,
411
+ existed: false,
412
+ error: {
413
+ code: FileSystemErrorCode.MKDIR_FAILED,
414
+ message,
415
+ },
416
+ }),
417
+ },
418
+ ],
419
+ isError: true,
420
+ };
421
+ }
422
+ };
423
+ /**
424
+ * Handle file_exists tool
425
+ *
426
+ * Read-only operation - no side effects
427
+ */
428
+ export const handleFileExists = async (args) => {
429
+ const workspaceRoot = getWorkspaceRoot();
430
+ try {
431
+ const filePath = args.path;
432
+ // Validate path
433
+ const pathResult = resolveSafePath(filePath, workspaceRoot);
434
+ if (!pathResult.valid) {
435
+ return {
436
+ content: [
437
+ {
438
+ type: 'text',
439
+ text: JSON.stringify({
440
+ path: filePath,
441
+ exists: false,
442
+ error: pathResult.error,
443
+ }),
444
+ },
445
+ ],
446
+ isError: true,
447
+ };
448
+ }
449
+ const resolvedPath = pathResult.resolved;
450
+ const exists = fs.existsSync(resolvedPath);
451
+ if (!exists) {
452
+ return {
453
+ content: [
454
+ {
455
+ type: 'text',
456
+ text: JSON.stringify({
457
+ path: filePath,
458
+ exists: false,
459
+ }),
460
+ },
461
+ ],
462
+ };
463
+ }
464
+ const stat = fs.statSync(resolvedPath);
465
+ return {
466
+ content: [
467
+ {
468
+ type: 'text',
469
+ text: JSON.stringify({
470
+ path: filePath,
471
+ exists: true,
472
+ isFile: stat.isFile(),
473
+ isDirectory: stat.isDirectory(),
474
+ size: stat.isFile() ? stat.size : undefined,
475
+ }),
476
+ },
477
+ ],
478
+ };
479
+ }
480
+ catch (error) {
481
+ const message = error instanceof Error ? error.message : String(error);
482
+ return {
483
+ content: [
484
+ {
485
+ type: 'text',
486
+ text: JSON.stringify({
487
+ path: typeof args.path === 'string' ? args.path : '',
488
+ exists: false,
489
+ error: {
490
+ code: 'CHECK_FAILED',
491
+ message,
492
+ },
493
+ }),
494
+ },
495
+ ],
496
+ isError: true,
497
+ };
498
+ }
499
+ };
500
+ // ============================================================================
501
+ // Exports
502
+ // ============================================================================
503
+ export const FILE_SYSTEM_TOOLS = [
504
+ fileWriteTool,
505
+ directoryCreateTool,
506
+ fileExistsTool,
507
+ ];
508
+ export const FILE_SYSTEM_HANDLERS = {
509
+ file_write: handleFileWrite,
510
+ directory_create: handleDirectoryCreate,
511
+ file_exists: handleFileExists,
512
+ };
513
+ //# sourceMappingURL=file-system.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-system.js","sourceRoot":"","sources":["../../src/tools/file-system.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,8BAA8B,EAC9B,UAAU,GACX,MAAM,0BAA0B,CAAC;AAElC,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;;;;;;;GAQG;AACH,MAAM,C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AC;QACvE,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;wBACnB,IAAI,EAAE,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;wBACpD,MAAM,EAAE,KAAK;wBACb,KAAK,EAAE;4BACL,IAAI,EAAE,cAAc;4BACpB,OAAO;yBACR;qBACF,CAAC;iBACH;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E,MAAM,CAAC,MAAM,iBAAiB,GAAc;IAC1C,aAAa;IACb,mBAAmB;IACnB,cAAc;CACf,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAgC;IAC/D,UAAU,EAAE,eAAe;IAC3B,gBAAgB,EAAE,qBAAqB;IACvC,WAAW,EAAE,gBAAgB;CAC9B,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { MCPTool, ToolHandler } from '../types.js';
2
+ /**
3
+ * Guard check tool definition
4
+ */
5
+ export declare const guardCheckTool: MCPTool;
6
+ /**
7
+ * Guard list tool definition
8
+ */
9
+ export declare const guardListTool: MCPTool;
10
+ /**
11
+ * Guard apply tool definition
12
+ */
13
+ export declare const guardApplyTool: MCPTool;
14
+ /**
15
+ * Handler for guard_check tool
16
+ */
17
+ export declare const handleGuardCheck: ToolHandler;
18
+ /**
19
+ * Handler for guard_list tool
20
+ */
21
+ export declare const handleGuardList: ToolHandler;
22
+ /**
23
+ * Handler for guard_apply tool
24
+ *
25
+ * Applies a governance policy to a session, enabling policy-based
26
+ * validation of agent actions within that session.
27
+ */
28
+ export declare const handleGuardApply: ToolHandler;
29
+ //# sourceMappingURL=guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../src/tools/guard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAwBxD;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,OAuD5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,OAmC3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,OA4B5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAoC9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,WAyD7B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAyE9B,CAAC"}