@loxia-labs/loxia-autopilot-one 1.0.1 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +44 -54
  2. package/bin/cli.js +1 -115
  3. package/bin/loxia-terminal-v2.js +3 -0
  4. package/bin/loxia-terminal.js +3 -0
  5. package/bin/start-with-terminal.js +3 -0
  6. package/package.json +15 -15
  7. package/scripts/install-scanners.js +1 -235
  8. package/src/analyzers/CSSAnalyzer.js +1 -297
  9. package/src/analyzers/ConfigValidator.js +1 -690
  10. package/src/analyzers/ESLintAnalyzer.js +1 -320
  11. package/src/analyzers/JavaScriptAnalyzer.js +1 -261
  12. package/src/analyzers/PrettierFormatter.js +1 -247
  13. package/src/analyzers/PythonAnalyzer.js +1 -266
  14. package/src/analyzers/SecurityAnalyzer.js +1 -729
  15. package/src/analyzers/TypeScriptAnalyzer.js +1 -247
  16. package/src/analyzers/codeCloneDetector/analyzer.js +1 -344
  17. package/src/analyzers/codeCloneDetector/detector.js +1 -203
  18. package/src/analyzers/codeCloneDetector/index.js +1 -160
  19. package/src/analyzers/codeCloneDetector/parser.js +1 -199
  20. package/src/analyzers/codeCloneDetector/reporter.js +1 -148
  21. package/src/analyzers/codeCloneDetector/scanner.js +1 -59
  22. package/src/core/agentPool.js +1 -1474
  23. package/src/core/agentScheduler.js +1 -2147
  24. package/src/core/contextManager.js +1 -709
  25. package/src/core/messageProcessor.js +1 -732
  26. package/src/core/orchestrator.js +1 -548
  27. package/src/core/stateManager.js +1 -877
  28. package/src/index.js +1 -631
  29. package/src/interfaces/cli.js +1 -549
  30. package/src/interfaces/terminal/__tests__/smoke/advancedFeatures.test.js +1 -0
  31. package/src/interfaces/terminal/__tests__/smoke/agentControl.test.js +1 -0
  32. package/src/interfaces/terminal/__tests__/smoke/agents.test.js +1 -0
  33. package/src/interfaces/terminal/__tests__/smoke/components.test.js +1 -0
  34. package/src/interfaces/terminal/__tests__/smoke/connection.test.js +1 -0
  35. package/src/interfaces/terminal/__tests__/smoke/enhancements.test.js +1 -0
  36. package/src/interfaces/terminal/__tests__/smoke/imports.test.js +1 -0
  37. package/src/interfaces/terminal/__tests__/smoke/messages.test.js +1 -0
  38. package/src/interfaces/terminal/__tests__/smoke/tools.test.js +1 -0
  39. package/src/interfaces/terminal/api/apiClient.js +1 -0
  40. package/src/interfaces/terminal/api/messageRouter.js +1 -0
  41. package/src/interfaces/terminal/api/session.js +1 -0
  42. package/src/interfaces/terminal/api/websocket.js +1 -0
  43. package/src/interfaces/terminal/components/AgentCreator.js +1 -0
  44. package/src/interfaces/terminal/components/AgentEditor.js +1 -0
  45. package/src/interfaces/terminal/components/AgentSwitcher.js +1 -0
  46. package/src/interfaces/terminal/components/ErrorBoundary.js +1 -0
  47. package/src/interfaces/terminal/components/ErrorPanel.js +1 -0
  48. package/src/interfaces/terminal/components/Header.js +1 -0
  49. package/src/interfaces/terminal/components/HelpPanel.js +1 -0
  50. package/src/interfaces/terminal/components/InputBox.js +1 -0
  51. package/src/interfaces/terminal/components/Layout.js +1 -0
  52. package/src/interfaces/terminal/components/LoadingSpinner.js +1 -0
  53. package/src/interfaces/terminal/components/MessageList.js +1 -0
  54. package/src/interfaces/terminal/components/MultilineTextInput.js +1 -0
  55. package/src/interfaces/terminal/components/SearchPanel.js +1 -0
  56. package/src/interfaces/terminal/components/SettingsPanel.js +1 -0
  57. package/src/interfaces/terminal/components/StatusBar.js +1 -0
  58. package/src/interfaces/terminal/components/TextInput.js +1 -0
  59. package/src/interfaces/terminal/config/agentEditorConstants.js +1 -0
  60. package/src/interfaces/terminal/config/constants.js +1 -0
  61. package/src/interfaces/terminal/index.js +1 -0
  62. package/src/interfaces/terminal/state/useAgentControl.js +1 -0
  63. package/src/interfaces/terminal/state/useAgents.js +1 -0
  64. package/src/interfaces/terminal/state/useConnection.js +1 -0
  65. package/src/interfaces/terminal/state/useMessages.js +1 -0
  66. package/src/interfaces/terminal/state/useTools.js +1 -0
  67. package/src/interfaces/terminal/utils/debugLogger.js +1 -0
  68. package/src/interfaces/terminal/utils/settingsStorage.js +1 -0
  69. package/src/interfaces/terminal/utils/theme.js +1 -0
  70. package/src/interfaces/webServer.js +1 -2162
  71. package/src/modules/fileExplorer/controller.js +1 -280
  72. package/src/modules/fileExplorer/index.js +1 -37
  73. package/src/modules/fileExplorer/middleware.js +1 -92
  74. package/src/modules/fileExplorer/routes.js +1 -125
  75. package/src/modules/fileExplorer/types.js +1 -44
  76. package/src/services/aiService.js +1 -1232
  77. package/src/services/apiKeyManager.js +1 -164
  78. package/src/services/benchmarkService.js +1 -366
  79. package/src/services/budgetService.js +1 -539
  80. package/src/services/contextInjectionService.js +1 -247
  81. package/src/services/conversationCompactionService.js +1 -637
  82. package/src/services/errorHandler.js +1 -810
  83. package/src/services/fileAttachmentService.js +1 -544
  84. package/src/services/modelRouterService.js +1 -366
  85. package/src/services/modelsService.js +1 -322
  86. package/src/services/qualityInspector.js +1 -796
  87. package/src/services/tokenCountingService.js +1 -536
  88. package/src/tools/agentCommunicationTool.js +1 -1344
  89. package/src/tools/agentDelayTool.js +1 -485
  90. package/src/tools/asyncToolManager.js +1 -604
  91. package/src/tools/baseTool.js +1 -800
  92. package/src/tools/browserTool.js +1 -920
  93. package/src/tools/cloneDetectionTool.js +1 -621
  94. package/src/tools/dependencyResolverTool.js +1 -1215
  95. package/src/tools/fileContentReplaceTool.js +1 -875
  96. package/src/tools/fileSystemTool.js +1 -1107
  97. package/src/tools/fileTreeTool.js +1 -853
  98. package/src/tools/imageTool.js +1 -901
  99. package/src/tools/importAnalyzerTool.js +1 -1060
  100. package/src/tools/jobDoneTool.js +1 -248
  101. package/src/tools/seekTool.js +1 -956
  102. package/src/tools/staticAnalysisTool.js +1 -1778
  103. package/src/tools/taskManagerTool.js +1 -2873
  104. package/src/tools/terminalTool.js +1 -2304
  105. package/src/tools/webTool.js +1 -1430
  106. package/src/types/agent.js +1 -519
  107. package/src/types/contextReference.js +1 -972
  108. package/src/types/conversation.js +1 -730
  109. package/src/types/toolCommand.js +1 -747
  110. package/src/utilities/attachmentValidator.js +1 -292
  111. package/src/utilities/configManager.js +1 -582
  112. package/src/utilities/constants.js +1 -722
  113. package/src/utilities/directoryAccessManager.js +1 -535
  114. package/src/utilities/fileProcessor.js +1 -307
  115. package/src/utilities/logger.js +1 -436
  116. package/src/utilities/tagParser.js +1 -1246
  117. package/src/utilities/toolConstants.js +1 -317
  118. package/web-ui/build/index.html +2 -2
  119. package/web-ui/build/static/{index-Dy2bYbOa.css → index-CClD1090.css} +1 -1
  120. package/web-ui/build/static/{index-CjkkcnFA.js → index-lCBai6dX.js} +66 -67
@@ -1,535 +1 @@
1
- /**
2
- * DirectoryAccessManager - Manage directory access permissions for agents
3
- *
4
- * Purpose:
5
- * - Control agent access to directories and files
6
- * - Distinguish between read-only and write-enabled directories
7
- * - Validate paths against access permissions
8
- * - Provide working directory management
9
- * - Support both absolute and relative path resolution
10
- */
11
-
12
- import path from 'path';
13
- import fs from 'fs/promises';
14
- import os from 'os';
15
-
16
- class DirectoryAccessManager {
17
- constructor(config = {}, logger = null) {
18
- this.logger = logger;
19
- this.config = config;
20
-
21
- // Default system restrictions
22
- this.systemRestrictedPaths = [
23
- // System directories
24
- '/etc',
25
- '/var',
26
- '/usr',
27
- '/bin',
28
- '/sbin',
29
- '/boot',
30
- '/dev',
31
- '/proc',
32
- '/sys',
33
- // Windows system directories
34
- 'C:\\Windows',
35
- 'C:\\Program Files',
36
- 'C:\\Program Files (x86)',
37
- // User sensitive directories
38
- path.join(os.homedir(), '.ssh'),
39
- path.join(os.homedir(), '.aws'),
40
- path.join(os.homedir(), '.config'),
41
- // Common package managers
42
- 'node_modules/.bin',
43
- '.git/objects',
44
- '.git/hooks'
45
- ];
46
- }
47
-
48
- /**
49
- * Create directory access configuration for an agent
50
- * @param {Object} options - Access configuration options
51
- * @returns {Object} Directory access configuration
52
- */
53
- createDirectoryAccess(options = {}) {
54
- const {
55
- workingDirectory = process.cwd(),
56
- readOnlyDirectories = [],
57
- writeEnabledDirectories = [],
58
- restrictToProject = true,
59
- allowSystemAccess = false,
60
- customRestrictions = []
61
- } = options;
62
-
63
- // Normalize all paths to absolute
64
- const workingDir = path.resolve(workingDirectory);
65
- const readOnlyDirs = readOnlyDirectories.map(dir => this.normalizePath(dir, workingDir));
66
- const writeEnabledDirs = writeEnabledDirectories.map(dir => this.normalizePath(dir, workingDir));
67
-
68
- // If restrict to project, ensure working directory is included
69
- const finalReadOnlyDirs = restrictToProject
70
- ? [...new Set([...readOnlyDirs, workingDir])]
71
- : readOnlyDirs;
72
-
73
- const finalWriteEnabledDirs = restrictToProject
74
- ? writeEnabledDirs.filter(dir => this.isPathWithinDirectory(dir, workingDir))
75
- : writeEnabledDirs;
76
-
77
- return {
78
- workingDirectory: workingDir,
79
- readOnlyDirectories: finalReadOnlyDirs,
80
- writeEnabledDirectories: finalWriteEnabledDirs,
81
- restrictToProject,
82
- allowSystemAccess,
83
- customRestrictions: customRestrictions.map(restriction => path.resolve(restriction)),
84
- createdAt: new Date().toISOString(),
85
- version: '1.0'
86
- };
87
- }
88
-
89
- /**
90
- * Validate if a path can be accessed for reading
91
- * @param {string} targetPath - Path to validate
92
- * @param {Object} accessConfig - Directory access configuration
93
- * @returns {Object} Validation result
94
- */
95
- validateReadAccess(targetPath, accessConfig) {
96
- try {
97
- const resolvedPath = this.resolvePath(targetPath, accessConfig.workingDirectory);
98
-
99
- // Check system restrictions first
100
- if (!accessConfig.allowSystemAccess && this.isSystemRestrictedPath(resolvedPath)) {
101
- return {
102
- allowed: false,
103
- reason: 'System path access denied',
104
- path: resolvedPath,
105
- category: 'system_restricted'
106
- };
107
- }
108
-
109
- // Check custom restrictions
110
- if (this.isCustomRestricted(resolvedPath, accessConfig.customRestrictions)) {
111
- return {
112
- allowed: false,
113
- reason: 'Custom restriction applied',
114
- path: resolvedPath,
115
- category: 'custom_restricted'
116
- };
117
- }
118
-
119
- // If restricting to project, ensure path is within allowed boundaries
120
- if (accessConfig.restrictToProject) {
121
- const isWithinProject = this.isPathWithinAnyDirectory(resolvedPath, [
122
- ...accessConfig.readOnlyDirectories,
123
- ...accessConfig.writeEnabledDirectories
124
- ]);
125
-
126
- if (!isWithinProject) {
127
- return {
128
- allowed: false,
129
- reason: 'Path outside project scope',
130
- path: resolvedPath,
131
- category: 'project_restricted'
132
- };
133
- }
134
- }
135
-
136
- // Check if path is within any allowed directory
137
- const isWithinAllowed = this.isPathWithinAnyDirectory(resolvedPath, [
138
- ...accessConfig.readOnlyDirectories,
139
- ...accessConfig.writeEnabledDirectories
140
- ]);
141
-
142
- if (!isWithinAllowed && accessConfig.readOnlyDirectories.length > 0) {
143
- return {
144
- allowed: false,
145
- reason: 'Path not in allowed directories',
146
- path: resolvedPath,
147
- category: 'directory_restricted'
148
- };
149
- }
150
-
151
- return {
152
- allowed: true,
153
- path: resolvedPath,
154
- category: 'allowed'
155
- };
156
-
157
- } catch (error) {
158
- return {
159
- allowed: false,
160
- reason: `Path validation error: ${error.message}`,
161
- path: targetPath,
162
- category: 'validation_error'
163
- };
164
- }
165
- }
166
-
167
- /**
168
- * Validate if a path can be accessed for writing
169
- * @param {string} targetPath - Path to validate
170
- * @param {Object} accessConfig - Directory access configuration
171
- * @returns {Object} Validation result
172
- */
173
- validateWriteAccess(targetPath, accessConfig) {
174
- // First check read access
175
- const readResult = this.validateReadAccess(targetPath, accessConfig);
176
- if (!readResult.allowed) {
177
- return {
178
- ...readResult,
179
- writeAllowed: false
180
- };
181
- }
182
-
183
- const resolvedPath = readResult.path;
184
-
185
- // Check if path is within write-enabled directories
186
- const isWithinWriteEnabled = this.isPathWithinAnyDirectory(
187
- resolvedPath,
188
- accessConfig.writeEnabledDirectories
189
- );
190
-
191
- if (!isWithinWriteEnabled) {
192
- // Check if it's in read-only directories
193
- const isWithinReadOnly = this.isPathWithinAnyDirectory(
194
- resolvedPath,
195
- accessConfig.readOnlyDirectories
196
- );
197
-
198
- if (isWithinReadOnly) {
199
- return {
200
- allowed: false,
201
- writeAllowed: false,
202
- reason: 'Path is in read-only directory',
203
- path: resolvedPath,
204
- category: 'read_only_restricted'
205
- };
206
- }
207
-
208
- return {
209
- allowed: false,
210
- writeAllowed: false,
211
- reason: 'Path not in write-enabled directories',
212
- path: resolvedPath,
213
- category: 'write_restricted'
214
- };
215
- }
216
-
217
- return {
218
- allowed: true,
219
- writeAllowed: true,
220
- path: resolvedPath,
221
- category: 'write_allowed'
222
- };
223
- }
224
-
225
- /**
226
- * Get the effective working directory for an agent
227
- * @param {Object} accessConfig - Directory access configuration
228
- * @returns {string} Working directory path
229
- */
230
- getWorkingDirectory(accessConfig) {
231
- return accessConfig.workingDirectory || process.cwd();
232
- }
233
-
234
- /**
235
- * List accessible directories for an agent
236
- * @param {Object} accessConfig - Directory access configuration
237
- * @returns {Object} Directory listing with permissions
238
- */
239
- getAccessibleDirectories(accessConfig) {
240
- return {
241
- workingDirectory: accessConfig.workingDirectory,
242
- readOnly: [...accessConfig.readOnlyDirectories],
243
- writeEnabled: [...accessConfig.writeEnabledDirectories],
244
- projectRestricted: accessConfig.restrictToProject,
245
- systemAccessAllowed: accessConfig.allowSystemAccess,
246
- totalDirectories: accessConfig.readOnlyDirectories.length + accessConfig.writeEnabledDirectories.length
247
- };
248
- }
249
-
250
- /**
251
- * Update directory access configuration
252
- * @param {Object} currentConfig - Current access configuration
253
- * @param {Object} updates - Updates to apply
254
- * @returns {Object} Updated configuration
255
- */
256
- updateDirectoryAccess(currentConfig, updates) {
257
- const updatedConfig = { ...currentConfig };
258
-
259
- if (updates.workingDirectory) {
260
- updatedConfig.workingDirectory = path.resolve(updates.workingDirectory);
261
- }
262
-
263
- if (updates.readOnlyDirectories !== undefined) {
264
- updatedConfig.readOnlyDirectories = updates.readOnlyDirectories.map(dir =>
265
- this.normalizePath(dir, updatedConfig.workingDirectory)
266
- );
267
- }
268
-
269
- if (updates.writeEnabledDirectories !== undefined) {
270
- updatedConfig.writeEnabledDirectories = updates.writeEnabledDirectories.map(dir =>
271
- this.normalizePath(dir, updatedConfig.workingDirectory)
272
- );
273
- }
274
-
275
- if (updates.restrictToProject !== undefined) {
276
- updatedConfig.restrictToProject = updates.restrictToProject;
277
- }
278
-
279
- if (updates.allowSystemAccess !== undefined) {
280
- updatedConfig.allowSystemAccess = updates.allowSystemAccess;
281
- }
282
-
283
- if (updates.customRestrictions !== undefined) {
284
- updatedConfig.customRestrictions = updates.customRestrictions.map(restriction =>
285
- path.resolve(restriction)
286
- );
287
- }
288
-
289
- updatedConfig.version = currentConfig.version || '1.0';
290
- updatedConfig.updatedAt = new Date().toISOString();
291
-
292
- return updatedConfig;
293
- }
294
-
295
- /**
296
- * Validate directory access configuration
297
- * @param {Object} accessConfig - Configuration to validate
298
- * @returns {Object} Validation result
299
- */
300
- validateAccessConfiguration(accessConfig) {
301
- const errors = [];
302
- const warnings = [];
303
-
304
- // Validate working directory exists
305
- if (!accessConfig.workingDirectory) {
306
- errors.push('Working directory is required');
307
- } else {
308
- // Convert relative paths to absolute paths relative to process.cwd()
309
- if (!path.isAbsolute(accessConfig.workingDirectory)) {
310
- accessConfig.workingDirectory = path.resolve(process.cwd(), accessConfig.workingDirectory);
311
- }
312
- }
313
-
314
- // Validate directory arrays
315
- if (!Array.isArray(accessConfig.readOnlyDirectories)) {
316
- errors.push('readOnlyDirectories must be an array');
317
- } else {
318
- // Convert relative paths to absolute paths
319
- accessConfig.readOnlyDirectories = accessConfig.readOnlyDirectories.map(dir =>
320
- path.isAbsolute(dir) ? dir : path.resolve(process.cwd(), dir)
321
- );
322
- }
323
-
324
- if (!Array.isArray(accessConfig.writeEnabledDirectories)) {
325
- errors.push('writeEnabledDirectories must be an array');
326
- } else {
327
- // Convert relative paths to absolute paths
328
- accessConfig.writeEnabledDirectories = accessConfig.writeEnabledDirectories.map(dir =>
329
- path.isAbsolute(dir) ? dir : path.resolve(process.cwd(), dir)
330
- );
331
- }
332
-
333
- // Check for overlapping directories
334
- if (accessConfig.readOnlyDirectories && accessConfig.writeEnabledDirectories) {
335
- const overlapping = this.findOverlappingPaths(
336
- accessConfig.readOnlyDirectories,
337
- accessConfig.writeEnabledDirectories
338
- );
339
-
340
- if (overlapping.length > 0) {
341
- warnings.push(`Overlapping directories found: ${overlapping.join(', ')}`);
342
- }
343
- }
344
-
345
- // Check for system path access
346
- if (accessConfig.allowSystemAccess) {
347
- warnings.push('System path access is enabled - use with caution');
348
- }
349
-
350
- // Validate paths exist (async check would be needed in real implementation)
351
- const allPaths = [
352
- ...accessConfig.readOnlyDirectories,
353
- ...accessConfig.writeEnabledDirectories
354
- ];
355
-
356
- for (const dirPath of allPaths) {
357
- if (!path.isAbsolute(dirPath)) {
358
- errors.push(`Directory path must be absolute: ${dirPath}`);
359
- }
360
- }
361
-
362
- return {
363
- valid: errors.length === 0,
364
- errors,
365
- warnings,
366
- summary: {
367
- readOnlyCount: accessConfig.readOnlyDirectories?.length || 0,
368
- writeEnabledCount: accessConfig.writeEnabledDirectories?.length || 0,
369
- restrictToProject: accessConfig.restrictToProject,
370
- allowSystemAccess: accessConfig.allowSystemAccess
371
- }
372
- };
373
- }
374
-
375
- /**
376
- * Create relative path from absolute path within accessible directories
377
- * @param {string} absolutePath - Absolute path to convert
378
- * @param {Object} accessConfig - Directory access configuration
379
- * @returns {string} Relative path or original if not within accessible directories
380
- */
381
- createRelativePath(absolutePath, accessConfig) {
382
- const allDirectories = [
383
- ...accessConfig.readOnlyDirectories,
384
- ...accessConfig.writeEnabledDirectories,
385
- accessConfig.workingDirectory
386
- ];
387
-
388
- for (const dir of allDirectories) {
389
- if (this.isPathWithinDirectory(absolutePath, dir)) {
390
- return path.relative(dir, absolutePath);
391
- }
392
- }
393
-
394
- return absolutePath;
395
- }
396
-
397
- /**
398
- * Resolve path relative to working directory or as absolute
399
- * @private
400
- */
401
- resolvePath(targetPath, workingDirectory) {
402
- if (path.isAbsolute(targetPath)) {
403
- return path.normalize(targetPath);
404
- }
405
- return path.resolve(workingDirectory, targetPath);
406
- }
407
-
408
- /**
409
- * Normalize path to absolute, resolving relative to working directory
410
- * @private
411
- */
412
- normalizePath(targetPath, workingDirectory) {
413
- if (path.isAbsolute(targetPath)) {
414
- return path.normalize(targetPath);
415
- }
416
- return path.resolve(workingDirectory, targetPath);
417
- }
418
-
419
- /**
420
- * Check if path is within a directory
421
- * @private
422
- */
423
- isPathWithinDirectory(targetPath, parentDirectory) {
424
- const relative = path.relative(parentDirectory, targetPath);
425
- return !relative.startsWith('..') && !path.isAbsolute(relative);
426
- }
427
-
428
- /**
429
- * Check if path is within any of the provided directories
430
- * @private
431
- */
432
- isPathWithinAnyDirectory(targetPath, directories) {
433
- return directories.some(dir => this.isPathWithinDirectory(targetPath, dir));
434
- }
435
-
436
- /**
437
- * Check if path is system restricted
438
- * @private
439
- */
440
- isSystemRestrictedPath(targetPath) {
441
- return this.systemRestrictedPaths.some(restrictedPath => {
442
- return targetPath.startsWith(restrictedPath) || targetPath === restrictedPath;
443
- });
444
- }
445
-
446
- /**
447
- * Check if path is custom restricted
448
- * @private
449
- */
450
- isCustomRestricted(targetPath, customRestrictions) {
451
- if (!customRestrictions || customRestrictions.length === 0) {
452
- return false;
453
- }
454
-
455
- return customRestrictions.some(restriction => {
456
- return targetPath.startsWith(restriction) || targetPath === restriction;
457
- });
458
- }
459
-
460
- /**
461
- * Find overlapping paths between two arrays
462
- * @private
463
- */
464
- findOverlappingPaths(paths1, paths2) {
465
- const overlapping = [];
466
-
467
- for (const path1 of paths1) {
468
- for (const path2 of paths2) {
469
- if (this.isPathWithinDirectory(path1, path2) || this.isPathWithinDirectory(path2, path1)) {
470
- overlapping.push(`${path1} <-> ${path2}`);
471
- }
472
- }
473
- }
474
-
475
- return overlapping;
476
- }
477
-
478
- /**
479
- * Get directory access summary for logging/debugging
480
- * @param {Object} accessConfig - Directory access configuration
481
- * @returns {Object} Summary object
482
- */
483
- getAccessSummary(accessConfig) {
484
- return {
485
- workingDirectory: accessConfig.workingDirectory,
486
- readOnlyCount: accessConfig.readOnlyDirectories.length,
487
- writeEnabledCount: accessConfig.writeEnabledDirectories.length,
488
- projectRestricted: accessConfig.restrictToProject,
489
- systemAccessAllowed: accessConfig.allowSystemAccess,
490
- customRestrictionsCount: accessConfig.customRestrictions?.length || 0,
491
- configVersion: accessConfig.version || 'unknown',
492
- lastUpdated: accessConfig.updatedAt || accessConfig.createdAt
493
- };
494
- }
495
-
496
- /**
497
- * Create default directory access for project-based agents
498
- * @param {string} projectDir - Project directory path
499
- * @returns {Object} Default directory access configuration
500
- */
501
- static createProjectDefaults(projectDir) {
502
- const resolvedProject = path.resolve(projectDir);
503
-
504
- return {
505
- workingDirectory: resolvedProject,
506
- readOnlyDirectories: [resolvedProject],
507
- writeEnabledDirectories: [resolvedProject],
508
- restrictToProject: true,
509
- allowSystemAccess: false,
510
- customRestrictions: [],
511
- createdAt: new Date().toISOString(),
512
- version: '1.0'
513
- };
514
- }
515
-
516
- /**
517
- * Create permissive directory access (use with caution)
518
- * @param {string} workingDir - Working directory
519
- * @returns {Object} Permissive directory access configuration
520
- */
521
- static createPermissiveDefaults(workingDir = process.cwd()) {
522
- return {
523
- workingDirectory: path.resolve(workingDir),
524
- readOnlyDirectories: [os.homedir()],
525
- writeEnabledDirectories: [path.resolve(workingDir)],
526
- restrictToProject: false,
527
- allowSystemAccess: false,
528
- customRestrictions: [],
529
- createdAt: new Date().toISOString(),
530
- version: '1.0'
531
- };
532
- }
533
- }
534
-
535
- export default DirectoryAccessManager;
1
+ const a0_0x16d667=a0_0x293c;(function(_0x3195d8,_0x4fc865){const _0x14f9b9=a0_0x293c,_0x1d8b8a=_0x3195d8();while(!![]){try{const _0x22b0c4=-parseInt(_0x14f9b9(0xf8))/0x1+parseInt(_0x14f9b9(0x104))/0x2*(parseInt(_0x14f9b9(0xf4))/0x3)+-parseInt(_0x14f9b9(0x107))/0x4+parseInt(_0x14f9b9(0x11f))/0x5+-parseInt(_0x14f9b9(0x10c))/0x6*(-parseInt(_0x14f9b9(0x101))/0x7)+parseInt(_0x14f9b9(0x10a))/0x8+-parseInt(_0x14f9b9(0x11b))/0x9;if(_0x22b0c4===_0x4fc865)break;else _0x1d8b8a['push'](_0x1d8b8a['shift']());}catch(_0x58f307){_0x1d8b8a['push'](_0x1d8b8a['shift']());}}}(a0_0x492c,0x9cd95));import a0_0x1c643b from'path';import a0_0x4ead27 from'fs/promises';function a0_0x293c(_0x14dc0c,_0x2d9828){_0x14dc0c=_0x14dc0c-0xe8;const _0x492c66=a0_0x492c();let _0x293c9c=_0x492c66[_0x14dc0c];if(a0_0x293c['BUOnsl']===undefined){var _0x40edd3=function(_0x407dd0){const _0x502be7='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1c643b='',_0x4ead27='';for(let _0x2e9205=0x0,_0x287e6a,_0x4bf27e,_0x6e1969=0x0;_0x4bf27e=_0x407dd0['charAt'](_0x6e1969++);~_0x4bf27e&&(_0x287e6a=_0x2e9205%0x4?_0x287e6a*0x40+_0x4bf27e:_0x4bf27e,_0x2e9205++%0x4)?_0x1c643b+=String['fromCharCode'](0xff&_0x287e6a>>(-0x2*_0x2e9205&0x6)):0x0){_0x4bf27e=_0x502be7['indexOf'](_0x4bf27e);}for(let _0x1ed55a=0x0,_0x497f5b=_0x1c643b['length'];_0x1ed55a<_0x497f5b;_0x1ed55a++){_0x4ead27+='%'+('00'+_0x1c643b['charCodeAt'](_0x1ed55a)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4ead27);};a0_0x293c['qBcISI']=_0x40edd3,a0_0x293c['UgLhXk']={},a0_0x293c['BUOnsl']=!![];}const _0x4ea33a=_0x492c66[0x0],_0x1b2701=_0x14dc0c+_0x4ea33a,_0x3ca843=a0_0x293c['UgLhXk'][_0x1b2701];return!_0x3ca843?(_0x293c9c=a0_0x293c['qBcISI'](_0x293c9c),a0_0x293c['UgLhXk'][_0x1b2701]=_0x293c9c):_0x293c9c=_0x3ca843,_0x293c9c;}import a0_0x2e9205 from'os';class DirectoryAccessManager{constructor(_0x287e6a={},_0x4bf27e=null){const _0x191489=a0_0x293c;this['logger']=_0x4bf27e,this[_0x191489(0xf0)]=_0x287e6a,this['systemRestrictedPaths']=[_0x191489(0xeb),'/var','/usr','/bin',_0x191489(0x106),'/boot','/dev','/proc','/sys',_0x191489(0xf6),'C:\x5cProgram\x20Files','C:\x5cProgram\x20Files\x20(x86)',a0_0x1c643b[_0x191489(0xfa)](a0_0x2e9205['homedir'](),_0x191489(0x115)),a0_0x1c643b['join'](a0_0x2e9205['homedir'](),'.aws'),a0_0x1c643b[_0x191489(0xfa)](a0_0x2e9205['homedir'](),'.config'),_0x191489(0xf3),'.git/objects','.git/hooks'];}['createDirectoryAccess'](_0x6e1969={}){const _0xa70863=a0_0x293c,{workingDirectory:workingDirectory=process[_0xa70863(0xec)](),readOnlyDirectories:readOnlyDirectories=[],writeEnabledDirectories:writeEnabledDirectories=[],restrictToProject:restrictToProject=!![],allowSystemAccess:allowSystemAccess=![],customRestrictions:customRestrictions=[]}=_0x6e1969,_0x1ed55a=a0_0x1c643b['resolve'](workingDirectory),_0x497f5b=readOnlyDirectories[_0xa70863(0x109)](_0x46373f=>this['normalizePath'](_0x46373f,_0x1ed55a)),_0x13b29f=writeEnabledDirectories[_0xa70863(0x109)](_0x21329d=>this['normalizePath'](_0x21329d,_0x1ed55a)),_0x4d0237=restrictToProject?[...new Set([..._0x497f5b,_0x1ed55a])]:_0x497f5b,_0x2aa120=restrictToProject?_0x13b29f[_0xa70863(0x100)](_0x33cf7b=>this[_0xa70863(0xff)](_0x33cf7b,_0x1ed55a)):_0x13b29f;return{'workingDirectory':_0x1ed55a,'readOnlyDirectories':_0x4d0237,'writeEnabledDirectories':_0x2aa120,'restrictToProject':restrictToProject,'allowSystemAccess':allowSystemAccess,'customRestrictions':customRestrictions['map'](_0x4abe68=>a0_0x1c643b[_0xa70863(0xf2)](_0x4abe68)),'createdAt':new Date()['toISOString'](),'version':'1.0'};}['validateReadAccess'](_0x4f1f03,_0x7f2bb){const _0x322a27=a0_0x293c;try{const _0x27a6a7=this['resolvePath'](_0x4f1f03,_0x7f2bb[_0x322a27(0x103)]);if(!_0x7f2bb['allowSystemAccess']&&this['isSystemRestrictedPath'](_0x27a6a7))return{'allowed':![],'reason':'System\x20path\x20access\x20denied','path':_0x27a6a7,'category':'system_restricted'};if(this['isCustomRestricted'](_0x27a6a7,_0x7f2bb['customRestrictions']))return{'allowed':![],'reason':'Custom\x20restriction\x20applied','path':_0x27a6a7,'category':'custom_restricted'};if(_0x7f2bb[_0x322a27(0x118)]){const _0x215ab4=this[_0x322a27(0xef)](_0x27a6a7,[..._0x7f2bb[_0x322a27(0x114)],..._0x7f2bb[_0x322a27(0x116)]]);if(!_0x215ab4)return{'allowed':![],'reason':_0x322a27(0xfc),'path':_0x27a6a7,'category':'project_restricted'};}const _0x40b2a6=this['isPathWithinAnyDirectory'](_0x27a6a7,[..._0x7f2bb[_0x322a27(0x114)],..._0x7f2bb['writeEnabledDirectories']]);if(!_0x40b2a6&&_0x7f2bb[_0x322a27(0x114)][_0x322a27(0x112)]>0x0)return{'allowed':![],'reason':'Path\x20not\x20in\x20allowed\x20directories','path':_0x27a6a7,'category':'directory_restricted'};return{'allowed':!![],'path':_0x27a6a7,'category':_0x322a27(0x117)};}catch(_0x4c00fd){return{'allowed':![],'reason':'Path\x20validation\x20error:\x20'+_0x4c00fd[_0x322a27(0x102)],'path':_0x4f1f03,'category':'validation_error'};}}[a0_0x16d667(0xf9)](_0x1a9f0f,_0x10e2ad){const _0x4b9c1b=a0_0x16d667,_0x1ae053=this['validateReadAccess'](_0x1a9f0f,_0x10e2ad);if(!_0x1ae053['allowed'])return{..._0x1ae053,'writeAllowed':![]};const _0x58e3a1=_0x1ae053['path'],_0x2ea911=this[_0x4b9c1b(0xef)](_0x58e3a1,_0x10e2ad['writeEnabledDirectories']);if(!_0x2ea911){const _0x45e196=this['isPathWithinAnyDirectory'](_0x58e3a1,_0x10e2ad[_0x4b9c1b(0x114)]);if(_0x45e196)return{'allowed':![],'writeAllowed':![],'reason':_0x4b9c1b(0xe9),'path':_0x58e3a1,'category':'read_only_restricted'};return{'allowed':![],'writeAllowed':![],'reason':'Path\x20not\x20in\x20write-enabled\x20directories','path':_0x58e3a1,'category':'write_restricted'};}return{'allowed':!![],'writeAllowed':!![],'path':_0x58e3a1,'category':'write_allowed'};}['getWorkingDirectory'](_0x5ff38b){const _0x2dcbca=a0_0x16d667;return _0x5ff38b[_0x2dcbca(0x103)]||process['cwd']();}[a0_0x16d667(0x10d)](_0x348920){const _0x42e7fe=a0_0x16d667;return{'workingDirectory':_0x348920[_0x42e7fe(0x103)],'readOnly':[..._0x348920[_0x42e7fe(0x114)]],'writeEnabled':[..._0x348920['writeEnabledDirectories']],'projectRestricted':_0x348920['restrictToProject'],'systemAccessAllowed':_0x348920[_0x42e7fe(0x110)],'totalDirectories':_0x348920['readOnlyDirectories'][_0x42e7fe(0x112)]+_0x348920['writeEnabledDirectories']['length']};}['updateDirectoryAccess'](_0x287e1c,_0x387ce4){const _0x8ea9c2=a0_0x16d667,_0x4e950b={..._0x287e1c};return _0x387ce4['workingDirectory']&&(_0x4e950b['workingDirectory']=a0_0x1c643b['resolve'](_0x387ce4['workingDirectory'])),_0x387ce4['readOnlyDirectories']!==undefined&&(_0x4e950b[_0x8ea9c2(0x114)]=_0x387ce4[_0x8ea9c2(0x114)]['map'](_0xc652ba=>this[_0x8ea9c2(0x111)](_0xc652ba,_0x4e950b[_0x8ea9c2(0x103)]))),_0x387ce4['writeEnabledDirectories']!==undefined&&(_0x4e950b['writeEnabledDirectories']=_0x387ce4['writeEnabledDirectories']['map'](_0x4c625a=>this[_0x8ea9c2(0x111)](_0x4c625a,_0x4e950b[_0x8ea9c2(0x103)]))),_0x387ce4[_0x8ea9c2(0x118)]!==undefined&&(_0x4e950b['restrictToProject']=_0x387ce4[_0x8ea9c2(0x118)]),_0x387ce4['allowSystemAccess']!==undefined&&(_0x4e950b['allowSystemAccess']=_0x387ce4['allowSystemAccess']),_0x387ce4['customRestrictions']!==undefined&&(_0x4e950b['customRestrictions']=_0x387ce4[_0x8ea9c2(0x10e)]['map'](_0x5ef7eb=>a0_0x1c643b[_0x8ea9c2(0xf2)](_0x5ef7eb))),_0x4e950b[_0x8ea9c2(0xf7)]=_0x287e1c['version']||'1.0',_0x4e950b[_0x8ea9c2(0xfe)]=new Date()[_0x8ea9c2(0x11d)](),_0x4e950b;}[a0_0x16d667(0x11c)](_0x18fe53){const _0x3c3203=a0_0x16d667,_0x2280bf=[],_0x296458=[];!_0x18fe53['workingDirectory']?_0x2280bf[_0x3c3203(0xee)](_0x3c3203(0x108)):!a0_0x1c643b['isAbsolute'](_0x18fe53[_0x3c3203(0x103)])&&(_0x18fe53['workingDirectory']=a0_0x1c643b[_0x3c3203(0xf2)](process[_0x3c3203(0xec)](),_0x18fe53[_0x3c3203(0x103)]));!Array[_0x3c3203(0x11e)](_0x18fe53['readOnlyDirectories'])?_0x2280bf['push'](_0x3c3203(0xfd)):_0x18fe53['readOnlyDirectories']=_0x18fe53['readOnlyDirectories'][_0x3c3203(0x109)](_0x343d07=>a0_0x1c643b['isAbsolute'](_0x343d07)?_0x343d07:a0_0x1c643b[_0x3c3203(0xf2)](process[_0x3c3203(0xec)](),_0x343d07));!Array[_0x3c3203(0x11e)](_0x18fe53[_0x3c3203(0x116)])?_0x2280bf['push'](_0x3c3203(0x113)):_0x18fe53[_0x3c3203(0x116)]=_0x18fe53['writeEnabledDirectories']['map'](_0x328da5=>a0_0x1c643b[_0x3c3203(0x10f)](_0x328da5)?_0x328da5:a0_0x1c643b['resolve'](process['cwd'](),_0x328da5));if(_0x18fe53[_0x3c3203(0x114)]&&_0x18fe53[_0x3c3203(0x116)]){const _0x590371=this['findOverlappingPaths'](_0x18fe53[_0x3c3203(0x114)],_0x18fe53[_0x3c3203(0x116)]);_0x590371['length']>0x0&&_0x296458['push'](_0x3c3203(0xf5)+_0x590371[_0x3c3203(0xfa)](',\x20'));}_0x18fe53['allowSystemAccess']&&_0x296458['push'](_0x3c3203(0xea));const _0x2651a6=[..._0x18fe53[_0x3c3203(0x114)],..._0x18fe53['writeEnabledDirectories']];for(const _0x56f396 of _0x2651a6){!a0_0x1c643b['isAbsolute'](_0x56f396)&&_0x2280bf[_0x3c3203(0xee)]('Directory\x20path\x20must\x20be\x20absolute:\x20'+_0x56f396);}return{'valid':_0x2280bf['length']===0x0,'errors':_0x2280bf,'warnings':_0x296458,'summary':{'readOnlyCount':_0x18fe53[_0x3c3203(0x114)]?.[_0x3c3203(0x112)]||0x0,'writeEnabledCount':_0x18fe53['writeEnabledDirectories']?.['length']||0x0,'restrictToProject':_0x18fe53[_0x3c3203(0x118)],'allowSystemAccess':_0x18fe53[_0x3c3203(0x110)]}};}[a0_0x16d667(0x11a)](_0x52d2ee,_0x7edefb){const _0x235fb0=a0_0x16d667,_0x48f579=[..._0x7edefb['readOnlyDirectories'],..._0x7edefb['writeEnabledDirectories'],_0x7edefb['workingDirectory']];for(const _0x17ac0f of _0x48f579){if(this['isPathWithinDirectory'](_0x52d2ee,_0x17ac0f))return a0_0x1c643b[_0x235fb0(0x105)](_0x17ac0f,_0x52d2ee);}return _0x52d2ee;}[a0_0x16d667(0xed)](_0x2c7876,_0x4ab34a){const _0x448cdd=a0_0x16d667;if(a0_0x1c643b['isAbsolute'](_0x2c7876))return a0_0x1c643b['normalize'](_0x2c7876);return a0_0x1c643b[_0x448cdd(0xf2)](_0x4ab34a,_0x2c7876);}['normalizePath'](_0x20b0fd,_0x4ef7e8){const _0xdcebc9=a0_0x16d667;if(a0_0x1c643b['isAbsolute'](_0x20b0fd))return a0_0x1c643b[_0xdcebc9(0xe8)](_0x20b0fd);return a0_0x1c643b['resolve'](_0x4ef7e8,_0x20b0fd);}[a0_0x16d667(0xff)](_0x2527f3,_0x27aba8){const _0x4d4618=a0_0x16d667,_0x10fa32=a0_0x1c643b[_0x4d4618(0x105)](_0x27aba8,_0x2527f3);return!_0x10fa32[_0x4d4618(0x119)]('..')&&!a0_0x1c643b['isAbsolute'](_0x10fa32);}[a0_0x16d667(0xef)](_0x5dc270,_0x506f49){return _0x506f49['some'](_0x5061f8=>this['isPathWithinDirectory'](_0x5dc270,_0x5061f8));}['isSystemRestrictedPath'](_0x3a3f7d){const _0x5bfb9d=a0_0x16d667;return this[_0x5bfb9d(0x121)][_0x5bfb9d(0xfb)](_0x27679d=>{return _0x3a3f7d['startsWith'](_0x27679d)||_0x3a3f7d===_0x27679d;});}['isCustomRestricted'](_0x274060,_0x24c7d7){if(!_0x24c7d7||_0x24c7d7['length']===0x0)return![];return _0x24c7d7['some'](_0x3d187f=>{const _0x4de5e6=a0_0x293c;return _0x274060[_0x4de5e6(0x119)](_0x3d187f)||_0x274060===_0x3d187f;});}[a0_0x16d667(0xf1)](_0x2d3cdb,_0x2d8e79){const _0x2e09bc=a0_0x16d667,_0x452ee8=[];for(const _0x8dfbde of _0x2d3cdb){for(const _0x2000fb of _0x2d8e79){(this[_0x2e09bc(0xff)](_0x8dfbde,_0x2000fb)||this[_0x2e09bc(0xff)](_0x2000fb,_0x8dfbde))&&_0x452ee8[_0x2e09bc(0xee)](_0x8dfbde+_0x2e09bc(0x10b)+_0x2000fb);}}return _0x452ee8;}[a0_0x16d667(0x120)](_0x53748c){const _0x1018ba=a0_0x16d667;return{'workingDirectory':_0x53748c['workingDirectory'],'readOnlyCount':_0x53748c['readOnlyDirectories'][_0x1018ba(0x112)],'writeEnabledCount':_0x53748c['writeEnabledDirectories'][_0x1018ba(0x112)],'projectRestricted':_0x53748c[_0x1018ba(0x118)],'systemAccessAllowed':_0x53748c[_0x1018ba(0x110)],'customRestrictionsCount':_0x53748c['customRestrictions']?.['length']||0x0,'configVersion':_0x53748c[_0x1018ba(0xf7)]||'unknown','lastUpdated':_0x53748c[_0x1018ba(0xfe)]||_0x53748c['createdAt']};}static['createProjectDefaults'](_0x34eabc){const _0x5d992a=a0_0x16d667,_0x2947f9=a0_0x1c643b['resolve'](_0x34eabc);return{'workingDirectory':_0x2947f9,'readOnlyDirectories':[_0x2947f9],'writeEnabledDirectories':[_0x2947f9],'restrictToProject':!![],'allowSystemAccess':![],'customRestrictions':[],'createdAt':new Date()[_0x5d992a(0x11d)](),'version':'1.0'};}static['createPermissiveDefaults'](_0x100b0c=process[a0_0x16d667(0xec)]()){const _0x2801a4=a0_0x16d667;return{'workingDirectory':a0_0x1c643b[_0x2801a4(0xf2)](_0x100b0c),'readOnlyDirectories':[a0_0x2e9205['homedir']()],'writeEnabledDirectories':[a0_0x1c643b[_0x2801a4(0xf2)](_0x100b0c)],'restrictToProject':![],'allowSystemAccess':![],'customRestrictions':[],'createdAt':new Date()['toISOString'](),'version':'1.0'};}}export default DirectoryAccessManager;function a0_0x492c(){const _0x46d500=['mti2ody5mgf5C2juAq','DMfSAwrHDgvxCML0zufJy2vZCW','AM9PBG','C29Tzq','ugf0AcbVDxrZAwrLihbYB2PLy3qGC2nVCgu','CMvHze9UBhLeAxjLy3rVCMLLCYbTDxn0igjLigfUigfYCMf5','DxbKyxrLzef0','AxnqyxrOv2L0AgLUrgLYzwn0B3j5','zMLSDgvY','mtGZmZuZmufzzxjwwq','BwvZC2fNzq','D29YA2LUz0rPCMvJDg9YEq','nteZmtG2Du9fuuPl','CMvSyxrPDMu','l3nIAw4','mty1mdy0ngHSzMDhtq','v29YA2LUzYbKAxjLy3rVCNKGAxmGCMvXDwLYzwq','BwfW','otC4nda5nM1qwKroCq','idWTpIa','nLv4wvLjvq','z2v0qwnJzxnZAwjSzurPCMvJDg9YAwvZ','y3vZDg9TuMvZDhjPy3rPB25Z','AxnbyNnVBhv0zq','ywXSB3DtExn0zw1by2nLC3m','BM9YBwfSAxPLugf0Aa','BgvUz3rO','D3jPDgvfBMfIBgvKrgLYzwn0B3jPzxmGBxvZDcbIzsbHBIbHCNjHEq','CMvHze9UBhLeAxjLy3rVCMLLCW','lNnZAa','D3jPDgvfBMfIBgvKrgLYzwn0B3jPzxm','ywXSB3DLza','CMvZDhjPy3ruB1bYB2PLy3q','C3rHCNrZv2L0Aa','y3jLyxrLuMvSyxrPDMvqyxrO','nJG4ntKWtwnQtND6','DMfSAwrHDgvby2nLC3ndB25MAwD1CMf0Aw9U','Dg9ju09tDhjPBMC','AxnbCNjHEq','nZi3otuWvwvhuKHd','z2v0qwnJzxnZu3vTBwfYEq','C3LZDgvTuMvZDhjPy3rLzfbHDgHZ','BM9YBwfSAxPL','ugf0AcbPCYbPBIbYzwfKlw9UBhKGzgLYzwn0B3j5','u3LZDgvTihbHDgGGywnJzxnZigLZigvUywjSzwqGlsb1C2uGD2L0AcbJyxv0Aw9U','l2v0yW','y3DK','CMvZB2X2zvbHDgG','ChvZAa','AxnqyxrOv2L0AgLUqw55rgLYzwn0B3j5','y29UzMLN','zMLUze92zxjSyxbWAw5Nugf0Ahm','CMvZB2X2zq','BM9Kzv9TB2r1BgvZlY5IAw4','ovbtvgzgwa','t3zLCMXHChbPBMCGzgLYzwn0B3jPzxmGzM91BMq6ia','qZPCv2LUzg93CW','DMvYC2LVBG'];a0_0x492c=function(){return _0x46d500;};return a0_0x492c();}