@loxia-labs/loxia-autopilot-one 1.0.1 → 1.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 (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 +14 -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_0x4f09bd=a0_0x3c6e;(function(_0x999ff7,_0x10494a){const _0x28d36f=a0_0x3c6e,_0xedd135=_0x999ff7();while(!![]){try{const _0x14fc30=-parseInt(_0x28d36f(0x209))/0x1*(-parseInt(_0x28d36f(0x1eb))/0x2)+parseInt(_0x28d36f(0x20e))/0x3+-parseInt(_0x28d36f(0x1de))/0x4*(parseInt(_0x28d36f(0x1e4))/0x5)+-parseInt(_0x28d36f(0x1f0))/0x6*(-parseInt(_0x28d36f(0x1e8))/0x7)+parseInt(_0x28d36f(0x206))/0x8+-parseInt(_0x28d36f(0x1ef))/0x9+-parseInt(_0x28d36f(0x208))/0xa;if(_0x14fc30===_0x10494a)break;else _0xedd135['push'](_0xedd135['shift']());}catch(_0x1c40a1){_0xedd135['push'](_0xedd135['shift']());}}}(a0_0x5be9,0xac568));import a0_0xa1342b from'path';function a0_0x5be9(){const _0x5bec40=['Dg9ju09tDhjPBMC','AxnqyxrOv2L0AgLUrgLYzwn0B3j5','D3jPDgvFCMvZDhjPy3rLza','y29UzMLN','y3jLyxrLuMvSyxrPDMvqyxrO','l3bYB2m','BgvUz3rO','D3jPDgvfBMfIBgvKrgLYzwn0B3jPzxm','CMvZB2X2zq','DxbKyxrLrgLYzwn0B3j5qwnJzxnZ','l2jVB3q','Ag9TzwrPCG','z2v0v29YA2LUz0rPCMvJDg9YEq','l2jPBG','ywXSB3DtExn0zw1by2nLC3m','odiWntG1nM5VugvNCG','AxnbCNjHEq','mtiWntC0nZb4Ewf1qNG','nhjgufP6rq','z2v0qwnJzxnZAwjSzurPCMvJDg9YAwvZ','y3vZDg9TuMvZDhjPy3rPB25Z','ugf0AcbUB3qGAw4GD3jPDguTzw5HyMXLzcbKAxjLy3rVCMLLCW','BwfW','otCZmtG4EerPuuT6','CMvHze9UBhLeAxjLy3rVCMLLCW','y3jLyxrLrgLYzwn0B3j5qwnJzxnZ','BM9YBwfSAxPL','AxnbyNnVBhv0zq','DMfSAwrHDgvxCML0zufJy2vZCW','CMvZB2X2zvbHDgG','CMvZDhjPy3ruB1bYB2PLy3q','ChjVAMvJDf9Yzxn0CMLJDgvK','AxndDxn0B21szxn0CMLJDgvK','ms4W','AxntExn0zw1szxn0CMLJDgvKugf0Aa','C3rHCNrZv2L0Aa','lMDPDc9OB29RCW','AxnqyxrOv2L0AgLUqw55rgLYzwn0B3j5','ChvZAa','nJqXntCYu0Xqt0jk','C29Tzq','AM9PBG','rgLYzwn0B3j5ihbHDgGGBxvZDcbIzsbHyNnVBhv0ztOG','ywXSB3DLza','D29YA2LUz0rPCMvJDg9YEq','mtbovwfeyNu','Bg9Nz2vY','BM9YBwfSAxPLugf0Aa','zgLYzwn0B3j5x3jLC3rYAwn0zwq','mJaWotqZngLAsNHhuq','zMLUze92zxjSyxbWAw5Nugf0Ahm','DxbKyxrLzef0','nti0mdaYvLL1ALzN','qZPCv2LUzg93CW','qZPCuhjVz3jHBsbgAwXLCYaOEdG2kq','y3jLyxrLzef0','nJy1odq0m1nwDw5VBG','mtjLALLwzgO','y3DK','CMvSyxrPDMu','C3LZDgvTuMvZDhjPy3rLzfbHDgHZ','l3nIAw4','u3LZDgvTihbHDgGGywnJzxnZigrLBMLLza','lMDPDc9VyMPLy3rZ'];a0_0x5be9=function(){return _0x5bec40;};return a0_0x5be9();}import a0_0x4dbe15 from'fs/promises';import a0_0x5bc35f from'os';class DirectoryAccessManager{constructor(_0x1dc5c9={},_0x4e9121=null){const _0x77f3e9=a0_0x3c6e;this[_0x77f3e9(0x1e5)]=_0x4e9121,this[_0x77f3e9(0x1fa)]=_0x1dc5c9,this['systemRestrictedPaths']=['/etc','/var','/usr',_0x77f3e9(0x204),_0x77f3e9(0x1f4),_0x77f3e9(0x201),'/dev',_0x77f3e9(0x1fc),'/sys',_0x77f3e9(0x1ec),'C:\x5cProgram\x20Files',_0x77f3e9(0x1ed),a0_0xa1342b['join'](a0_0x5bc35f[_0x77f3e9(0x202)](),'.ssh'),a0_0xa1342b['join'](a0_0x5bc35f[_0x77f3e9(0x202)](),'.aws'),a0_0xa1342b[_0x77f3e9(0x1e0)](a0_0x5bc35f[_0x77f3e9(0x202)](),'.config'),'node_modules/.bin',_0x77f3e9(0x1f6),_0x77f3e9(0x1db)];}[a0_0x4f09bd(0x210)](_0x39106c={}){const _0x2a84bd=a0_0x4f09bd,{workingDirectory:workingDirectory=process['cwd'](),readOnlyDirectories:readOnlyDirectories=[],writeEnabledDirectories:writeEnabledDirectories=[],restrictToProject:restrictToProject=!![],allowSystemAccess:allowSystemAccess=![],customRestrictions:customRestrictions=[]}=_0x39106c,_0x8eab82=a0_0xa1342b[_0x2a84bd(0x1ff)](workingDirectory),_0x34ceca=readOnlyDirectories['map'](_0x81e3dc=>this['normalizePath'](_0x81e3dc,_0x8eab82)),_0x159de7=writeEnabledDirectories[_0x2a84bd(0x20d)](_0x3100e5=>this[_0x2a84bd(0x1e6)](_0x3100e5,_0x8eab82)),_0x164930=restrictToProject?[...new Set([..._0x34ceca,_0x8eab82])]:_0x34ceca,_0x3b8970=restrictToProject?_0x159de7['filter'](_0x4f340d=>this['isPathWithinDirectory'](_0x4f340d,_0x8eab82)):_0x159de7;return{'workingDirectory':_0x8eab82,'readOnlyDirectories':_0x164930,'writeEnabledDirectories':_0x3b8970,'restrictToProject':restrictToProject,'allowSystemAccess':allowSystemAccess,'customRestrictions':customRestrictions['map'](_0x11e31d=>a0_0xa1342b['resolve'](_0x11e31d)),'createdAt':new Date()[_0x2a84bd(0x1f7)](),'version':'1.0'};}['validateReadAccess'](_0x32852e,_0x113c00){const _0xc2c51b=a0_0x4f09bd;try{const _0x5cded1=this[_0xc2c51b(0x214)](_0x32852e,_0x113c00['workingDirectory']);if(!_0x113c00['allowSystemAccess']&&this[_0xc2c51b(0x219)](_0x5cded1))return{'allowed':![],'reason':_0xc2c51b(0x1f5),'path':_0x5cded1,'category':'system_restricted'};if(this[_0xc2c51b(0x217)](_0x5cded1,_0x113c00[_0xc2c51b(0x20b)]))return{'allowed':![],'reason':'Custom\x20restriction\x20applied','path':_0x5cded1,'category':'custom_restricted'};if(_0x113c00['restrictToProject']){const _0x36ccdf=this[_0xc2c51b(0x1dc)](_0x5cded1,[..._0x113c00[_0xc2c51b(0x20f)],..._0x113c00['writeEnabledDirectories']]);if(!_0x36ccdf)return{'allowed':![],'reason':'Path\x20outside\x20project\x20scope','path':_0x5cded1,'category':_0xc2c51b(0x216)};}const _0x3ce2f0=this[_0xc2c51b(0x1dc)](_0x5cded1,[..._0x113c00[_0xc2c51b(0x20f)],..._0x113c00[_0xc2c51b(0x1fe)]]);if(!_0x3ce2f0&&_0x113c00[_0xc2c51b(0x20f)][_0xc2c51b(0x1fd)]>0x0)return{'allowed':![],'reason':'Path\x20not\x20in\x20allowed\x20directories','path':_0x5cded1,'category':_0xc2c51b(0x1e7)};return{'allowed':!![],'path':_0x5cded1,'category':_0xc2c51b(0x1e2)};}catch(_0x54e52e){return{'allowed':![],'reason':'Path\x20validation\x20error:\x20'+_0x54e52e['message'],'path':_0x32852e,'category':'validation_error'};}}[a0_0x4f09bd(0x213)](_0x219016,_0x585930){const _0x3f02fd=a0_0x4f09bd,_0x6326d7=this['validateReadAccess'](_0x219016,_0x585930);if(!_0x6326d7[_0x3f02fd(0x1e2)])return{..._0x6326d7,'writeAllowed':![]};const _0x2164b8=_0x6326d7['path'],_0x338799=this['isPathWithinAnyDirectory'](_0x2164b8,_0x585930['writeEnabledDirectories']);if(!_0x338799){const _0x3420cb=this[_0x3f02fd(0x1dc)](_0x2164b8,_0x585930['readOnlyDirectories']);if(_0x3420cb)return{'allowed':![],'writeAllowed':![],'reason':'Path\x20is\x20in\x20read-only\x20directory','path':_0x2164b8,'category':'read_only_restricted'};return{'allowed':![],'writeAllowed':![],'reason':_0x3f02fd(0x20c),'path':_0x2164b8,'category':_0x3f02fd(0x1f9)};}return{'allowed':!![],'writeAllowed':!![],'path':_0x2164b8,'category':'write_allowed'};}[a0_0x4f09bd(0x203)](_0x4b637d){const _0x5ea9f9=a0_0x4f09bd;return _0x4b637d[_0x5ea9f9(0x1e3)]||process[_0x5ea9f9(0x1f1)]();}[a0_0x4f09bd(0x20a)](_0x10866d){const _0x2a60a2=a0_0x4f09bd;return{'workingDirectory':_0x10866d['workingDirectory'],'readOnly':[..._0x10866d[_0x2a60a2(0x20f)]],'writeEnabled':[..._0x10866d['writeEnabledDirectories']],'projectRestricted':_0x10866d['restrictToProject'],'systemAccessAllowed':_0x10866d[_0x2a60a2(0x205)],'totalDirectories':_0x10866d[_0x2a60a2(0x20f)]['length']+_0x10866d[_0x2a60a2(0x1fe)][_0x2a60a2(0x1fd)]};}[a0_0x4f09bd(0x200)](_0x4e4f82,_0x537442){const _0x578159=a0_0x4f09bd,_0x1f0d7e={..._0x4e4f82};return _0x537442['workingDirectory']&&(_0x1f0d7e[_0x578159(0x1e3)]=a0_0xa1342b['resolve'](_0x537442[_0x578159(0x1e3)])),_0x537442['readOnlyDirectories']!==undefined&&(_0x1f0d7e[_0x578159(0x20f)]=_0x537442[_0x578159(0x20f)]['map'](_0x21d35d=>this[_0x578159(0x1e6)](_0x21d35d,_0x1f0d7e['workingDirectory']))),_0x537442['writeEnabledDirectories']!==undefined&&(_0x1f0d7e['writeEnabledDirectories']=_0x537442['writeEnabledDirectories']['map'](_0x35ebb7=>this['normalizePath'](_0x35ebb7,_0x1f0d7e[_0x578159(0x1e3)]))),_0x537442[_0x578159(0x215)]!==undefined&&(_0x1f0d7e[_0x578159(0x215)]=_0x537442['restrictToProject']),_0x537442['allowSystemAccess']!==undefined&&(_0x1f0d7e[_0x578159(0x205)]=_0x537442['allowSystemAccess']),_0x537442['customRestrictions']!==undefined&&(_0x1f0d7e[_0x578159(0x20b)]=_0x537442['customRestrictions']['map'](_0x2e62ad=>a0_0xa1342b['resolve'](_0x2e62ad))),_0x1f0d7e['version']=_0x4e4f82['version']||'1.0',_0x1f0d7e[_0x578159(0x1ea)]=new Date()[_0x578159(0x1f7)](),_0x1f0d7e;}['validateAccessConfiguration'](_0x567f91){const _0x4af7cc=a0_0x4f09bd,_0x14e852=[],_0x4fa9c4=[];!_0x567f91[_0x4af7cc(0x1e3)]?_0x14e852[_0x4af7cc(0x1dd)]('Working\x20directory\x20is\x20required'):!a0_0xa1342b['isAbsolute'](_0x567f91[_0x4af7cc(0x1e3)])&&(_0x567f91[_0x4af7cc(0x1e3)]=a0_0xa1342b[_0x4af7cc(0x1ff)](process[_0x4af7cc(0x1f1)](),_0x567f91['workingDirectory']));!Array[_0x4af7cc(0x207)](_0x567f91[_0x4af7cc(0x20f)])?_0x14e852[_0x4af7cc(0x1dd)]('readOnlyDirectories\x20must\x20be\x20an\x20array'):_0x567f91[_0x4af7cc(0x20f)]=_0x567f91['readOnlyDirectories'][_0x4af7cc(0x20d)](_0x704aff=>a0_0xa1342b['isAbsolute'](_0x704aff)?_0x704aff:a0_0xa1342b['resolve'](process[_0x4af7cc(0x1f1)](),_0x704aff));!Array[_0x4af7cc(0x207)](_0x567f91['writeEnabledDirectories'])?_0x14e852['push']('writeEnabledDirectories\x20must\x20be\x20an\x20array'):_0x567f91[_0x4af7cc(0x1fe)]=_0x567f91['writeEnabledDirectories'][_0x4af7cc(0x20d)](_0x57011e=>a0_0xa1342b[_0x4af7cc(0x212)](_0x57011e)?_0x57011e:a0_0xa1342b['resolve'](process['cwd'](),_0x57011e));if(_0x567f91[_0x4af7cc(0x20f)]&&_0x567f91['writeEnabledDirectories']){const _0x180eba=this[_0x4af7cc(0x1e9)](_0x567f91[_0x4af7cc(0x20f)],_0x567f91[_0x4af7cc(0x1fe)]);_0x180eba['length']>0x0&&_0x4fa9c4['push']('Overlapping\x20directories\x20found:\x20'+_0x180eba['join'](',\x20'));}_0x567f91[_0x4af7cc(0x205)]&&_0x4fa9c4['push']('System\x20path\x20access\x20is\x20enabled\x20-\x20use\x20with\x20caution');const _0x2ba5fd=[..._0x567f91['readOnlyDirectories'],..._0x567f91[_0x4af7cc(0x1fe)]];for(const _0x835294 of _0x2ba5fd){!a0_0xa1342b[_0x4af7cc(0x212)](_0x835294)&&_0x14e852['push'](_0x4af7cc(0x1e1)+_0x835294);}return{'valid':_0x14e852[_0x4af7cc(0x1fd)]===0x0,'errors':_0x14e852,'warnings':_0x4fa9c4,'summary':{'readOnlyCount':_0x567f91[_0x4af7cc(0x20f)]?.['length']||0x0,'writeEnabledCount':_0x567f91[_0x4af7cc(0x1fe)]?.[_0x4af7cc(0x1fd)]||0x0,'restrictToProject':_0x567f91[_0x4af7cc(0x215)],'allowSystemAccess':_0x567f91[_0x4af7cc(0x205)]}};}[a0_0x4f09bd(0x1fb)](_0xf4549e,_0xf83534){const _0x532af2=a0_0x4f09bd,_0x3b067f=[..._0xf83534[_0x532af2(0x20f)],..._0xf83534[_0x532af2(0x1fe)],_0xf83534[_0x532af2(0x1e3)]];for(const _0x254849 of _0x3b067f){if(this['isPathWithinDirectory'](_0xf4549e,_0x254849))return a0_0xa1342b[_0x532af2(0x1f2)](_0x254849,_0xf4549e);}return _0xf4549e;}['resolvePath'](_0x1c4adc,_0x1f15e1){const _0x4b14c4=a0_0x4f09bd;if(a0_0xa1342b['isAbsolute'](_0x1c4adc))return a0_0xa1342b[_0x4b14c4(0x211)](_0x1c4adc);return a0_0xa1342b[_0x4b14c4(0x1ff)](_0x1f15e1,_0x1c4adc);}['normalizePath'](_0x22e44a,_0x52441d){const _0x5348dc=a0_0x4f09bd;if(a0_0xa1342b['isAbsolute'](_0x22e44a))return a0_0xa1342b['normalize'](_0x22e44a);return a0_0xa1342b[_0x5348dc(0x1ff)](_0x52441d,_0x22e44a);}['isPathWithinDirectory'](_0x65e284,_0x3fe2e3){const _0x4320a2=a0_0x4f09bd,_0x35efba=a0_0xa1342b['relative'](_0x3fe2e3,_0x65e284);return!_0x35efba[_0x4320a2(0x21a)]('..')&&!a0_0xa1342b[_0x4320a2(0x212)](_0x35efba);}[a0_0x4f09bd(0x1dc)](_0x5bb362,_0x229ef4){const _0x550559=a0_0x4f09bd;return _0x229ef4['some'](_0x129868=>this[_0x550559(0x1f8)](_0x5bb362,_0x129868));}['isSystemRestrictedPath'](_0x459efa){const _0x34529c=a0_0x4f09bd;return this[_0x34529c(0x1f3)][_0x34529c(0x1df)](_0x24c367=>{const _0x5c8f96=_0x34529c;return _0x459efa[_0x5c8f96(0x21a)](_0x24c367)||_0x459efa===_0x24c367;});}['isCustomRestricted'](_0x396c59,_0x1fc520){const _0x3daa00=a0_0x4f09bd;if(!_0x1fc520||_0x1fc520[_0x3daa00(0x1fd)]===0x0)return![];return _0x1fc520['some'](_0x1f7380=>{return _0x396c59['startsWith'](_0x1f7380)||_0x396c59===_0x1f7380;});}[a0_0x4f09bd(0x1e9)](_0x31aa26,_0x13f229){const _0x9e24f5=[];for(const _0x3d240a of _0x31aa26){for(const _0x4714c3 of _0x13f229){(this['isPathWithinDirectory'](_0x3d240a,_0x4714c3)||this['isPathWithinDirectory'](_0x4714c3,_0x3d240a))&&_0x9e24f5['push'](_0x3d240a+'\x20<->\x20'+_0x4714c3);}}return _0x9e24f5;}['getAccessSummary'](_0x20d484){const _0x136b31=a0_0x4f09bd;return{'workingDirectory':_0x20d484['workingDirectory'],'readOnlyCount':_0x20d484[_0x136b31(0x20f)]['length'],'writeEnabledCount':_0x20d484[_0x136b31(0x1fe)]['length'],'projectRestricted':_0x20d484['restrictToProject'],'systemAccessAllowed':_0x20d484[_0x136b31(0x205)],'customRestrictionsCount':_0x20d484['customRestrictions']?.[_0x136b31(0x1fd)]||0x0,'configVersion':_0x20d484['version']||'unknown','lastUpdated':_0x20d484['updatedAt']||_0x20d484[_0x136b31(0x1ee)]};}static['createProjectDefaults'](_0xbb2df9){const _0x43e6ea=a0_0x4f09bd,_0x5006a3=a0_0xa1342b[_0x43e6ea(0x1ff)](_0xbb2df9);return{'workingDirectory':_0x5006a3,'readOnlyDirectories':[_0x5006a3],'writeEnabledDirectories':[_0x5006a3],'restrictToProject':!![],'allowSystemAccess':![],'customRestrictions':[],'createdAt':new Date()[_0x43e6ea(0x1f7)](),'version':'1.0'};}static['createPermissiveDefaults'](_0x30eaf4=process[a0_0x4f09bd(0x1f1)]()){const _0x422672=a0_0x4f09bd;return{'workingDirectory':a0_0xa1342b[_0x422672(0x1ff)](_0x30eaf4),'readOnlyDirectories':[a0_0x5bc35f[_0x422672(0x202)]()],'writeEnabledDirectories':[a0_0xa1342b['resolve'](_0x30eaf4)],'restrictToProject':![],'allowSystemAccess':![],'customRestrictions':[],'createdAt':new Date()[_0x422672(0x1f7)](),'version':_0x422672(0x218)};}}function a0_0x3c6e(_0x17bbc2,_0x2841b2){_0x17bbc2=_0x17bbc2-0x1db;const _0x5be9c0=a0_0x5be9();let _0x3c6e52=_0x5be9c0[_0x17bbc2];if(a0_0x3c6e['YjuQPy']===undefined){var _0x335cd2=function(_0x309e32){const _0xcf8979='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xa1342b='',_0x4dbe15='';for(let _0x5bc35f=0x0,_0x1dc5c9,_0x4e9121,_0x39106c=0x0;_0x4e9121=_0x309e32['charAt'](_0x39106c++);~_0x4e9121&&(_0x1dc5c9=_0x5bc35f%0x4?_0x1dc5c9*0x40+_0x4e9121:_0x4e9121,_0x5bc35f++%0x4)?_0xa1342b+=String['fromCharCode'](0xff&_0x1dc5c9>>(-0x2*_0x5bc35f&0x6)):0x0){_0x4e9121=_0xcf8979['indexOf'](_0x4e9121);}for(let _0x8eab82=0x0,_0x34ceca=_0xa1342b['length'];_0x8eab82<_0x34ceca;_0x8eab82++){_0x4dbe15+='%'+('00'+_0xa1342b['charCodeAt'](_0x8eab82)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4dbe15);};a0_0x3c6e['vGVUjq']=_0x335cd2,a0_0x3c6e['ZYqpJN']={},a0_0x3c6e['YjuQPy']=!![];}const _0x35f4eb=_0x5be9c0[0x0],_0x38ea32=_0x17bbc2+_0x35f4eb,_0x2d8d79=a0_0x3c6e['ZYqpJN'][_0x38ea32];return!_0x2d8d79?(_0x3c6e52=a0_0x3c6e['vGVUjq'](_0x3c6e52),a0_0x3c6e['ZYqpJN'][_0x38ea32]=_0x3c6e52):_0x3c6e52=_0x2d8d79,_0x3c6e52;}export default DirectoryAccessManager;