@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
package/src/index.js
CHANGED
|
@@ -1,631 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Loxia Autopilot One - Main Application Entry Point
|
|
3
|
-
*
|
|
4
|
-
* Purpose:
|
|
5
|
-
* - Initialize all system components
|
|
6
|
-
* - Setup dependency injection
|
|
7
|
-
* - Start interface handlers
|
|
8
|
-
* - Handle graceful shutdown
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import path from 'path';
|
|
12
|
-
import { fileURLToPath } from 'url';
|
|
13
|
-
import { createLogger } from './utilities/logger.js';
|
|
14
|
-
import { createConfigManager } from './utilities/configManager.js';
|
|
15
|
-
import Orchestrator from './core/orchestrator.js';
|
|
16
|
-
import AgentPool from './core/agentPool.js';
|
|
17
|
-
import MessageProcessor from './core/messageProcessor.js';
|
|
18
|
-
import AgentScheduler from './core/agentScheduler.js';
|
|
19
|
-
import ContextManager from './core/contextManager.js';
|
|
20
|
-
import StateManager from './core/stateManager.js';
|
|
21
|
-
import AIService from './services/aiService.js';
|
|
22
|
-
import BudgetService from './services/budgetService.js';
|
|
23
|
-
import ErrorHandler from './services/errorHandler.js';
|
|
24
|
-
import BenchmarkService from './services/benchmarkService.js';
|
|
25
|
-
import ModelRouterService from './services/modelRouterService.js';
|
|
26
|
-
import ModelsService from './services/modelsService.js';
|
|
27
|
-
import ApiKeyManager from './services/apiKeyManager.js';
|
|
28
|
-
import FileAttachmentService from './services/fileAttachmentService.js';
|
|
29
|
-
import { ToolsRegistry } from './tools/baseTool.js';
|
|
30
|
-
import AgentDelayTool from './tools/agentDelayTool.js';
|
|
31
|
-
import TerminalTool from './tools/terminalTool.js';
|
|
32
|
-
import FileSystemTool from './tools/fileSystemTool.js';
|
|
33
|
-
import BrowserTool from './tools/browserTool.js';
|
|
34
|
-
import JobDoneTool from './tools/jobDoneTool.js';
|
|
35
|
-
import AgentCommunicationTool from './tools/agentCommunicationTool.js';
|
|
36
|
-
import TaskManagerTool from './tools/taskManagerTool.js';
|
|
37
|
-
import ImportAnalyzerTool from './tools/importAnalyzerTool.js';
|
|
38
|
-
import DependencyResolverTool from './tools/dependencyResolverTool.js';
|
|
39
|
-
import ImageTool from './tools/imageTool.js';
|
|
40
|
-
import StaticAnalysisTool from './tools/staticAnalysisTool.js';
|
|
41
|
-
import CloneDetectionTool from './tools/cloneDetectionTool.js';
|
|
42
|
-
import FileTreeTool from './tools/fileTreeTool.js';
|
|
43
|
-
import FileContentReplaceTool from './tools/fileContentReplaceTool.js';
|
|
44
|
-
import SeekTool from './tools/seekTool.js';
|
|
45
|
-
import WebTool from './tools/webTool.js';
|
|
46
|
-
import AsyncToolManager from './tools/asyncToolManager.js';
|
|
47
|
-
import WebServer from './interfaces/webServer.js';
|
|
48
|
-
|
|
49
|
-
import {
|
|
50
|
-
SYSTEM_VERSION,
|
|
51
|
-
INTERFACE_TYPES
|
|
52
|
-
} from './utilities/constants.js';
|
|
53
|
-
|
|
54
|
-
class LoxiaApplication {
|
|
55
|
-
constructor() {
|
|
56
|
-
this.logger = null;
|
|
57
|
-
this.config = null;
|
|
58
|
-
this.orchestrator = null;
|
|
59
|
-
this.interfaces = new Map();
|
|
60
|
-
this.isShuttingDown = false;
|
|
61
|
-
|
|
62
|
-
// Bind shutdown handler
|
|
63
|
-
this.shutdown = this.shutdown.bind(this);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Initialize the application
|
|
68
|
-
* @param {Object} options - Initialization options
|
|
69
|
-
* @returns {Promise<void>}
|
|
70
|
-
*/
|
|
71
|
-
async initialize(options = {}) {
|
|
72
|
-
try {
|
|
73
|
-
console.log(`🚀 Starting Loxia Autopilot One v${SYSTEM_VERSION}`);
|
|
74
|
-
|
|
75
|
-
// Initialize configuration
|
|
76
|
-
await this.initializeConfig(options);
|
|
77
|
-
|
|
78
|
-
// Initialize logging
|
|
79
|
-
await this.initializeLogging();
|
|
80
|
-
|
|
81
|
-
this.logger.info('Loxia Autopilot One starting up', {
|
|
82
|
-
version: SYSTEM_VERSION,
|
|
83
|
-
nodeVersion: process.version,
|
|
84
|
-
platform: process.platform,
|
|
85
|
-
projectDir: options.projectDir || process.cwd()
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// Initialize core components
|
|
89
|
-
await this.initializeCoreComponents();
|
|
90
|
-
|
|
91
|
-
// Initialize tools
|
|
92
|
-
await this.initializeTools();
|
|
93
|
-
|
|
94
|
-
this.logger.info('Starting interface initialization...');
|
|
95
|
-
|
|
96
|
-
// Initialize interfaces
|
|
97
|
-
await this.initializeInterfaces(options);
|
|
98
|
-
|
|
99
|
-
this.logger.info('Interface initialization completed');
|
|
100
|
-
|
|
101
|
-
// Setup shutdown handlers
|
|
102
|
-
this.setupShutdownHandlers();
|
|
103
|
-
|
|
104
|
-
this.logger.info('Loxia Autopilot One startup complete');
|
|
105
|
-
console.log('✅ Loxia Autopilot One is ready!');
|
|
106
|
-
|
|
107
|
-
} catch (error) {
|
|
108
|
-
console.error('❌ Failed to initialize Loxia Autopilot One:', error.message);
|
|
109
|
-
if (this.logger) {
|
|
110
|
-
this.logger.error('Application initialization failed', {
|
|
111
|
-
error: error.message,
|
|
112
|
-
stack: error.stack
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
process.exit(1);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Initialize configuration management
|
|
121
|
-
* @private
|
|
122
|
-
*/
|
|
123
|
-
async initializeConfig(options) {
|
|
124
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
125
|
-
const __dirname = path.dirname(__filename);
|
|
126
|
-
|
|
127
|
-
const configPaths = [
|
|
128
|
-
path.join(__dirname, '../config/default.json'),
|
|
129
|
-
...(options.configPaths || [])
|
|
130
|
-
];
|
|
131
|
-
|
|
132
|
-
this.configManager = createConfigManager({
|
|
133
|
-
configPaths,
|
|
134
|
-
envPrefix: 'LOXIA'
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
this.config = await this.configManager.loadConfig();
|
|
138
|
-
|
|
139
|
-
// Enable config watching if requested
|
|
140
|
-
if (options.watchConfig) {
|
|
141
|
-
await this.configManager.watchConfig(true);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Initialize logging system
|
|
147
|
-
* @private
|
|
148
|
-
*/
|
|
149
|
-
async initializeLogging() {
|
|
150
|
-
const loggingConfig = this.config.logging || {};
|
|
151
|
-
|
|
152
|
-
this.logger = createLogger({
|
|
153
|
-
level: loggingConfig.level || 'info',
|
|
154
|
-
outputs: loggingConfig.outputs || ['console'],
|
|
155
|
-
colors: loggingConfig.colors !== false,
|
|
156
|
-
timestamp: loggingConfig.timestamp !== false,
|
|
157
|
-
logFile: loggingConfig.logFile,
|
|
158
|
-
maxFileSize: loggingConfig.maxFileSize,
|
|
159
|
-
maxFiles: loggingConfig.maxFiles
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
await this.logger.initialize();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Initialize core system components
|
|
167
|
-
* @private
|
|
168
|
-
*/
|
|
169
|
-
async initializeCoreComponents() {
|
|
170
|
-
this.logger.info('Initializing core components...');
|
|
171
|
-
|
|
172
|
-
// State Manager
|
|
173
|
-
this.stateManager = new StateManager(this.config, this.logger);
|
|
174
|
-
|
|
175
|
-
// File Attachment Service
|
|
176
|
-
this.fileAttachmentService = new FileAttachmentService(this.config, this.logger);
|
|
177
|
-
await this.fileAttachmentService.initialize();
|
|
178
|
-
|
|
179
|
-
// Context Manager
|
|
180
|
-
this.contextManager = new ContextManager(this.config, this.logger);
|
|
181
|
-
|
|
182
|
-
// Tools Registry and Async Tool Manager
|
|
183
|
-
this.toolsRegistry = new ToolsRegistry(this.logger);
|
|
184
|
-
this.asyncToolManager = new AsyncToolManager(this.config, this.logger);
|
|
185
|
-
|
|
186
|
-
// Agent Pool (with tools registry for prompt enhancement)
|
|
187
|
-
this.agentPool = new AgentPool(
|
|
188
|
-
this.config,
|
|
189
|
-
this.logger,
|
|
190
|
-
this.stateManager,
|
|
191
|
-
this.contextManager,
|
|
192
|
-
this.toolsRegistry
|
|
193
|
-
);
|
|
194
|
-
|
|
195
|
-
// Initialize Budget Service and Error Handler
|
|
196
|
-
this.budgetService = new BudgetService(this.config, this.logger);
|
|
197
|
-
this.errorHandler = new ErrorHandler(this.config, this.logger);
|
|
198
|
-
|
|
199
|
-
// API Key Manager
|
|
200
|
-
this.apiKeyManager = new ApiKeyManager(this.logger);
|
|
201
|
-
|
|
202
|
-
// AI Service
|
|
203
|
-
this.aiService = new AIService(
|
|
204
|
-
this.config,
|
|
205
|
-
this.logger,
|
|
206
|
-
this.budgetService,
|
|
207
|
-
this.errorHandler
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
// Set API Key Manager reference in AI Service
|
|
211
|
-
this.aiService.setApiKeyManager(this.apiKeyManager);
|
|
212
|
-
|
|
213
|
-
// Set Agent Pool reference in AI Service
|
|
214
|
-
this.aiService.setAgentPool(this.agentPool);
|
|
215
|
-
|
|
216
|
-
// Initialize Model Routing Services
|
|
217
|
-
this.benchmarkService = new BenchmarkService(this.config, this.logger);
|
|
218
|
-
this.modelsService = new ModelsService(this.config, this.logger);
|
|
219
|
-
this.modelRouterService = new ModelRouterService(
|
|
220
|
-
this.config,
|
|
221
|
-
this.logger,
|
|
222
|
-
this.benchmarkService,
|
|
223
|
-
this.aiService
|
|
224
|
-
);
|
|
225
|
-
|
|
226
|
-
// Set API Key Manager reference in ModelsService
|
|
227
|
-
this.modelsService.setApiKeyManager(this.apiKeyManager);
|
|
228
|
-
|
|
229
|
-
// Initialize services
|
|
230
|
-
await this.benchmarkService.initialize();
|
|
231
|
-
await this.modelsService.initialize();
|
|
232
|
-
|
|
233
|
-
// Message Processor
|
|
234
|
-
this.messageProcessor = new MessageProcessor(
|
|
235
|
-
this.config,
|
|
236
|
-
this.logger,
|
|
237
|
-
this.toolsRegistry,
|
|
238
|
-
this.agentPool,
|
|
239
|
-
this.contextManager,
|
|
240
|
-
this.aiService,
|
|
241
|
-
this.modelRouterService,
|
|
242
|
-
this.modelsService
|
|
243
|
-
);
|
|
244
|
-
|
|
245
|
-
// Agent Scheduler - NEW ARCHITECTURE
|
|
246
|
-
this.agentScheduler = new AgentScheduler(
|
|
247
|
-
this.agentPool,
|
|
248
|
-
this.messageProcessor,
|
|
249
|
-
this.aiService,
|
|
250
|
-
this.logger,
|
|
251
|
-
null, // webSocketManager will be set later
|
|
252
|
-
this.modelRouterService,
|
|
253
|
-
this.modelsService
|
|
254
|
-
);
|
|
255
|
-
|
|
256
|
-
// Note: Scheduler will be started after WebSocketManager is initialized
|
|
257
|
-
|
|
258
|
-
// Orchestrator
|
|
259
|
-
this.orchestrator = new Orchestrator(
|
|
260
|
-
this.config,
|
|
261
|
-
this.logger,
|
|
262
|
-
this.agentPool,
|
|
263
|
-
this.messageProcessor,
|
|
264
|
-
this.aiService,
|
|
265
|
-
this.stateManager
|
|
266
|
-
);
|
|
267
|
-
|
|
268
|
-
// Set cross-references between components
|
|
269
|
-
this.messageProcessor.orchestrator = this.orchestrator;
|
|
270
|
-
this.messageProcessor.setScheduler(this.agentScheduler);
|
|
271
|
-
this.agentPool.setMessageProcessor(this.messageProcessor);
|
|
272
|
-
this.agentPool.setScheduler(this.agentScheduler);
|
|
273
|
-
this.agentPool.setFileAttachmentService(this.fileAttachmentService);
|
|
274
|
-
|
|
275
|
-
// Attach FileAttachmentService to orchestrator for webServer access
|
|
276
|
-
this.orchestrator.fileAttachmentService = this.fileAttachmentService;
|
|
277
|
-
|
|
278
|
-
this.logger.info('Core components initialized');
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Initialize tools system
|
|
283
|
-
* @private
|
|
284
|
-
*/
|
|
285
|
-
async initializeTools() {
|
|
286
|
-
this.logger.info('Initializing tools...');
|
|
287
|
-
|
|
288
|
-
// Register Agent Delay Tool
|
|
289
|
-
await this.toolsRegistry.registerTool(AgentDelayTool);
|
|
290
|
-
|
|
291
|
-
// Register Terminal Tool
|
|
292
|
-
await this.toolsRegistry.registerTool(TerminalTool);
|
|
293
|
-
|
|
294
|
-
// Register File System Tool
|
|
295
|
-
await this.toolsRegistry.registerTool(FileSystemTool);
|
|
296
|
-
|
|
297
|
-
// Register Job Done Tool
|
|
298
|
-
await this.toolsRegistry.registerTool(JobDoneTool);
|
|
299
|
-
|
|
300
|
-
// Register Agent Communication Tool
|
|
301
|
-
await this.toolsRegistry.registerTool(AgentCommunicationTool);
|
|
302
|
-
|
|
303
|
-
// Register Task Manager Tool
|
|
304
|
-
await this.toolsRegistry.registerTool(TaskManagerTool);
|
|
305
|
-
|
|
306
|
-
// Register Import Analyzer Tool
|
|
307
|
-
await this.toolsRegistry.registerTool(ImportAnalyzerTool);
|
|
308
|
-
|
|
309
|
-
// Register Dependency Resolver Tool
|
|
310
|
-
await this.toolsRegistry.registerTool(DependencyResolverTool);
|
|
311
|
-
|
|
312
|
-
// Register Image Generation Tool
|
|
313
|
-
await this.toolsRegistry.registerTool(ImageTool);
|
|
314
|
-
|
|
315
|
-
// Register Static Analysis Tool
|
|
316
|
-
await this.toolsRegistry.registerTool(StaticAnalysisTool);
|
|
317
|
-
|
|
318
|
-
// Register Clone Detection Tool
|
|
319
|
-
await this.toolsRegistry.registerTool(CloneDetectionTool);
|
|
320
|
-
|
|
321
|
-
// Register File Tree Tool
|
|
322
|
-
await this.toolsRegistry.registerTool(FileTreeTool);
|
|
323
|
-
|
|
324
|
-
// Register File Content Replace Tool
|
|
325
|
-
await this.toolsRegistry.registerTool(FileContentReplaceTool);
|
|
326
|
-
|
|
327
|
-
// Register Seek Tool
|
|
328
|
-
await this.toolsRegistry.registerTool(SeekTool);
|
|
329
|
-
|
|
330
|
-
// Register Web Tool
|
|
331
|
-
await this.toolsRegistry.registerTool(WebTool);
|
|
332
|
-
|
|
333
|
-
// Register Browser Tool (if enabled)
|
|
334
|
-
if (this.config.tools?.browser?.enabled !== false) {
|
|
335
|
-
try {
|
|
336
|
-
await this.toolsRegistry.registerTool(BrowserTool);
|
|
337
|
-
this.logger.info('Browser tool registered (requires puppeteer)');
|
|
338
|
-
} catch (error) {
|
|
339
|
-
this.logger.warn('Browser tool registration skipped', {
|
|
340
|
-
reason: error.message,
|
|
341
|
-
suggestion: 'Install puppeteer to enable browser automation'
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// Set AgentPool dependency for AgentDelayTool
|
|
347
|
-
const agentDelayTool = this.toolsRegistry.getTool('agentdelay');
|
|
348
|
-
if (agentDelayTool && typeof agentDelayTool.setAgentPool === 'function') {
|
|
349
|
-
agentDelayTool.setAgentPool(this.agentPool);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// Set AgentPool dependency for JobDoneTool
|
|
353
|
-
const jobDoneTool = this.toolsRegistry.getTool('jobdone');
|
|
354
|
-
if (jobDoneTool && typeof jobDoneTool.setAgentPool === 'function') {
|
|
355
|
-
jobDoneTool.setAgentPool(this.agentPool);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
// Set AgentPool and Scheduler dependencies for TaskManagerTool
|
|
359
|
-
const taskManagerTool = this.toolsRegistry.getTool('taskmanager');
|
|
360
|
-
if (taskManagerTool && typeof taskManagerTool.setAgentPool === 'function') {
|
|
361
|
-
taskManagerTool.setAgentPool(this.agentPool);
|
|
362
|
-
}
|
|
363
|
-
if (taskManagerTool && typeof taskManagerTool.setScheduler === 'function') {
|
|
364
|
-
taskManagerTool.setScheduler(this.scheduler);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
// Note: AgentCommunicationTool receives agentPool through execution context
|
|
368
|
-
// No need to set it directly as it's passed in the context parameter
|
|
369
|
-
const agentCommTool = this.toolsRegistry.getTool('agentcommunication');
|
|
370
|
-
if (agentCommTool) {
|
|
371
|
-
this.logger.info('Agent Communication Tool registered successfully');
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
// Set AIService dependency for ImageTool
|
|
375
|
-
const imageTool = this.toolsRegistry.getTool('image-gen');
|
|
376
|
-
if (imageTool && typeof imageTool.setAIService === 'function') {
|
|
377
|
-
imageTool.setAIService(this.aiService);
|
|
378
|
-
this.logger.info('AIService set for Image Generation Tool');
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// Set AgentPool dependency for ImageTool (for conversation history persistence)
|
|
382
|
-
if (imageTool && typeof imageTool.setAgentPool === 'function') {
|
|
383
|
-
imageTool.setAgentPool(this.agentPool);
|
|
384
|
-
this.logger.info('AgentPool set for Image Generation Tool');
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
const toolCapabilities = this.toolsRegistry.getToolCapabilities();
|
|
388
|
-
this.logger.info('Tools initialized', {
|
|
389
|
-
toolCount: Object.keys(toolCapabilities).length,
|
|
390
|
-
enabledTools: Object.keys(toolCapabilities).filter(id => toolCapabilities[id].capabilities.enabled),
|
|
391
|
-
registeredTools: this.toolsRegistry.listTools()
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
// Log tool descriptions for debugging
|
|
395
|
-
if (this.logger.level === 'debug') {
|
|
396
|
-
for (const [toolId, tool] of toolCapabilities.entries()) {
|
|
397
|
-
this.logger.debug(`Tool ${toolId} capabilities`, tool.capabilities);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Initialize interface handlers
|
|
404
|
-
* @private
|
|
405
|
-
*/
|
|
406
|
-
async initializeInterfaces(options) {
|
|
407
|
-
this.logger.info('Initializing interfaces...');
|
|
408
|
-
|
|
409
|
-
const interfaceConfig = this.config.interfaces || {};
|
|
410
|
-
|
|
411
|
-
// CLI Interface (basic implementation)
|
|
412
|
-
if (interfaceConfig.cli?.enabled !== false) {
|
|
413
|
-
const { default: CLIInterface } = await import('./interfaces/cli.js');
|
|
414
|
-
const cliInterface = new CLIInterface(
|
|
415
|
-
this.orchestrator,
|
|
416
|
-
this.logger,
|
|
417
|
-
interfaceConfig.cli || {}
|
|
418
|
-
);
|
|
419
|
-
|
|
420
|
-
await cliInterface.initialize();
|
|
421
|
-
this.interfaces.set(INTERFACE_TYPES.CLI, cliInterface);
|
|
422
|
-
|
|
423
|
-
this.logger.info('CLI interface initialized');
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
// Web Interface - now implemented
|
|
427
|
-
if (interfaceConfig.web?.enabled !== false) {
|
|
428
|
-
const webServer = new WebServer(
|
|
429
|
-
this.orchestrator,
|
|
430
|
-
this.logger,
|
|
431
|
-
interfaceConfig.web || { port: 8080, host: 'localhost' }
|
|
432
|
-
);
|
|
433
|
-
|
|
434
|
-
// Pass toolsRegistry to webServer for the /api/tools endpoint
|
|
435
|
-
webServer.toolsRegistry = this.toolsRegistry;
|
|
436
|
-
|
|
437
|
-
// Set API Key Manager reference in Web Server
|
|
438
|
-
webServer.setApiKeyManager(this.apiKeyManager);
|
|
439
|
-
|
|
440
|
-
await webServer.initialize();
|
|
441
|
-
this.interfaces.set(INTERFACE_TYPES.WEB, webServer);
|
|
442
|
-
|
|
443
|
-
// Attach WebServer to orchestrator for MessageProcessor broadcasting
|
|
444
|
-
this.orchestrator.webServer = webServer;
|
|
445
|
-
|
|
446
|
-
// Connect MessageProcessor to WebServer for real-time updates
|
|
447
|
-
this.messageProcessor.setWebSocketManager(webServer);
|
|
448
|
-
|
|
449
|
-
// Connect AgentScheduler to WebServer for real-time updates
|
|
450
|
-
this.agentScheduler.webSocketManager = webServer;
|
|
451
|
-
|
|
452
|
-
// Start the scheduler now that WebSocketManager is available
|
|
453
|
-
this.agentScheduler.start();
|
|
454
|
-
this.logger.info('Agent Scheduler started with WebSocket integration');
|
|
455
|
-
|
|
456
|
-
// Set global reference for tools that need to broadcast
|
|
457
|
-
global.loxiaWebServer = webServer;
|
|
458
|
-
|
|
459
|
-
const status = webServer.getStatus();
|
|
460
|
-
this.logger.info('Web interface initialized', { url: status.url });
|
|
461
|
-
console.log(`🌐 Web Server running at ${status.url}`);
|
|
462
|
-
console.log(`📱 Web UI available at: http://localhost:3001 (if running)`);
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
// VSCode Extension Interface (placeholder)
|
|
466
|
-
if (interfaceConfig.vscode?.enabled === true) {
|
|
467
|
-
this.logger.info('VSCode interface configured but not implemented yet');
|
|
468
|
-
// TODO: Initialize VSCode extension interface
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
/**
|
|
473
|
-
* Setup graceful shutdown handlers
|
|
474
|
-
* @private
|
|
475
|
-
*/
|
|
476
|
-
setupShutdownHandlers() {
|
|
477
|
-
// Handle SIGINT (Ctrl+C)
|
|
478
|
-
process.on('SIGINT', async () => {
|
|
479
|
-
console.log('\n📋 Received SIGINT, shutting down gracefully...');
|
|
480
|
-
await this.shutdown();
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
// Handle SIGTERM
|
|
484
|
-
process.on('SIGTERM', async () => {
|
|
485
|
-
console.log('\n📋 Received SIGTERM, shutting down gracefully...');
|
|
486
|
-
await this.shutdown();
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
// Handle uncaught exceptions
|
|
490
|
-
process.on('uncaughtException', async (error) => {
|
|
491
|
-
console.error('❌ Uncaught exception:', error);
|
|
492
|
-
if (this.logger) {
|
|
493
|
-
this.logger.error('Uncaught exception', {
|
|
494
|
-
error: error.message,
|
|
495
|
-
stack: error.stack
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
await this.shutdown();
|
|
500
|
-
process.exit(1);
|
|
501
|
-
});
|
|
502
|
-
|
|
503
|
-
// Handle unhandled promise rejections
|
|
504
|
-
process.on('unhandledRejection', async (reason, promise) => {
|
|
505
|
-
console.error('❌ Unhandled promise rejection:', reason);
|
|
506
|
-
if (this.logger) {
|
|
507
|
-
this.logger.error('Unhandled promise rejection', {
|
|
508
|
-
reason: reason?.message || reason,
|
|
509
|
-
promise: promise.toString()
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
await this.shutdown();
|
|
514
|
-
process.exit(1);
|
|
515
|
-
});
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
/**
|
|
519
|
-
* Gracefully shutdown the application
|
|
520
|
-
* @returns {Promise<void>}
|
|
521
|
-
*/
|
|
522
|
-
async shutdown() {
|
|
523
|
-
if (this.isShuttingDown) {
|
|
524
|
-
return;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
this.isShuttingDown = true;
|
|
528
|
-
|
|
529
|
-
try {
|
|
530
|
-
console.log('🛑 Shutting down Loxia Autopilot One...');
|
|
531
|
-
|
|
532
|
-
if (this.logger) {
|
|
533
|
-
this.logger.info('Application shutdown initiated');
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
// Shutdown interfaces
|
|
537
|
-
for (const [type, interface_] of this.interfaces) {
|
|
538
|
-
try {
|
|
539
|
-
if (interface_.shutdown) {
|
|
540
|
-
await interface_.shutdown();
|
|
541
|
-
}
|
|
542
|
-
this.logger?.info(`${type} interface shutdown complete`);
|
|
543
|
-
} catch (error) {
|
|
544
|
-
console.error(`Failed to shutdown ${type} interface:`, error.message);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
// Shutdown async tool manager
|
|
549
|
-
if (this.asyncToolManager) {
|
|
550
|
-
await this.asyncToolManager.shutdown();
|
|
551
|
-
this.logger?.info('Async tool manager shutdown complete');
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
// Shutdown orchestrator
|
|
555
|
-
if (this.orchestrator) {
|
|
556
|
-
await this.orchestrator.shutdown();
|
|
557
|
-
this.logger?.info('Orchestrator shutdown complete');
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
// Cleanup configuration manager
|
|
561
|
-
if (this.configManager) {
|
|
562
|
-
this.configManager.cleanup();
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
// Close logger
|
|
566
|
-
if (this.logger) {
|
|
567
|
-
await this.logger.close();
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
console.log('✅ Loxia Autopilot One shutdown complete');
|
|
571
|
-
|
|
572
|
-
} catch (error) {
|
|
573
|
-
console.error('❌ Error during shutdown:', error.message);
|
|
574
|
-
} finally {
|
|
575
|
-
process.exit(0);
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
/**
|
|
580
|
-
* Get application status
|
|
581
|
-
* @returns {Object} Application status
|
|
582
|
-
*/
|
|
583
|
-
getStatus() {
|
|
584
|
-
return {
|
|
585
|
-
version: SYSTEM_VERSION,
|
|
586
|
-
uptime: process.uptime(),
|
|
587
|
-
memoryUsage: process.memoryUsage(),
|
|
588
|
-
interfaces: Array.from(this.interfaces.keys()),
|
|
589
|
-
isShuttingDown: this.isShuttingDown
|
|
590
|
-
};
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
/**
|
|
595
|
-
* Main application entry point
|
|
596
|
-
*/
|
|
597
|
-
async function main() {
|
|
598
|
-
const app = new LoxiaApplication();
|
|
599
|
-
|
|
600
|
-
// Parse command line arguments
|
|
601
|
-
const args = process.argv.slice(2);
|
|
602
|
-
const options = {
|
|
603
|
-
projectDir: process.cwd(),
|
|
604
|
-
watchConfig: args.includes('--watch-config'),
|
|
605
|
-
configPaths: []
|
|
606
|
-
};
|
|
607
|
-
|
|
608
|
-
// Look for custom config file
|
|
609
|
-
const configIndex = args.indexOf('--config');
|
|
610
|
-
if (configIndex !== -1 && args[configIndex + 1]) {
|
|
611
|
-
options.configPaths.push(args[configIndex + 1]);
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
await app.initialize(options);
|
|
615
|
-
|
|
616
|
-
// Keep the application running
|
|
617
|
-
return app;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
// Start the application if this file is run directly
|
|
621
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
622
|
-
if (process.argv[1] === __filename) {
|
|
623
|
-
console.log('🚀 Starting Loxia Autopilot One...');
|
|
624
|
-
main().catch(error => {
|
|
625
|
-
console.error('❌ Failed to start Loxia Autopilot One:', error.message);
|
|
626
|
-
console.error('Stack trace:', error.stack);
|
|
627
|
-
process.exit(1);
|
|
628
|
-
});
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
export { LoxiaApplication, main };
|
|
1
|
+
const a0_0x102749=a0_0x212c;(function(_0x5770e5,_0xb6b48b){const _0x4166b1=a0_0x212c,_0x49e81c=_0x5770e5();while(!![]){try{const _0x572c71=-parseInt(_0x4166b1(0xae))/0x1*(-parseInt(_0x4166b1(0xeb))/0x2)+-parseInt(_0x4166b1(0x123))/0x3*(-parseInt(_0x4166b1(0xdd))/0x4)+-parseInt(_0x4166b1(0xc2))/0x5*(parseInt(_0x4166b1(0x108))/0x6)+-parseInt(_0x4166b1(0xe1))/0x7+-parseInt(_0x4166b1(0x10d))/0x8*(-parseInt(_0x4166b1(0xba))/0x9)+-parseInt(_0x4166b1(0xc5))/0xa*(-parseInt(_0x4166b1(0xb1))/0xb)+parseInt(_0x4166b1(0x11f))/0xc;if(_0x572c71===_0xb6b48b)break;else _0x49e81c['push'](_0x49e81c['shift']());}catch(_0x4a12a0){_0x49e81c['push'](_0x49e81c['shift']());}}}(a0_0x57d3,0xd6cc7));import a0_0xa83fa5 from'path';import{fileURLToPath}from'url';import{createLogger}from'./utilities/logger.js';import{createConfigManager}from'./utilities/configManager.js';import a0_0x369568 from'./core/orchestrator.js';import a0_0x137313 from'./core/agentPool.js';import a0_0x24556f from'./core/messageProcessor.js';import a0_0x1f2b16 from'./core/agentScheduler.js';import a0_0x128f86 from'./core/contextManager.js';import a0_0xcf294e from'./core/stateManager.js';import a0_0x548e12 from'./services/aiService.js';import a0_0x4ba98e from'./services/budgetService.js';function a0_0x57d3(){const _0x2addc9=['Dw5JyxvNAhrfEgnLChrPB24','mtiXotLuAM1QyM4','igLUDgvYzMfJzsbZAhv0zg93BIbJB21WBgv0zq','yxn5BMnuB29StwfUywDLCG','y2XLyw51Ca','cVcFK4SGuMvJzwL2zwqGu0Lhsu5ulcbZAhv0DgLUzYbKB3DUigDYywnLzNvSBhKUlI4','B3v0Chv0CW','ywDLBNrty2HLzhvSzxi','zw5HyMXLza','y29UC29Szq','nty5nZu0B2LRr2L5','CMvNAxn0zxjuB29S','DMvYC2LVBG','zxHPDa','rMfPBgvKihrVihnODxrKB3DUia','D2vIu29JA2v0twfUywDLCG','sw50zxjMywnLigLUAxrPywXPEMf0Aw9UignVBxbSzxrLza','y29UDgv4De1HBMfNzxi','nduWnw5KDLfKDq','8j+tSsbxzwiGvuKGyxzHAwXHyMXLigf0oIa','C2v0u2nOzwr1BgvY','mty1mfjRyvrutq','zMLSDgvY','Bw9KzwXsB3v0zxjtzxj2AwnL','z2v0vg9VBa','B3jJAgvZDhjHDg9Y','lI9PBNrLCMzHy2vZl2nSAs5QCW','qxn5BMmGDg9VBcbTyw5Hz2vYihnODxrKB3DUignVBxbSzxrL','yxbPs2v5twfUywDLCG','BwvTB3j5vxnHz2u','y29UzMLN','Aw5PDgLHBgL6zuXVz2DPBMC','ignHCgfIAwXPDgLLCW','vg9VBca','vg9VBhmGAw5PDgLHBgL6zwq','BgLZDfrVB2XZ','4PYfieXVEgLHief1Dg9WAwXVDcbpBMuGAxmGCMvHzhKH','Dg9VBhnszwDPC3rYEq','Bg9N','C2v0qxbPs2v5twfUywDLCG','yNvKz2v0u2vYDMLJzq','igLUDgvYzMfJztO','CgXHDgzVCM0','DxjS','Aw1Hz2uTz2vU','nfnuvhvyCa','yMvUy2HTyxjRu2vYDMLJzq','AM9PBG','Bg94Awfxzwjtzxj2zxi','nZa3nZa5oevMCMHcvG','ywDLBNrKzwXHEq','Bwf4rMLSzvnPEMu','vLndB2rLigLUDgvYzMfJzsbJB25MAwD1CMvKigj1DcbUB3qGAw1WBgvTzw50zwqGEwv0','AxntAhv0DgLUz0rVD24','C2v0twvZC2fNzvbYB2nLC3nVCG','C2nOzwr1BgvY','y2XVC2u','Aw5PDgLHBgL6zuLUDgvYzMfJzxm','Aw5PDgLHBgL6zvrVB2XZ','ntrTrK5HCgK','qwDLBNqGu2nOzwr1BgvYihn0yxj0zwqGD2L0AcbxzwjtB2nRzxqGAw50zwDYyxrPB24','C2v0quLtzxj2AwnL','C2XPy2u','Bg9Nz2vY','A2v5CW','Dg9tDhjPBMC','ChvZAa','zNvUy3rPB24','zw50CMLLCW','AM9Izg9Uzq','C3rHy2S','D2f0y2HdB25MAwC','ywLtzxj2AwnL','zw52','y29UzMLNugf0Ahm','C2v0DxbtAhv0zg93BKHHBMrSzxjZ','u0Lhsu5u','y29UzMLNtwfUywDLCG','Aw5MBW','vw5JyxvNAhqGzxHJzxb0Aw9U','zxjYB3i','DNnJB2rL','4P2miezHAwXLzcb0BYbPBML0AwfSAxPLieXVEgLHief1Dg9WAwXVDcbpBMu6','zgLYBMfTzq','4P2mievYCM9Yigr1CMLUzYbZAhv0zg93BJO','Aw5PDgLHBgL6zq','C3rHDgvnyw5Hz2vY','qNjVD3nLCIb0B29SihjLz2LZDhjHDgLVBIbZA2LWCgvK','mJm4mLLQrMrrra','C2H1DgrVD24','u3rHCNrPBMCGAw50zxjMywnLigLUAxrPywXPEMf0Aw9UlI4U','C3rHCNq','Bw9KzwXZu2vYDMLJzq','mtm2sLHPEg90','qxbWBgLJyxrPB24GAw5PDgLHBgL6yxrPB24GzMfPBgvK','tg94AweGqxv0B3bPBg90ie9UzsbZDgfYDhvWignVBxbSzxrL','8j+AGcbtDgfYDgLUzYbmB3HPysbbDxrVCgLSB3qGt25LlI4U','4PYfieXVEgLHief1Dg9WAwXVDcbpBMuGC2H1DgrVD24Gy29TCgXLDgu','Aw5PDgLHBgL6zunVBMzPzW','sw5ZDgfSBcbWDxbWzxrLzxiGDg8Gzw5HyMXLigjYB3DZzxiGyxv0B21HDgLVBG','y29SB3jZ','BwvZC2fNzvbYB2nLC3nVCG','ywDLBNrqB29S','BwvZC2fNzq','cVcFK4SGuMvJzwL2zwqGu0LhvevstsWGC2H1DhrPBMCGzg93BIbNCMfJzwz1BgX5lI4U','Aw50zxjMywnLCW','zMLSzuf0DgfJAg1LBNrtzxj2AwnL','DgvYBwLUywW','u3rHy2SGDhjHy2u6','Aw5PDgLHBgL6zunVCMvdB21WB25LBNrZ','ChjVAMvJDerPCG','mtm3mJa4zhjLrK13','y3DK','zxjYB3jiyw5KBgvY','vgvYBwLUywWGvuKGBw9KztOGu2vYDMvYlw9UBhKGC3rHCNr1CcaOvgvYBwLUywWGvuKGD2LSBcbJB25Uzwn0igfZifDLyLnVy2TLDcbJBgLLBNqP','odmXodq2wLzxuu9x','D2vIu2vYDMvY','Bg9NrMLSzq','sw5PDgLHBgL6Aw5NihrVB2XZlI4U','mJu5ndLKrKvQuha','C2v0qwDLBNrqB29S'];a0_0x57d3=function(){return _0x2addc9;};return a0_0x57d3();}import a0_0x1e7173 from'./services/errorHandler.js';import a0_0xb631bf from'./services/benchmarkService.js';import a0_0x2ef57e from'./services/modelRouterService.js';import a0_0x4a88c2 from'./services/modelsService.js';import a0_0x10260e from'./services/apiKeyManager.js';import a0_0x13e97c from'./services/fileAttachmentService.js';import{ToolsRegistry}from'./tools/baseTool.js';import a0_0x4edbac from'./tools/agentDelayTool.js';import a0_0x18efe2 from'./tools/terminalTool.js';import a0_0x3e2595 from'./tools/fileSystemTool.js';import a0_0x67a2e7 from'./tools/browserTool.js';import a0_0x46225f from'./tools/jobDoneTool.js';import a0_0x2f308b from'./tools/agentCommunicationTool.js';import a0_0x31a0a4 from'./tools/taskManagerTool.js';import a0_0x3f6344 from'./tools/importAnalyzerTool.js';import a0_0x3e18d8 from'./tools/dependencyResolverTool.js';function a0_0x212c(_0x56a022,_0x1be753){_0x56a022=_0x56a022-0xae;const _0x57d360=a0_0x57d3();let _0x212c5d=_0x57d360[_0x56a022];if(a0_0x212c['HrNVIb']===undefined){var _0x5a2291=function(_0x3dcbac){const _0x2d86e3='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xa83fa5='',_0x369568='';for(let _0x137313=0x0,_0x24556f,_0x1f2b16,_0x128f86=0x0;_0x1f2b16=_0x3dcbac['charAt'](_0x128f86++);~_0x1f2b16&&(_0x24556f=_0x137313%0x4?_0x24556f*0x40+_0x1f2b16:_0x1f2b16,_0x137313++%0x4)?_0xa83fa5+=String['fromCharCode'](0xff&_0x24556f>>(-0x2*_0x137313&0x6)):0x0){_0x1f2b16=_0x2d86e3['indexOf'](_0x1f2b16);}for(let _0xcf294e=0x0,_0x548e12=_0xa83fa5['length'];_0xcf294e<_0x548e12;_0xcf294e++){_0x369568+='%'+('00'+_0xa83fa5['charCodeAt'](_0xcf294e)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x369568);};a0_0x212c['ptcYkS']=_0x5a2291,a0_0x212c['JuRhlg']={},a0_0x212c['HrNVIb']=!![];}const _0xfa44b0=_0x57d360[0x0],_0x402c15=_0x56a022+_0xfa44b0,_0x54b1c2=a0_0x212c['JuRhlg'][_0x402c15];return!_0x54b1c2?(_0x212c5d=a0_0x212c['ptcYkS'](_0x212c5d),a0_0x212c['JuRhlg'][_0x402c15]=_0x212c5d):_0x212c5d=_0x54b1c2,_0x212c5d;}import a0_0x37981f from'./tools/imageTool.js';import a0_0xe60cff from'./tools/staticAnalysisTool.js';import a0_0xd125e6 from'./tools/cloneDetectionTool.js';import a0_0x1a9ace from'./tools/fileTreeTool.js';import a0_0x2e526d from'./tools/fileContentReplaceTool.js';import a0_0x3d4d64 from'./tools/seekTool.js';import a0_0x50c64e from'./tools/webTool.js';import a0_0x3a1006 from'./tools/asyncToolManager.js';import a0_0x5ae8ac from'./interfaces/webServer.js';import{SYSTEM_VERSION,INTERFACE_TYPES}from'./utilities/constants.js';class LoxiaApplication{constructor(){const _0x1d7dcd=a0_0x212c;this['logger']=null,this[_0x1d7dcd(0xce)]=null,this['orchestrator']=null,this['interfaces']=new Map(),this['isShuttingDown']=![],this['shutdown']=this['shutdown']['bind'](this);}async[a0_0x102749(0x105)](_0x151d0d={}){const _0x1df03f=a0_0x102749;try{console['log']('🚀\x20Starting\x20Loxia\x20Autopilot\x20One\x20v'+SYSTEM_VERSION),await this['initializeConfig'](_0x151d0d),await this['initializeLogging'](),this['logger']['info']('Loxia\x20Autopilot\x20One\x20starting\x20up',{'version':SYSTEM_VERSION,'nodeVersion':process[_0x1df03f(0xbc)],'platform':process[_0x1df03f(0xda)],'projectDir':_0x151d0d[_0x1df03f(0x11e)]||process[_0x1df03f(0x120)]()}),await this[_0x1df03f(0x11d)](),await this[_0x1df03f(0xea)](),this['logger'][_0x1df03f(0xfe)](_0x1df03f(0x10a)),await this[_0x1df03f(0xe9)](_0x151d0d),this[_0x1df03f(0xef)][_0x1df03f(0xfe)](_0x1df03f(0xc0)),this[_0x1df03f(0xfb)](),this[_0x1df03f(0xef)][_0x1df03f(0xfe)](_0x1df03f(0x10f)),console[_0x1df03f(0xd6)](_0x1df03f(0xd4));}catch(_0x53b2bd){console['error'](_0x1df03f(0x102),_0x53b2bd['message']),this[_0x1df03f(0xef)]&&this['logger']['error'](_0x1df03f(0x10e),{'error':_0x53b2bd[_0x1df03f(0x117)],'stack':_0x53b2bd['stack']}),process[_0x1df03f(0xbd)](0x1);}}async[a0_0x102749(0x112)](_0x4968a0){const _0x3ac905=a0_0x102749,__filename=fileURLToPath(import.meta.url),__dirname=a0_0xa83fa5[_0x3ac905(0x103)](__filename),_0x13fcd1=[a0_0xa83fa5[_0x3ac905(0xdf)](__dirname,'../config/default.json'),..._0x4968a0['configPaths']||[]];this['configManager']=createConfigManager({'configPaths':_0x13fcd1,'envPrefix':'LOXIA'}),this[_0x3ac905(0xce)]=await this[_0x3ac905(0xfd)]['loadConfig'](),_0x4968a0['watchConfig']&&await this[_0x3ac905(0xfd)][_0x3ac905(0xf7)](!![]);}async[a0_0x102749(0xcf)](){const _0x43d0a6=a0_0x102749,_0x20ad56=this[_0x43d0a6(0xce)]['logging']||{};this[_0x43d0a6(0xef)]=createLogger({'level':_0x20ad56['level']||'info','outputs':_0x20ad56[_0x43d0a6(0xb6)]||[_0x43d0a6(0xb9)],'colors':_0x20ad56[_0x43d0a6(0x114)]!==![],'timestamp':_0x20ad56['timestamp']!==![],'logFile':_0x20ad56[_0x43d0a6(0x125)],'maxFileSize':_0x20ad56[_0x43d0a6(0xe3)],'maxFiles':_0x20ad56['maxFiles']}),await this[_0x43d0a6(0xef)][_0x43d0a6(0x105)]();}async[a0_0x102749(0x11d)](){const _0x38bbe5=a0_0x102749;this[_0x38bbe5(0xef)]['info']('Initializing\x20core\x20components...'),this['stateManager']=new a0_0xcf294e(this['config'],this[_0x38bbe5(0xef)]),this['fileAttachmentService']=new a0_0x13e97c(this[_0x38bbe5(0xce)],this[_0x38bbe5(0xef)]),await this['fileAttachmentService']['initialize'](),this['contextManager']=new a0_0x128f86(this['config'],this['logger']),this['toolsRegistry']=new ToolsRegistry(this[_0x38bbe5(0xef)]),this['asyncToolManager']=new a0_0x3a1006(this['config'],this['logger']),this[_0x38bbe5(0x116)]=new a0_0x137313(this['config'],this[_0x38bbe5(0xef)],this[_0x38bbe5(0x106)],this[_0x38bbe5(0xc1)],this['toolsRegistry']),this['budgetService']=new a0_0x4ba98e(this[_0x38bbe5(0xce)],this[_0x38bbe5(0xef)]),this[_0x38bbe5(0x121)]=new a0_0x1e7173(this['config'],this['logger']),this[_0x38bbe5(0xcc)]=new a0_0x10260e(this[_0x38bbe5(0xef)]),this[_0x38bbe5(0xf8)]=new a0_0x548e12(this['config'],this[_0x38bbe5(0xef)],this[_0x38bbe5(0xd8)],this[_0x38bbe5(0x121)]),this['aiService'][_0x38bbe5(0xd7)](this[_0x38bbe5(0xcc)]),this[_0x38bbe5(0xf8)][_0x38bbe5(0xaf)](this[_0x38bbe5(0x116)]),this['benchmarkService']=new a0_0xb631bf(this['config'],this['logger']),this['modelsService']=new a0_0x4a88c2(this['config'],this['logger']),this['modelRouterService']=new a0_0x2ef57e(this[_0x38bbe5(0xce)],this['logger'],this['benchmarkService'],this['aiService']),this[_0x38bbe5(0x10c)][_0x38bbe5(0xd7)](this[_0x38bbe5(0xcc)]),await this[_0x38bbe5(0xde)]['initialize'](),await this[_0x38bbe5(0x10c)]['initialize'](),this['messageProcessor']=new a0_0x24556f(this['config'],this[_0x38bbe5(0xef)],this[_0x38bbe5(0xd5)],this[_0x38bbe5(0x116)],this[_0x38bbe5(0xc1)],this['aiService'],this[_0x38bbe5(0xc7)],this[_0x38bbe5(0x10c)]),this[_0x38bbe5(0xb7)]=new a0_0x1f2b16(this[_0x38bbe5(0x116)],this['messageProcessor'],this[_0x38bbe5(0xf8)],this['logger'],null,this['modelRouterService'],this['modelsService']),this[_0x38bbe5(0xc9)]=new a0_0x369568(this['config'],this[_0x38bbe5(0xef)],this['agentPool'],this['messageProcessor'],this[_0x38bbe5(0xf8)],this['stateManager']),this[_0x38bbe5(0x115)]['orchestrator']=this[_0x38bbe5(0xc9)],this['messageProcessor']['setScheduler'](this['agentScheduler']),this[_0x38bbe5(0x116)][_0x38bbe5(0xe6)](this['messageProcessor']),this[_0x38bbe5(0x116)]['setScheduler'](this[_0x38bbe5(0xb7)]),this[_0x38bbe5(0x116)]['setFileAttachmentService'](this[_0x38bbe5(0x11a)]),this['orchestrator'][_0x38bbe5(0x11a)]=this[_0x38bbe5(0x11a)],this['logger']['info']('Core\x20components\x20initialized');}async['initializeTools'](){const _0x15c361=a0_0x102749;this[_0x15c361(0xef)][_0x15c361(0xfe)](_0x15c361(0x126)),await this[_0x15c361(0xd5)]['registerTool'](a0_0x4edbac),await this[_0x15c361(0xd5)]['registerTool'](a0_0x18efe2),await this[_0x15c361(0xd5)]['registerTool'](a0_0x3e2595),await this[_0x15c361(0xd5)][_0x15c361(0xbb)](a0_0x46225f),await this['toolsRegistry']['registerTool'](a0_0x2f308b),await this[_0x15c361(0xd5)]['registerTool'](a0_0x31a0a4),await this['toolsRegistry'][_0x15c361(0xbb)](a0_0x3f6344),await this[_0x15c361(0xd5)][_0x15c361(0xbb)](a0_0x3e18d8),await this[_0x15c361(0xd5)][_0x15c361(0xbb)](a0_0x37981f),await this[_0x15c361(0xd5)]['registerTool'](a0_0xe60cff),await this[_0x15c361(0xd5)]['registerTool'](a0_0xd125e6),await this[_0x15c361(0xd5)][_0x15c361(0xbb)](a0_0x1a9ace),await this['toolsRegistry']['registerTool'](a0_0x2e526d),await this[_0x15c361(0xd5)][_0x15c361(0xbb)](a0_0x3d4d64),await this[_0x15c361(0xd5)][_0x15c361(0xbb)](a0_0x50c64e);if(this['config']['tools']?.['browser']?.[_0x15c361(0xb8)]!==![])try{await this['toolsRegistry']['registerTool'](a0_0x67a2e7),this[_0x15c361(0xef)]['info']('Browser\x20tool\x20registered\x20(requires\x20puppeteer)');}catch(_0x3052da){this['logger']['warn'](_0x15c361(0x107),{'reason':_0x3052da[_0x15c361(0x117)],'suggestion':_0x15c361(0x113)});}const _0x1270fc=this['toolsRegistry'][_0x15c361(0xc8)](_0x15c361(0xe2));_0x1270fc&&typeof _0x1270fc[_0x15c361(0xaf)]==='function'&&_0x1270fc[_0x15c361(0xaf)](this['agentPool']);const _0x2fd06f=this[_0x15c361(0xd5)][_0x15c361(0xc8)](_0x15c361(0xf5));_0x2fd06f&&typeof _0x2fd06f['setAgentPool']==='function'&&_0x2fd06f[_0x15c361(0xaf)](this['agentPool']);const _0x45d9e1=this['toolsRegistry'][_0x15c361(0xc8)]('taskmanager');_0x45d9e1&&typeof _0x45d9e1[_0x15c361(0xaf)]==='function'&&_0x45d9e1['setAgentPool'](this[_0x15c361(0x116)]);_0x45d9e1&&typeof _0x45d9e1[_0x15c361(0xc4)]==='function'&&_0x45d9e1['setScheduler'](this[_0x15c361(0xe7)]);const _0x1bb7ba=this['toolsRegistry']['getTool']('agentcommunication');_0x1bb7ba&&this['logger'][_0x15c361(0xfe)]('Agent\x20Communication\x20Tool\x20registered\x20successfully');const _0x2f7160=this[_0x15c361(0xd5)][_0x15c361(0xc8)](_0x15c361(0xdc));_0x2f7160&&typeof _0x2f7160['setAIService']===_0x15c361(0xf3)&&(_0x2f7160[_0x15c361(0xed)](this[_0x15c361(0xf8)]),this['logger']['info']('AIService\x20set\x20for\x20Image\x20Generation\x20Tool'));_0x2f7160&&typeof _0x2f7160['setAgentPool']===_0x15c361(0xf3)&&(_0x2f7160[_0x15c361(0xaf)](this[_0x15c361(0x116)]),this['logger']['info']('AgentPool\x20set\x20for\x20Image\x20Generation\x20Tool'));const _0x250587=this[_0x15c361(0xd5)]['getToolCapabilities']();this[_0x15c361(0xef)]['info'](_0x15c361(0xd2),{'toolCount':Object[_0x15c361(0xf0)](_0x250587)['length'],'enabledTools':Object['keys'](_0x250587)[_0x15c361(0xc6)](_0x46ee3b=>_0x250587[_0x46ee3b]['capabilities'][_0x15c361(0xb8)]),'registeredTools':this[_0x15c361(0xd5)][_0x15c361(0xd3)]()});if(this[_0x15c361(0xef)]['level']==='debug')for(const [_0x53c581,_0x32ac45]of Object[_0x15c361(0xf4)](_0x250587)){this[_0x15c361(0xef)]['debug'](_0x15c361(0xd1)+_0x53c581+_0x15c361(0xd0),_0x32ac45['capabilities']);}}async[a0_0x102749(0xe9)](_0x1c877a){const _0x42f1dd=a0_0x102749;this['logger'][_0x42f1dd(0xfe)]('Initializing\x20interfaces...');const _0xf6c85f=this[_0x42f1dd(0xce)]['interfaces']||{},_0x2738fd=process[_0x42f1dd(0xf9)]['LOXIA_UI_MODE']||'cli';if(_0xf6c85f['cli']?.['enabled']!==![]&&_0x2738fd!==_0x42f1dd(0x11b)){this[_0x42f1dd(0xef)][_0x42f1dd(0xfe)]('Loading\x20CLI\x20(readline)...');const {default:_0x534ad1}=await import(_0x42f1dd(0xca)),_0x538af0=new _0x534ad1(this['orchestrator'],this[_0x42f1dd(0xef)],_0xf6c85f['cli']||{});await _0x538af0['initialize'](),this[_0x42f1dd(0x119)]['set'](INTERFACE_TYPES['CLI'],_0x538af0),this[_0x42f1dd(0xef)][_0x42f1dd(0xfe)]('CLI\x20interface\x20initialized');}_0x2738fd===_0x42f1dd(0x11b)&&this['logger']['info'](_0x42f1dd(0x122));if(_0xf6c85f['web']?.['enabled']!==![]){const _0x59ee85=new a0_0x5ae8ac(this['orchestrator'],this[_0x42f1dd(0xef)],_0xf6c85f['web']||{'port':0x1f90,'host':'localhost'});_0x59ee85[_0x42f1dd(0xd5)]=this['toolsRegistry'],_0x59ee85['setApiKeyManager'](this['apiKeyManager']),await _0x59ee85['initialize'](),this['interfaces']['set'](INTERFACE_TYPES['WEB'],_0x59ee85),this['orchestrator'][_0x42f1dd(0x124)]=_0x59ee85,this[_0x42f1dd(0x115)]['setWebSocketManager'](_0x59ee85),this['agentScheduler'][_0x42f1dd(0xbf)]=_0x59ee85,this[_0x42f1dd(0xb7)][_0x42f1dd(0x10b)](),this['logger'][_0x42f1dd(0xfe)](_0x42f1dd(0xec)),global[_0x42f1dd(0xe0)]=_0x59ee85;const _0x16f24e=_0x59ee85['getStatus']();this['logger']['info']('Web\x20interface\x20initialized',{'url':_0x16f24e['url']}),console['log']('🌐\x20Server\x20running\x20at\x20'+_0x16f24e[_0x42f1dd(0xdb)]),console[_0x42f1dd(0xd6)](_0x42f1dd(0xc3)+_0x16f24e['url']);}_0xf6c85f[_0x42f1dd(0x101)]?.['enabled']===!![]&&this['logger'][_0x42f1dd(0xfe)](_0x42f1dd(0xe4));}['setupShutdownHandlers'](){const _0x638309=a0_0x102749;process['on'](_0x638309(0xfc),async()=>{const _0x217ced=_0x638309;console['log'](_0x217ced(0xb5)),await this[_0x217ced(0x109)]();}),process['on']('SIGTERM',async()=>{const _0x142f64=_0x638309;console['log'](_0x142f64(0x118)),await this['shutdown']();}),process['on'](_0x638309(0xb0),async _0x55cfc4=>{const _0x479195=_0x638309;console['error']('❌\x20Uncaught\x20exception:',_0x55cfc4),this[_0x479195(0xef)]&&this['logger'][_0x479195(0x100)](_0x479195(0xff),{'error':_0x55cfc4['message'],'stack':_0x55cfc4[_0x479195(0xf6)]}),await this['shutdown'](),process[_0x479195(0xbd)](0x1);}),process['on']('unhandledRejection',async(_0x33b4c0,_0x3db740)=>{const _0x58d3a6=_0x638309;console['error']('❌\x20Unhandled\x20promise\x20rejection:',_0x33b4c0),this['logger']&&this[_0x58d3a6(0xef)]['error']('Unhandled\x20promise\x20rejection',{'reason':_0x33b4c0?.['message']||_0x33b4c0,'promise':_0x3db740[_0x58d3a6(0xf1)]()}),await this['shutdown'](),process[_0x58d3a6(0xbd)](0x1);});}async['shutdown'](){const _0x469d20=a0_0x102749;if(this['isShuttingDown'])return;this['isShuttingDown']=!![];try{console[_0x469d20(0xd6)]('🛑\x20Shutting\x20down\x20Loxia\x20Autopilot\x20One...');this[_0x469d20(0xef)]&&this['logger'][_0x469d20(0xfe)]('Application\x20shutdown\x20initiated');for(const [_0x47aecf,_0x15cc3f]of this[_0x469d20(0x119)]){try{_0x15cc3f[_0x469d20(0x109)]&&await _0x15cc3f[_0x469d20(0x109)](),this[_0x469d20(0xef)]?.['info'](_0x47aecf+_0x469d20(0xb2));}catch(_0x371f6c){console[_0x469d20(0x100)](_0x469d20(0xbe)+_0x47aecf+_0x469d20(0xd9),_0x371f6c[_0x469d20(0x117)]);}}this[_0x469d20(0xb3)]&&(await this[_0x469d20(0xb3)][_0x469d20(0x109)](),this['logger']?.[_0x469d20(0xfe)](_0x469d20(0xcb))),this[_0x469d20(0xc9)]&&(await this['orchestrator'][_0x469d20(0x109)](),this['logger']?.[_0x469d20(0xfe)]('Orchestrator\x20shutdown\x20complete')),this['configManager']&&this['configManager'][_0x469d20(0xb4)](),this[_0x469d20(0xef)]&&await this['logger'][_0x469d20(0xe8)](),console[_0x469d20(0xd6)](_0x469d20(0x111));}catch(_0x3de3ce){console['error'](_0x469d20(0x104),_0x3de3ce['message']);}finally{process[_0x469d20(0xbd)](0x0);}}['getStatus'](){const _0x2059b1=a0_0x102749;return{'version':SYSTEM_VERSION,'uptime':process['uptime'](),'memoryUsage':process[_0x2059b1(0xcd)](),'interfaces':Array['from'](this[_0x2059b1(0x119)][_0x2059b1(0xf0)]()),'isShuttingDown':this[_0x2059b1(0xe5)]};}}async function main(){const _0x1fc855=a0_0x102749,_0x5522f8=new LoxiaApplication(),_0x903254=process['argv'][_0x1fc855(0xee)](0x2),_0xf65489={'projectDir':process[_0x1fc855(0x120)](),'watchConfig':_0x903254['includes']('--watch-config'),'configPaths':[]},_0x3b6183=_0x903254['indexOf']('--config');return _0x3b6183!==-0x1&&_0x903254[_0x3b6183+0x1]&&_0xf65489[_0x1fc855(0xfa)][_0x1fc855(0xf2)](_0x903254[_0x3b6183+0x1]),await _0x5522f8['initialize'](_0xf65489),_0x5522f8;}const __filename=fileURLToPath(import.meta.url);process['argv'][0x1]===__filename&&(console[a0_0x102749(0xd6)](a0_0x102749(0x110)),main()['catch'](_0x4bbad3=>{const _0x42f8a5=a0_0x102749;console[_0x42f8a5(0x100)]('❌\x20Failed\x20to\x20start\x20Loxia\x20Autopilot\x20One:',_0x4bbad3[_0x42f8a5(0x117)]),console['error'](_0x42f8a5(0x11c),_0x4bbad3['stack']),process['exit'](0x1);}));export{LoxiaApplication,main};
|