@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.
- package/README.md +44 -54
- package/bin/cli.js +1 -115
- package/bin/loxia-terminal-v2.js +3 -0
- package/bin/loxia-terminal.js +3 -0
- package/bin/start-with-terminal.js +3 -0
- package/package.json +15 -15
- package/scripts/install-scanners.js +1 -235
- package/src/analyzers/CSSAnalyzer.js +1 -297
- package/src/analyzers/ConfigValidator.js +1 -690
- package/src/analyzers/ESLintAnalyzer.js +1 -320
- package/src/analyzers/JavaScriptAnalyzer.js +1 -261
- package/src/analyzers/PrettierFormatter.js +1 -247
- package/src/analyzers/PythonAnalyzer.js +1 -266
- package/src/analyzers/SecurityAnalyzer.js +1 -729
- package/src/analyzers/TypeScriptAnalyzer.js +1 -247
- package/src/analyzers/codeCloneDetector/analyzer.js +1 -344
- package/src/analyzers/codeCloneDetector/detector.js +1 -203
- package/src/analyzers/codeCloneDetector/index.js +1 -160
- package/src/analyzers/codeCloneDetector/parser.js +1 -199
- package/src/analyzers/codeCloneDetector/reporter.js +1 -148
- package/src/analyzers/codeCloneDetector/scanner.js +1 -59
- package/src/core/agentPool.js +1 -1474
- package/src/core/agentScheduler.js +1 -2147
- package/src/core/contextManager.js +1 -709
- package/src/core/messageProcessor.js +1 -732
- package/src/core/orchestrator.js +1 -548
- package/src/core/stateManager.js +1 -877
- package/src/index.js +1 -631
- package/src/interfaces/cli.js +1 -549
- package/src/interfaces/terminal/__tests__/smoke/advancedFeatures.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/agentControl.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/agents.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/components.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/connection.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/enhancements.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/imports.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/messages.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/tools.test.js +1 -0
- package/src/interfaces/terminal/api/apiClient.js +1 -0
- package/src/interfaces/terminal/api/messageRouter.js +1 -0
- package/src/interfaces/terminal/api/session.js +1 -0
- package/src/interfaces/terminal/api/websocket.js +1 -0
- package/src/interfaces/terminal/components/AgentCreator.js +1 -0
- package/src/interfaces/terminal/components/AgentEditor.js +1 -0
- package/src/interfaces/terminal/components/AgentSwitcher.js +1 -0
- package/src/interfaces/terminal/components/ErrorBoundary.js +1 -0
- package/src/interfaces/terminal/components/ErrorPanel.js +1 -0
- package/src/interfaces/terminal/components/Header.js +1 -0
- package/src/interfaces/terminal/components/HelpPanel.js +1 -0
- package/src/interfaces/terminal/components/InputBox.js +1 -0
- package/src/interfaces/terminal/components/Layout.js +1 -0
- package/src/interfaces/terminal/components/LoadingSpinner.js +1 -0
- package/src/interfaces/terminal/components/MessageList.js +1 -0
- package/src/interfaces/terminal/components/MultilineTextInput.js +1 -0
- package/src/interfaces/terminal/components/SearchPanel.js +1 -0
- package/src/interfaces/terminal/components/SettingsPanel.js +1 -0
- package/src/interfaces/terminal/components/StatusBar.js +1 -0
- package/src/interfaces/terminal/components/TextInput.js +1 -0
- package/src/interfaces/terminal/config/agentEditorConstants.js +1 -0
- package/src/interfaces/terminal/config/constants.js +1 -0
- package/src/interfaces/terminal/index.js +1 -0
- package/src/interfaces/terminal/state/useAgentControl.js +1 -0
- package/src/interfaces/terminal/state/useAgents.js +1 -0
- package/src/interfaces/terminal/state/useConnection.js +1 -0
- package/src/interfaces/terminal/state/useMessages.js +1 -0
- package/src/interfaces/terminal/state/useTools.js +1 -0
- package/src/interfaces/terminal/utils/debugLogger.js +1 -0
- package/src/interfaces/terminal/utils/settingsStorage.js +1 -0
- package/src/interfaces/terminal/utils/theme.js +1 -0
- package/src/interfaces/webServer.js +1 -2162
- package/src/modules/fileExplorer/controller.js +1 -280
- package/src/modules/fileExplorer/index.js +1 -37
- package/src/modules/fileExplorer/middleware.js +1 -92
- package/src/modules/fileExplorer/routes.js +1 -125
- package/src/modules/fileExplorer/types.js +1 -44
- package/src/services/aiService.js +1 -1232
- package/src/services/apiKeyManager.js +1 -164
- package/src/services/benchmarkService.js +1 -366
- package/src/services/budgetService.js +1 -539
- package/src/services/contextInjectionService.js +1 -247
- package/src/services/conversationCompactionService.js +1 -637
- package/src/services/errorHandler.js +1 -810
- package/src/services/fileAttachmentService.js +1 -544
- package/src/services/modelRouterService.js +1 -366
- package/src/services/modelsService.js +1 -322
- package/src/services/qualityInspector.js +1 -796
- package/src/services/tokenCountingService.js +1 -536
- package/src/tools/agentCommunicationTool.js +1 -1344
- package/src/tools/agentDelayTool.js +1 -485
- package/src/tools/asyncToolManager.js +1 -604
- package/src/tools/baseTool.js +1 -800
- package/src/tools/browserTool.js +1 -920
- package/src/tools/cloneDetectionTool.js +1 -621
- package/src/tools/dependencyResolverTool.js +1 -1215
- package/src/tools/fileContentReplaceTool.js +1 -875
- package/src/tools/fileSystemTool.js +1 -1107
- package/src/tools/fileTreeTool.js +1 -853
- package/src/tools/imageTool.js +1 -901
- package/src/tools/importAnalyzerTool.js +1 -1060
- package/src/tools/jobDoneTool.js +1 -248
- package/src/tools/seekTool.js +1 -956
- package/src/tools/staticAnalysisTool.js +1 -1778
- package/src/tools/taskManagerTool.js +1 -2873
- package/src/tools/terminalTool.js +1 -2304
- package/src/tools/webTool.js +1 -1430
- package/src/types/agent.js +1 -519
- package/src/types/contextReference.js +1 -972
- package/src/types/conversation.js +1 -730
- package/src/types/toolCommand.js +1 -747
- package/src/utilities/attachmentValidator.js +1 -292
- package/src/utilities/configManager.js +1 -582
- package/src/utilities/constants.js +1 -722
- package/src/utilities/directoryAccessManager.js +1 -535
- package/src/utilities/fileProcessor.js +1 -307
- package/src/utilities/logger.js +1 -436
- package/src/utilities/tagParser.js +1 -1246
- package/src/utilities/toolConstants.js +1 -317
- package/web-ui/build/index.html +2 -2
- package/web-ui/build/static/{index-Dy2bYbOa.css → index-CClD1090.css} +1 -1
- package/web-ui/build/static/{index-CjkkcnFA.js → index-lCBai6dX.js} +66 -67
|
@@ -1,307 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* File Processor
|
|
3
|
-
* Handles file reading, conversion, and processing operations
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import fs from 'fs/promises';
|
|
7
|
-
import path from 'path';
|
|
8
|
-
import crypto from 'crypto';
|
|
9
|
-
|
|
10
|
-
// PDF support disabled due to DOM API requirements in Node.js environment
|
|
11
|
-
// The pdf-parse library requires browser DOM APIs (DOMMatrix, ImageData, Path2D)
|
|
12
|
-
// which are not available in Node.js. PDF text extraction can be re-enabled
|
|
13
|
-
// by installing canvas-based polyfills or using an alternative PDF library.
|
|
14
|
-
|
|
15
|
-
class FileProcessor {
|
|
16
|
-
constructor(config = {}, logger = null) {
|
|
17
|
-
this.config = config;
|
|
18
|
-
this.logger = logger;
|
|
19
|
-
this.pdfSupported = false; // Disabled - requires DOM APIs
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Read file content
|
|
24
|
-
* @param {string} filePath - Path to file
|
|
25
|
-
* @param {string} encoding - File encoding (default: 'utf8')
|
|
26
|
-
* @returns {Promise<string|Buffer>}
|
|
27
|
-
*/
|
|
28
|
-
async readFile(filePath, encoding = 'utf8') {
|
|
29
|
-
try {
|
|
30
|
-
const content = await fs.readFile(filePath, encoding);
|
|
31
|
-
return content;
|
|
32
|
-
} catch (error) {
|
|
33
|
-
this.logger?.error('Error reading file', { filePath, error: error.message });
|
|
34
|
-
throw new Error(`Failed to read file: ${error.message}`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Convert image to base64
|
|
40
|
-
* @param {string} filePath - Path to image file
|
|
41
|
-
* @returns {Promise<string>} Base64 encoded string with data URI
|
|
42
|
-
*/
|
|
43
|
-
async imageToBase64(filePath) {
|
|
44
|
-
try {
|
|
45
|
-
const buffer = await fs.readFile(filePath);
|
|
46
|
-
const ext = path.extname(filePath).toLowerCase();
|
|
47
|
-
|
|
48
|
-
// Determine MIME type
|
|
49
|
-
const mimeTypes = {
|
|
50
|
-
'.jpg': 'image/jpeg',
|
|
51
|
-
'.jpeg': 'image/jpeg',
|
|
52
|
-
'.png': 'image/png',
|
|
53
|
-
'.gif': 'image/gif',
|
|
54
|
-
'.webp': 'image/webp',
|
|
55
|
-
'.bmp': 'image/bmp',
|
|
56
|
-
'.svg': 'image/svg+xml'
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const mimeType = mimeTypes[ext] || 'image/jpeg';
|
|
60
|
-
const base64 = buffer.toString('base64');
|
|
61
|
-
|
|
62
|
-
return `data:${mimeType};base64,${base64}`;
|
|
63
|
-
} catch (error) {
|
|
64
|
-
this.logger?.error('Error converting image to base64', { filePath, error: error.message });
|
|
65
|
-
throw new Error(`Failed to convert image: ${error.message}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Extract text from PDF
|
|
71
|
-
* @param {string} filePath - Path to PDF file
|
|
72
|
-
* @returns {Promise<Object>} { text: string, numPages: number }
|
|
73
|
-
*/
|
|
74
|
-
async extractPdfText(filePath) {
|
|
75
|
-
if (!this.pdfSupported) {
|
|
76
|
-
throw new Error('PDF text extraction is not supported - pdf-parse library not available');
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
try {
|
|
80
|
-
const dataBuffer = await fs.readFile(filePath);
|
|
81
|
-
const data = await pdfParse(dataBuffer);
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
text: data.text,
|
|
85
|
-
numPages: data.numpages,
|
|
86
|
-
info: data.info || {},
|
|
87
|
-
metadata: data.metadata || {}
|
|
88
|
-
};
|
|
89
|
-
} catch (error) {
|
|
90
|
-
this.logger?.error('Error extracting PDF text', { filePath, error: error.message });
|
|
91
|
-
throw new Error(`Failed to extract PDF text: ${error.message}`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Calculate file hash (SHA-256)
|
|
97
|
-
* @param {string} filePath - Path to file
|
|
98
|
-
* @returns {Promise<string>} Hash as hex string
|
|
99
|
-
*/
|
|
100
|
-
async calculateHash(filePath) {
|
|
101
|
-
try {
|
|
102
|
-
const buffer = await fs.readFile(filePath);
|
|
103
|
-
const hash = crypto.createHash('sha256');
|
|
104
|
-
hash.update(buffer);
|
|
105
|
-
return hash.digest('hex');
|
|
106
|
-
} catch (error) {
|
|
107
|
-
this.logger?.error('Error calculating file hash', { filePath, error: error.message });
|
|
108
|
-
throw new Error(`Failed to calculate hash: ${error.message}`);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Get file stats
|
|
114
|
-
* @param {string} filePath - Path to file
|
|
115
|
-
* @returns {Promise<Object>} File stats
|
|
116
|
-
*/
|
|
117
|
-
async getFileStats(filePath) {
|
|
118
|
-
try {
|
|
119
|
-
const stats = await fs.stat(filePath);
|
|
120
|
-
return {
|
|
121
|
-
size: stats.size,
|
|
122
|
-
created: stats.birthtime,
|
|
123
|
-
modified: stats.mtime,
|
|
124
|
-
isFile: stats.isFile(),
|
|
125
|
-
isDirectory: stats.isDirectory()
|
|
126
|
-
};
|
|
127
|
-
} catch (error) {
|
|
128
|
-
this.logger?.error('Error getting file stats', { filePath, error: error.message });
|
|
129
|
-
throw new Error(`Failed to get file stats: ${error.message}`);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Check if file exists
|
|
135
|
-
* @param {string} filePath - Path to file
|
|
136
|
-
* @returns {Promise<boolean>}
|
|
137
|
-
*/
|
|
138
|
-
async fileExists(filePath) {
|
|
139
|
-
try {
|
|
140
|
-
await fs.access(filePath);
|
|
141
|
-
return true;
|
|
142
|
-
} catch {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Process file based on content type
|
|
149
|
-
* @param {string} filePath - Path to file
|
|
150
|
-
* @param {string} contentType - 'text' | 'image' | 'pdf'
|
|
151
|
-
* @returns {Promise<Object>} { content: string, metadata: Object }
|
|
152
|
-
*/
|
|
153
|
-
async processFile(filePath, contentType) {
|
|
154
|
-
const metadata = {};
|
|
155
|
-
|
|
156
|
-
try {
|
|
157
|
-
switch (contentType) {
|
|
158
|
-
case 'text': {
|
|
159
|
-
const content = await this.readFile(filePath, 'utf8');
|
|
160
|
-
metadata.lines = content.split('\n').length;
|
|
161
|
-
metadata.characters = content.length;
|
|
162
|
-
return { content, metadata };
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
case 'image': {
|
|
166
|
-
const content = await this.imageToBase64(filePath);
|
|
167
|
-
const stats = await this.getFileStats(filePath);
|
|
168
|
-
metadata.size = stats.size;
|
|
169
|
-
return { content, metadata };
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
case 'pdf': {
|
|
173
|
-
const pdfData = await this.extractPdfText(filePath);
|
|
174
|
-
metadata.numPages = pdfData.numPages;
|
|
175
|
-
metadata.info = pdfData.info;
|
|
176
|
-
return { content: pdfData.text, metadata };
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
default:
|
|
180
|
-
throw new Error(`Unsupported content type: ${contentType}`);
|
|
181
|
-
}
|
|
182
|
-
} catch (error) {
|
|
183
|
-
this.logger?.error('Error processing file', { filePath, contentType, error: error.message });
|
|
184
|
-
throw error;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Estimate token count for text
|
|
190
|
-
* @param {string} text - Text content
|
|
191
|
-
* @returns {number} Estimated token count
|
|
192
|
-
*/
|
|
193
|
-
estimateTokens(text) {
|
|
194
|
-
// Rough estimate: 1 token ≈ 4 characters for text
|
|
195
|
-
// For base64 images: 1 token ≈ 1.5 characters (overhead)
|
|
196
|
-
|
|
197
|
-
if (!text) return 0;
|
|
198
|
-
|
|
199
|
-
// Check if it's a base64 data URI
|
|
200
|
-
if (text.startsWith('data:image')) {
|
|
201
|
-
// Extract base64 part and estimate
|
|
202
|
-
const base64Part = text.split(',')[1] || '';
|
|
203
|
-
return Math.ceil(base64Part.length / 1.5);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// Regular text
|
|
207
|
-
return Math.ceil(text.length / 4);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Write content to file
|
|
212
|
-
* @param {string} filePath - Path to file
|
|
213
|
-
* @param {string|Buffer} content - Content to write
|
|
214
|
-
* @param {string} encoding - Encoding (default: 'utf8')
|
|
215
|
-
* @returns {Promise<void>}
|
|
216
|
-
*/
|
|
217
|
-
async writeFile(filePath, content, encoding = 'utf8') {
|
|
218
|
-
try {
|
|
219
|
-
// Ensure directory exists
|
|
220
|
-
const dir = path.dirname(filePath);
|
|
221
|
-
await fs.mkdir(dir, { recursive: true });
|
|
222
|
-
|
|
223
|
-
await fs.writeFile(filePath, content, encoding);
|
|
224
|
-
} catch (error) {
|
|
225
|
-
this.logger?.error('Error writing file', { filePath, error: error.message });
|
|
226
|
-
throw new Error(`Failed to write file: ${error.message}`);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Delete file
|
|
232
|
-
* @param {string} filePath - Path to file
|
|
233
|
-
* @returns {Promise<void>}
|
|
234
|
-
*/
|
|
235
|
-
async deleteFile(filePath) {
|
|
236
|
-
try {
|
|
237
|
-
await fs.unlink(filePath);
|
|
238
|
-
} catch (error) {
|
|
239
|
-
this.logger?.error('Error deleting file', { filePath, error: error.message });
|
|
240
|
-
throw new Error(`Failed to delete file: ${error.message}`);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Copy file
|
|
246
|
-
* @param {string} sourcePath - Source file path
|
|
247
|
-
* @param {string} destPath - Destination file path
|
|
248
|
-
* @returns {Promise<void>}
|
|
249
|
-
*/
|
|
250
|
-
async copyFile(sourcePath, destPath) {
|
|
251
|
-
try {
|
|
252
|
-
// Ensure destination directory exists
|
|
253
|
-
const dir = path.dirname(destPath);
|
|
254
|
-
await fs.mkdir(dir, { recursive: true });
|
|
255
|
-
|
|
256
|
-
await fs.copyFile(sourcePath, destPath);
|
|
257
|
-
} catch (error) {
|
|
258
|
-
this.logger?.error('Error copying file', { sourcePath, destPath, error: error.message });
|
|
259
|
-
throw new Error(`Failed to copy file: ${error.message}`);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Create directory
|
|
265
|
-
* @param {string} dirPath - Directory path
|
|
266
|
-
* @returns {Promise<void>}
|
|
267
|
-
*/
|
|
268
|
-
async createDirectory(dirPath) {
|
|
269
|
-
try {
|
|
270
|
-
await fs.mkdir(dirPath, { recursive: true });
|
|
271
|
-
} catch (error) {
|
|
272
|
-
this.logger?.error('Error creating directory', { dirPath, error: error.message });
|
|
273
|
-
throw new Error(`Failed to create directory: ${error.message}`);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Delete directory recursively
|
|
279
|
-
* @param {string} dirPath - Directory path
|
|
280
|
-
* @returns {Promise<void>}
|
|
281
|
-
*/
|
|
282
|
-
async deleteDirectory(dirPath) {
|
|
283
|
-
try {
|
|
284
|
-
await fs.rm(dirPath, { recursive: true, force: true });
|
|
285
|
-
} catch (error) {
|
|
286
|
-
this.logger?.error('Error deleting directory', { dirPath, error: error.message });
|
|
287
|
-
throw new Error(`Failed to delete directory: ${error.message}`);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* List files in directory
|
|
293
|
-
* @param {string} dirPath - Directory path
|
|
294
|
-
* @returns {Promise<string[]>} Array of file names
|
|
295
|
-
*/
|
|
296
|
-
async listFiles(dirPath) {
|
|
297
|
-
try {
|
|
298
|
-
const files = await fs.readdir(dirPath);
|
|
299
|
-
return files;
|
|
300
|
-
} catch (error) {
|
|
301
|
-
this.logger?.error('Error listing files', { dirPath, error: error.message });
|
|
302
|
-
throw new Error(`Failed to list files: ${error.message}`);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
export default FileProcessor;
|
|
1
|
+
const a0_0x50f11b=a0_0x4547;(function(_0x56d220,_0xf98fd4){const _0x127698=a0_0x4547,_0x37875e=_0x56d220();while(!![]){try{const _0x23cdd0=-parseInt(_0x127698(0xfa))/0x1+parseInt(_0x127698(0xd9))/0x2+-parseInt(_0x127698(0xe8))/0x3+-parseInt(_0x127698(0xf1))/0x4*(parseInt(_0x127698(0xfe))/0x5)+-parseInt(_0x127698(0xe0))/0x6*(-parseInt(_0x127698(0xe7))/0x7)+parseInt(_0x127698(0xff))/0x8*(-parseInt(_0x127698(0xed))/0x9)+-parseInt(_0x127698(0xf4))/0xa*(-parseInt(_0x127698(0x105))/0xb);if(_0x23cdd0===_0xf98fd4)break;else _0x37875e['push'](_0x37875e['shift']());}catch(_0x3edeb0){_0x37875e['push'](_0x37875e['shift']());}}}(a0_0x2c4a,0x400b9));import a0_0x543228 from'fs/promises';import a0_0x4dc29a from'path';function a0_0x2c4a(){const _0x420ca1=['rxjYB3iGy29UDMvYDgLUzYbPBwfNzsb0BYbIyxnLnJq','zgvSzxrLrMLSzq','rxjYB3iGzgvSzxrPBMCGzMLSzq','rxjYB3iGy3jLyxrPBMCGzgLYzwn0B3j5','yMLYDgH0Aw1L','DxbKyxrL','rMfPBgvKihrVignVBNzLCNqGAw1Hz2u6ia','nJa2ntGYAMLhyK5P','C3rHCNrZv2L0Aa','rxjYB3iGy2fSy3vSyxrPBMCGzMLSzsbOyxnO','BwvZC2fNzq','y29WEuzPBgu','C2L6zq','zxjYB3i','nJK5nJmWAur5qLbO','zgLYBMfTzq','DxrMoa','BNvTCgfNzxm','rMfPBgvKihrVigXPC3qGzMLSzxm6ia','Aw1Hz2uVz2LM','zgf0ytO','n1viBen0sa','oti5ntm4q2vTzK5o','Aw1Hz2uVyM1W','Agv4','Aw1Hz2uVANbLzW','o2jHC2u2ncW','ntu4mePesej0Ca','rxjYB3iGChjVy2vZC2LUzYbMAwXL','Bg9Nz2vY','Aw1Hz2vuB0jHC2u2na','nJG3ndq4vKHUEfDV','CMvHzezPBgu','zxH0CMfJDfbKzLrLEhq','mJGXmtqWy2Tjshne','y2HHCMfJDgvYCW','y2fSy3vSyxrLsgfZAa','C2HHmJu2','ChjVy2vZC0zPBgu','Dw5SAw5R','mJyZodK3EK5PDwLi','zxn0Aw1HDgvuB2TLBNm','rMfPBgvKihrVihjLywqGzMLSztOG','zgLNzxn0','mtvAz1LTtuu','mZu3nKXfyvDhqq','CgrMu3vWCg9YDgvK','Dgv4Da','Aw1Hz2uVC3zNk3HTBa','rxjYB3iGy29WEwLUzYbMAwXL','rMfPBgvKihrVihDYAxrLigzPBgu6ia','ndCZB1LkAujt','zxH0BMfTzq','z2v0rMLSzvn0yxrZ','zMLSzuv4Axn0CW','CgrM'];a0_0x2c4a=function(){return _0x420ca1;};return a0_0x2c4a();}import a0_0xe2514 from'crypto';class FileProcessor{constructor(_0x333a37={},_0xa87df1=null){const _0x46f25e=a0_0x4547;this['config']=_0x333a37,this['logger']=_0xa87df1,this[_0x46f25e(0x100)]=![];}async[a0_0x50f11b(0xf2)](_0x3d289a,_0x1ef97b=a0_0x50f11b(0xe2)){const _0x111078=a0_0x50f11b;try{const _0x5eaf14=await a0_0x543228['readFile'](_0x3d289a,_0x1ef97b);return _0x5eaf14;}catch(_0x1ec215){this['logger']?.['error']('Error\x20reading\x20file',{'filePath':_0x3d289a,'error':_0x1ec215['message']});throw new Error(_0x111078(0xfc)+_0x1ec215[_0x111078(0xdc)]);}}async['imageToBase64'](_0x191906){const _0x2e9d61=a0_0x50f11b;try{const _0x120094=await a0_0x543228[_0x2e9d61(0xf2)](_0x191906),_0x5d12e9=a0_0x4dc29a[_0x2e9d61(0x106)](_0x191906)['toLowerCase'](),_0x67f9c0={'.jpg':_0x2e9d61(0xeb),'.jpeg':_0x2e9d61(0xeb),'.png':'image/png','.gif':_0x2e9d61(0xe5),'.webp':'image/webp','.bmp':_0x2e9d61(0xe9),'.svg':_0x2e9d61(0x102)},_0x5a402a=_0x67f9c0[_0x5d12e9]||_0x2e9d61(0xeb),_0x5d7d76=_0x120094['toString']('base64');return _0x2e9d61(0xe6)+_0x5a402a+_0x2e9d61(0xec)+_0x5d7d76;}catch(_0x947654){this['logger']?.['error'](_0x2e9d61(0x10a),{'filePath':_0x191906,'error':_0x947654['message']});throw new Error(_0x2e9d61(0xd8)+_0x947654['message']);}}async[a0_0x50f11b(0xf3)](_0x29509e){const _0x2488cf=a0_0x50f11b;if(!this['pdfSupported'])throw new Error('PDF\x20text\x20extraction\x20is\x20not\x20supported\x20-\x20pdf-parse\x20library\x20not\x20available');try{const dataBuffer=await a0_0x543228['readFile'](_0x29509e),_0x16dd5a=await pdfParse(dataBuffer);return{'text':_0x16dd5a['text'],'numPages':_0x16dd5a[_0x2488cf(0xe3)],'info':_0x16dd5a['info']||{},'metadata':_0x16dd5a['metadata']||{}};}catch(_0x40ef13){this['logger']?.['error']('Error\x20extracting\x20PDF\x20text',{'filePath':_0x29509e,'error':_0x40ef13[_0x2488cf(0xdc)]});throw new Error('Failed\x20to\x20extract\x20PDF\x20text:\x20'+_0x40ef13[_0x2488cf(0xdc)]);}}async[a0_0x50f11b(0xf6)](_0x3cda34){const _0x54b02e=a0_0x50f11b;try{const _0xac2f54=await a0_0x543228[_0x54b02e(0xf2)](_0x3cda34),_0x1ad892=a0_0xe2514['createHash'](_0x54b02e(0xf7));return _0x1ad892[_0x54b02e(0x10f)](_0xac2f54),_0x1ad892[_0x54b02e(0xfd)](_0x54b02e(0xea));}catch(_0x564d3f){this['logger']?.['error'](_0x54b02e(0xdb),{'filePath':_0x3cda34,'error':_0x564d3f[_0x54b02e(0xdc)]});throw new Error('Failed\x20to\x20calculate\x20hash:\x20'+_0x564d3f[_0x54b02e(0xdc)]);}}async[a0_0x50f11b(0x107)](_0x3b794c){const _0x243e3d=a0_0x50f11b;try{const _0x2d9277=await a0_0x543228['stat'](_0x3b794c);return{'size':_0x2d9277[_0x243e3d(0xde)],'created':_0x2d9277[_0x243e3d(0x10e)],'modified':_0x2d9277['mtime'],'isFile':_0x2d9277['isFile'](),'isDirectory':_0x2d9277['isDirectory']()};}catch(_0x2cb85c){this['logger']?.[_0x243e3d(0xdf)]('Error\x20getting\x20file\x20stats',{'filePath':_0x3b794c,'error':_0x2cb85c['message']});throw new Error('Failed\x20to\x20get\x20file\x20stats:\x20'+_0x2cb85c['message']);}}async[a0_0x50f11b(0x108)](_0x518413){try{return await a0_0x543228['access'](_0x518413),!![];}catch{return![];}}async[a0_0x50f11b(0xf8)](_0x3fb35f,_0x5e542c){const _0x31b7ac=a0_0x50f11b,_0x560e11={};try{switch(_0x5e542c){case _0x31b7ac(0x101):{const _0x207a3b=await this['readFile'](_0x3fb35f,'utf8');return _0x560e11['lines']=_0x207a3b['split']('\x0a')['length'],_0x560e11[_0x31b7ac(0xf5)]=_0x207a3b['length'],{'content':_0x207a3b,'metadata':_0x560e11};}case'image':{const _0x418117=await this[_0x31b7ac(0xf0)](_0x3fb35f),_0x4902ba=await this['getFileStats'](_0x3fb35f);return _0x560e11['size']=_0x4902ba[_0x31b7ac(0xde)],{'content':_0x418117,'metadata':_0x560e11};}case _0x31b7ac(0x109):{const _0x59a81f=await this['extractPdfText'](_0x3fb35f);return _0x560e11['numPages']=_0x59a81f['numPages'],_0x560e11['info']=_0x59a81f['info'],{'content':_0x59a81f[_0x31b7ac(0x101)],'metadata':_0x560e11};}default:throw new Error('Unsupported\x20content\x20type:\x20'+_0x5e542c);}}catch(_0x4fbb91){this[_0x31b7ac(0xef)]?.[_0x31b7ac(0xdf)](_0x31b7ac(0xee),{'filePath':_0x3fb35f,'contentType':_0x5e542c,'error':_0x4fbb91[_0x31b7ac(0xdc)]});throw _0x4fbb91;}}[a0_0x50f11b(0xfb)](_0x30290e){const _0x5b1646=a0_0x50f11b;if(!_0x30290e)return 0x0;if(_0x30290e[_0x5b1646(0xda)]('data:image')){const _0x4d6068=_0x30290e['split'](',')[0x1]||'';return Math['ceil'](_0x4d6068['length']/1.5);}return Math['ceil'](_0x30290e['length']/0x4);}async['writeFile'](_0x567839,_0x188411,_0x37766f='utf8'){const _0x5bda2f=a0_0x50f11b;try{const _0x202aa4=a0_0x4dc29a[_0x5bda2f(0xe1)](_0x567839);await a0_0x543228['mkdir'](_0x202aa4,{'recursive':!![]}),await a0_0x543228['writeFile'](_0x567839,_0x188411,_0x37766f);}catch(_0x4ed0b1){this[_0x5bda2f(0xef)]?.['error']('Error\x20writing\x20file',{'filePath':_0x567839,'error':_0x4ed0b1[_0x5bda2f(0xdc)]});throw new Error(_0x5bda2f(0x104)+_0x4ed0b1['message']);}}async[a0_0x50f11b(0x10b)](_0x4d1a0f){const _0xc26677=a0_0x50f11b;try{await a0_0x543228[_0xc26677(0xf9)](_0x4d1a0f);}catch(_0x553e53){this[_0xc26677(0xef)]?.[_0xc26677(0xdf)](_0xc26677(0x10c),{'filePath':_0x4d1a0f,'error':_0x553e53[_0xc26677(0xdc)]});throw new Error('Failed\x20to\x20delete\x20file:\x20'+_0x553e53['message']);}}async[a0_0x50f11b(0xdd)](_0x37423a,_0x5b0824){const _0x5308a5=a0_0x50f11b;try{const _0x6a0584=a0_0x4dc29a['dirname'](_0x5b0824);await a0_0x543228['mkdir'](_0x6a0584,{'recursive':!![]}),await a0_0x543228['copyFile'](_0x37423a,_0x5b0824);}catch(_0x134768){this['logger']?.['error'](_0x5308a5(0x103),{'sourcePath':_0x37423a,'destPath':_0x5b0824,'error':_0x134768[_0x5308a5(0xdc)]});throw new Error('Failed\x20to\x20copy\x20file:\x20'+_0x134768['message']);}}async['createDirectory'](_0x351711){const _0x5f52ff=a0_0x50f11b;try{await a0_0x543228['mkdir'](_0x351711,{'recursive':!![]});}catch(_0x264271){this[_0x5f52ff(0xef)]?.[_0x5f52ff(0xdf)](_0x5f52ff(0x10d),{'dirPath':_0x351711,'error':_0x264271['message']});throw new Error('Failed\x20to\x20create\x20directory:\x20'+_0x264271['message']);}}async['deleteDirectory'](_0x3f56e2){const _0x2956eb=a0_0x50f11b;try{await a0_0x543228['rm'](_0x3f56e2,{'recursive':!![],'force':!![]});}catch(_0x584b62){this['logger']?.['error']('Error\x20deleting\x20directory',{'dirPath':_0x3f56e2,'error':_0x584b62['message']});throw new Error('Failed\x20to\x20delete\x20directory:\x20'+_0x584b62[_0x2956eb(0xdc)]);}}async['listFiles'](_0x2cccb9){const _0x51dbda=a0_0x50f11b;try{const _0x4fb87b=await a0_0x543228['readdir'](_0x2cccb9);return _0x4fb87b;}catch(_0x5e2a72){this[_0x51dbda(0xef)]?.[_0x51dbda(0xdf)]('Error\x20listing\x20files',{'dirPath':_0x2cccb9,'error':_0x5e2a72[_0x51dbda(0xdc)]});throw new Error(_0x51dbda(0xe4)+_0x5e2a72['message']);}}}function a0_0x4547(_0x3c0f24,_0x474756){_0x3c0f24=_0x3c0f24-0xd8;const _0x2c4a30=a0_0x2c4a();let _0x45471e=_0x2c4a30[_0x3c0f24];if(a0_0x4547['HsyYjF']===undefined){var _0x28bab5=function(_0x144e66){const _0x5ee951='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x543228='',_0x4dc29a='';for(let _0xe2514=0x0,_0x333a37,_0xa87df1,_0x3d289a=0x0;_0xa87df1=_0x144e66['charAt'](_0x3d289a++);~_0xa87df1&&(_0x333a37=_0xe2514%0x4?_0x333a37*0x40+_0xa87df1:_0xa87df1,_0xe2514++%0x4)?_0x543228+=String['fromCharCode'](0xff&_0x333a37>>(-0x2*_0xe2514&0x6)):0x0){_0xa87df1=_0x5ee951['indexOf'](_0xa87df1);}for(let _0x1ef97b=0x0,_0x5eaf14=_0x543228['length'];_0x1ef97b<_0x5eaf14;_0x1ef97b++){_0x4dc29a+='%'+('00'+_0x543228['charCodeAt'](_0x1ef97b)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4dc29a);};a0_0x4547['aSudcq']=_0x28bab5,a0_0x4547['yaORis']={},a0_0x4547['HsyYjF']=!![];}const _0x4d97bd=_0x2c4a30[0x0],_0x3150aa=_0x3c0f24+_0x4d97bd,_0xa33410=a0_0x4547['yaORis'][_0x3150aa];return!_0xa33410?(_0x45471e=a0_0x4547['aSudcq'](_0x45471e),a0_0x4547['yaORis'][_0x3150aa]=_0x45471e):_0x45471e=_0xa33410,_0x45471e;}export default FileProcessor;
|