@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.
- 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 +14 -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_0xfa603b=a0_0x290b;(function(_0x510903,_0x29b681){const _0x3b24b7=a0_0x290b,_0x274ef4=_0x510903();while(!![]){try{const _0x4ddcfc=parseInt(_0x3b24b7(0x13c))/0x1*(-parseInt(_0x3b24b7(0x151))/0x2)+parseInt(_0x3b24b7(0x160))/0x3+-parseInt(_0x3b24b7(0x179))/0x4+parseInt(_0x3b24b7(0x156))/0x5+parseInt(_0x3b24b7(0x15e))/0x6+-parseInt(_0x3b24b7(0x13b))/0x7+-parseInt(_0x3b24b7(0x137))/0x8;if(_0x4ddcfc===_0x29b681)break;else _0x274ef4['push'](_0x274ef4['shift']());}catch(_0xce71c1){_0x274ef4['push'](_0x274ef4['shift']());}}}(a0_0x2ad7,0x9dd1e));import a0_0x559949 from'path';import{fileURLToPath}from'url';import{createLogger}from'./utilities/logger.js';import{createConfigManager}from'./utilities/configManager.js';import a0_0x3af5ba from'./core/orchestrator.js';import a0_0x42e5ce from'./core/agentPool.js';import a0_0x6963a9 from'./core/messageProcessor.js';import a0_0x4caa62 from'./core/agentScheduler.js';import a0_0x2437f7 from'./core/contextManager.js';import a0_0x1bd9d2 from'./core/stateManager.js';import a0_0x5bb219 from'./services/aiService.js';import a0_0x1d7516 from'./services/budgetService.js';import a0_0x45037e from'./services/errorHandler.js';import a0_0x518fac from'./services/benchmarkService.js';import a0_0x5ece32 from'./services/modelRouterService.js';import a0_0x1015ba from'./services/modelsService.js';import a0_0xc6fc71 from'./services/apiKeyManager.js';import a0_0x16626c from'./services/fileAttachmentService.js';import{ToolsRegistry}from'./tools/baseTool.js';import a0_0x27a5d3 from'./tools/agentDelayTool.js';import a0_0x2e0014 from'./tools/terminalTool.js';import a0_0x5d254e from'./tools/fileSystemTool.js';import a0_0x28b7e4 from'./tools/browserTool.js';import a0_0x46f2a7 from'./tools/jobDoneTool.js';import a0_0x2425d2 from'./tools/agentCommunicationTool.js';import a0_0x5e8188 from'./tools/taskManagerTool.js';import a0_0x3cd03f from'./tools/importAnalyzerTool.js';import a0_0x4da148 from'./tools/dependencyResolverTool.js';function a0_0x290b(_0x3eb6e7,_0x736e54){_0x3eb6e7=_0x3eb6e7-0x118;const _0x2ad71c=a0_0x2ad7();let _0x290b13=_0x2ad71c[_0x3eb6e7];if(a0_0x290b['hMahMg']===undefined){var _0x411952=function(_0x5b91ae){const _0x510b84='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x559949='',_0x3af5ba='';for(let _0x42e5ce=0x0,_0x6963a9,_0x4caa62,_0x2437f7=0x0;_0x4caa62=_0x5b91ae['charAt'](_0x2437f7++);~_0x4caa62&&(_0x6963a9=_0x42e5ce%0x4?_0x6963a9*0x40+_0x4caa62:_0x4caa62,_0x42e5ce++%0x4)?_0x559949+=String['fromCharCode'](0xff&_0x6963a9>>(-0x2*_0x42e5ce&0x6)):0x0){_0x4caa62=_0x510b84['indexOf'](_0x4caa62);}for(let _0x1bd9d2=0x0,_0x5bb219=_0x559949['length'];_0x1bd9d2<_0x5bb219;_0x1bd9d2++){_0x3af5ba+='%'+('00'+_0x559949['charCodeAt'](_0x1bd9d2)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3af5ba);};a0_0x290b['oKoKaF']=_0x411952,a0_0x290b['XsWAuG']={},a0_0x290b['hMahMg']=!![];}const _0x372452=_0x2ad71c[0x0],_0x53c974=_0x3eb6e7+_0x372452,_0x1a4177=a0_0x290b['XsWAuG'][_0x53c974];return!_0x1a4177?(_0x290b13=a0_0x290b['oKoKaF'](_0x290b13),a0_0x290b['XsWAuG'][_0x53c974]=_0x290b13):_0x290b13=_0x1a4177,_0x290b13;}import a0_0x1ff97b from'./tools/imageTool.js';function a0_0x2ad7(){const _0x4c1546=['zw5HyMXLza','ChjVAMvJDerPCG','zw50CMLLCW','zw52','nJK1ndqWswHcCero','y29UDgv4De1HBMfNzxi','y2XVC2u','Bg9Nz2vY','C2v0DxbtAhv0zg93BKHHBMrSzxjZ','vw5JyxvNAhqGzxHJzxb0Aw9U','qwDLBNrqB29SihnLDcbMB3iGsw1Hz2uGr2vUzxjHDgLVBIbuB29S','yMvUy2HTyxjRu2vYDMLJzq','nJaYnti3ofLUrxvlrW','yxjNDG','mJeXmdyYm0fuCgn6zq','y29UzMLNtwfUywDLCG','cVcFK4SGuMvJzwL2zwqGu0LhvevstsWGC2H1DhrPBMCGzg93BIbNCMfJzwz1BgX5lI4U','B3v0Chv0CW','yxbPs2v5twfUywDLCG','C2v0qxbPs2v5twfUywDLCG','vg9VBca','tg94AweGqxv0B3bPBg90ie9UzsbZDgfYDgLUzYb1Ca','sw5PDgLHBgL6Aw5NigLUDgvYzMfJzxmUlI4','yNvKz2v0u2vYDMLJzq','q0XjigLUDgvYzMfJzsbPBML0AwfSAxPLza','Bwf4rMLSzxm','Aw50zxjMywnLCW','AxntAhv0DgLUz0rVD24','8j+tSsbxzwiGvuKGyxzHAwXHyMXLigf0oIa','ignHCgfIAwXPDgLLCW','8j+mKcbtzxj2zxiGCNvUBMLUzYbHDca','C2nOzwr1BgvY','zxjYB3i','vLndB2rLigLUDgvYzMfJzsbJB25MAwD1CMvKigj1DcbUB3qGAw1WBgvTzw50zwqGEwv0','Aw5JBhvKzxm','D2f0y2HdB25MAwC','igLUDgvYzMfJzsbZAhv0zg93BIbJB21WBgv0zq','z2v0u3rHDhvZ','Bw9KzwXZu2vYDMLJzq','mtiXnZmYngvOzhHNAq','y2f0y2G','zxHPDa','Aw5PDgLHBgL6zunVBMzPzW','C2v0','Bg9HzenVBMzPzW','D2vI','Aw5MBW','u3rHCNrPBMCGAw50zxjMywnLigLUAxrPywXPEMf0Aw9UlI4U','qwDLBNqGq29TBxvUAwnHDgLVBIbuB29SihjLz2LZDgvYzwqGC3vJy2vZC2z1BgX5','C3rHDgvnyw5Hz2vY','C3rHy2S','8j+BKsbtAhv0DgLUzYbKB3DUieXVEgLHief1Dg9WAwXVDcbpBMuUlI4','Aw5PDgLHBgL6zuXVz2DPBMC','sw5ZDgfSBcbWDxbWzxrLzxiGDg8Gzw5HyMXLigjYB3DZzxiGyxv0B21HDgLVBG','4P2miezHAwXLzcb0BYbZDgfYDcbmB3HPysbbDxrVCgLSB3qGt25LoG','Bw9KzwXsB3v0zxjtzxj2AwnL','zgvIDwC','te9ysufFvuLFtu9erq','C2v0quLtzxj2AwnL','8j+AGcbtDgfYDgLUzYbmB3HPysbbDxrVCgLSB3qGt25Lihy','CMvNAxn0zxjuB29S','C2v0qwDLBNrqB29S','zMLSzuf0DgfJAg1LBNrtzxj2AwnL','ywDLBNrty2HLzhvSzxi','BwvZC2fNzvbYB2nLC3nVCG','Dg9VBhnszwDPC3rYEq','DgfZA21HBMfNzxi','u0Lhsu5u','q29YzsbJB21WB25LBNrZigLUAxrPywXPEMvK','y2XLyw51Ca','ywDLBNrqB29S','u0Lhvevstq','tg94AweGqxv0B3bPBg90ie9UzsbZDgfYDhvWignVBxbSzxrL','C2H1DgrVD24','DxjS','zNvUy3rPB24','z2v0vg9VBenHCgfIAwXPDgLLCW','BwvZC2fNzq','mJy4mJu3nK92sujZAW','B3jJAgvZDhjHDg9Y','AM9Izg9Uzq','Bg9N','mtKXmdGXogviuuLMuG','nvndAK1cCq','z2v0vg9VBa','4P2mifvUy2f1z2H0igv4y2vWDgLVBJO','y2XP','rMfPBgvKihrVihnODxrKB3DUia','DMvYC2LVBG','lI9PBNrLCMzHy2vZl2nSAs5QCW','Aw5PDgLHBgL6zvrVB2XZ','vw5Oyw5KBgvKihbYB21PC2uGCMvQzwn0Aw9U','y29UzMLN','Aw5PDgLHBgL6zuLUDgvYzMfJzxm','Dg9VBhm','ywLtzxj2AwnL','Aw5PDgLHBgL6zq','qxbWBgLJyxrPB24GC2H1DgrVD24GAw5PDgLHDgvK','Bg94Awfxzwjtzxj2zxi','4PYfieXVEgLHief1Dg9WAwXVDcbpBMuGC2H1DgrVD24Gy29TCgXLDgu','yxn5BMnuB29StwfUywDLCG','cVcFK4SGuMvJzwL2zwqGu0Lhsu5ulcbZAhv0DgLUzYbKB3DUigDYywnLzNvSBhKUlI4','zMLSDgvY','Bwf4rMLSzvnPEMu','mte1mte0z05qu0ne'];a0_0x2ad7=function(){return _0x4c1546;};return a0_0x2ad7();}import a0_0x20f41a from'./tools/staticAnalysisTool.js';import a0_0x410481 from'./tools/cloneDetectionTool.js';import a0_0x407e82 from'./tools/fileTreeTool.js';import a0_0x53853e from'./tools/fileContentReplaceTool.js';import a0_0x4c6c5f from'./tools/seekTool.js';import a0_0x2feec9 from'./tools/webTool.js';import a0_0x1e9a38 from'./tools/asyncToolManager.js';import a0_0x2a8548 from'./interfaces/webServer.js';import{SYSTEM_VERSION,INTERFACE_TYPES}from'./utilities/constants.js';class LoxiaApplication{constructor(){const _0x450802=a0_0x290b;this[_0x450802(0x159)]=null,this['config']=null,this['orchestrator']=null,this['interfaces']=new Map(),this['isShuttingDown']=![],this[_0x450802(0x132)]=this['shutdown']['bind'](this);}async[a0_0xfa603b(0x149)](_0x2f3ef4={}){const _0x1dd15f=a0_0xfa603b;try{console[_0x1dd15f(0x13a)](_0x1dd15f(0x124)+SYSTEM_VERSION),await this['initializeConfig'](_0x2f3ef4),await this[_0x1dd15f(0x11d)](),this['logger'][_0x1dd15f(0x180)](_0x1dd15f(0x167),{'version':SYSTEM_VERSION,'nodeVersion':process[_0x1dd15f(0x141)],'platform':process['platform'],'projectDir':_0x2f3ef4[_0x1dd15f(0x153)]||process['cwd']()}),await this['initializeCoreComponents'](),await this[_0x1dd15f(0x143)](),this[_0x1dd15f(0x159)][_0x1dd15f(0x180)](_0x1dd15f(0x118)),await this[_0x1dd15f(0x146)](_0x2f3ef4),this[_0x1dd15f(0x159)][_0x1dd15f(0x180)]('Interface\x20initialization\x20completed'),this[_0x1dd15f(0x15a)](),this[_0x1dd15f(0x159)]['info'](_0x1dd15f(0x131)),console[_0x1dd15f(0x13a)]('✅\x20Loxia\x20Autopilot\x20One\x20is\x20ready!');}catch(_0x2cfe58){console[_0x1dd15f(0x172)]('❌\x20Failed\x20to\x20initialize\x20Loxia\x20Autopilot\x20One:',_0x2cfe58[_0x1dd15f(0x136)]),this[_0x1dd15f(0x159)]&&this['logger'][_0x1dd15f(0x172)]('Application\x20initialization\x20failed',{'error':_0x2cfe58[_0x1dd15f(0x136)],'stack':_0x2cfe58['stack']}),process['exit'](0x1);}}async[a0_0xfa603b(0x17c)](_0xd4235f){const _0x53ae7e=a0_0xfa603b,__filename=fileURLToPath(import.meta.url),__dirname=a0_0x559949['dirname'](__filename),_0x1df052=[a0_0x559949['join'](__dirname,'../config/default.json'),..._0xd4235f['configPaths']||[]];this['configManager']=createConfigManager({'configPaths':_0x1df052,'envPrefix':'LOXIA'}),this[_0x53ae7e(0x145)]=await this[_0x53ae7e(0x161)][_0x53ae7e(0x17e)](),_0xd4235f[_0x53ae7e(0x175)]&&await this['configManager']['watchConfig'](!![]);}async[a0_0xfa603b(0x11d)](){const _0x58be7e=a0_0xfa603b,_0x4317a8=this[_0x58be7e(0x145)]['logging']||{};this['logger']=createLogger({'level':_0x4317a8['level']||'info','outputs':_0x4317a8[_0x58be7e(0x163)]||['console'],'colors':_0x4317a8['colors']!==![],'timestamp':_0x4317a8['timestamp']!==![],'logFile':_0x4317a8['logFile'],'maxFileSize':_0x4317a8[_0x58be7e(0x150)],'maxFiles':_0x4317a8[_0x58be7e(0x16b)]}),await this['logger'][_0x58be7e(0x149)]();}async['initializeCoreComponents'](){const _0x10cc02=a0_0xfa603b;this['logger'][_0x10cc02(0x180)]('Initializing\x20core\x20components...'),this['stateManager']=new a0_0x1bd9d2(this[_0x10cc02(0x145)],this[_0x10cc02(0x159)]),this['fileAttachmentService']=new a0_0x16626c(this['config'],this['logger']),await this['fileAttachmentService'][_0x10cc02(0x149)](),this['contextManager']=new a0_0x2437f7(this[_0x10cc02(0x145)],this[_0x10cc02(0x159)]),this['toolsRegistry']=new ToolsRegistry(this['logger']),this['asyncToolManager']=new a0_0x1e9a38(this['config'],this[_0x10cc02(0x159)]),this['agentPool']=new a0_0x42e5ce(this['config'],this[_0x10cc02(0x159)],this[_0x10cc02(0x11a)],this['contextManager'],this['toolsRegistry']),this[_0x10cc02(0x169)]=new a0_0x1d7516(this['config'],this[_0x10cc02(0x159)]),this['errorHandler']=new a0_0x45037e(this[_0x10cc02(0x145)],this['logger']),this['apiKeyManager']=new a0_0xc6fc71(this[_0x10cc02(0x159)]),this[_0x10cc02(0x148)]=new a0_0x5bb219(this['config'],this[_0x10cc02(0x159)],this['budgetService'],this['errorHandler']),this['aiService'][_0x10cc02(0x165)](this[_0x10cc02(0x164)]),this[_0x10cc02(0x148)][_0x10cc02(0x126)](this[_0x10cc02(0x12f)]),this[_0x10cc02(0x15d)]=new a0_0x518fac(this[_0x10cc02(0x145)],this['logger']),this['modelsService']=new a0_0x1015ba(this[_0x10cc02(0x145)],this['logger']),this[_0x10cc02(0x120)]=new a0_0x5ece32(this[_0x10cc02(0x145)],this['logger'],this[_0x10cc02(0x15d)],this[_0x10cc02(0x148)]),this[_0x10cc02(0x178)]['setApiKeyManager'](this[_0x10cc02(0x164)]),await this['benchmarkService'][_0x10cc02(0x149)](),await this['modelsService'][_0x10cc02(0x149)](),this[_0x10cc02(0x129)]=new a0_0x6963a9(this['config'],this['logger'],this['toolsRegistry'],this[_0x10cc02(0x12f)],this[_0x10cc02(0x157)],this[_0x10cc02(0x148)],this[_0x10cc02(0x120)],this[_0x10cc02(0x178)]),this['agentScheduler']=new a0_0x4caa62(this[_0x10cc02(0x12f)],this[_0x10cc02(0x129)],this[_0x10cc02(0x148)],this['logger'],null,this['modelRouterService'],this['modelsService']),this[_0x10cc02(0x138)]=new a0_0x3af5ba(this[_0x10cc02(0x145)],this[_0x10cc02(0x159)],this[_0x10cc02(0x12f)],this[_0x10cc02(0x129)],this[_0x10cc02(0x148)],this[_0x10cc02(0x11a)]),this['messageProcessor'][_0x10cc02(0x138)]=this[_0x10cc02(0x138)],this[_0x10cc02(0x129)]['setScheduler'](this[_0x10cc02(0x128)]),this['agentPool']['setMessageProcessor'](this[_0x10cc02(0x129)]),this['agentPool']['setScheduler'](this['agentScheduler']),this['agentPool']['setFileAttachmentService'](this['fileAttachmentService']),this[_0x10cc02(0x138)][_0x10cc02(0x127)]=this['fileAttachmentService'],this[_0x10cc02(0x159)][_0x10cc02(0x180)](_0x10cc02(0x12d));}async[a0_0xfa603b(0x143)](){const _0x136c43=a0_0xfa603b;this[_0x136c43(0x159)]['info']('Initializing\x20tools...'),await this[_0x136c43(0x12a)]['registerTool'](a0_0x27a5d3),await this['toolsRegistry'][_0x136c43(0x125)](a0_0x2e0014),await this[_0x136c43(0x12a)][_0x136c43(0x125)](a0_0x5d254e),await this['toolsRegistry'][_0x136c43(0x125)](a0_0x46f2a7),await this[_0x136c43(0x12a)][_0x136c43(0x125)](a0_0x2425d2),await this[_0x136c43(0x12a)]['registerTool'](a0_0x5e8188),await this[_0x136c43(0x12a)]['registerTool'](a0_0x3cd03f),await this[_0x136c43(0x12a)]['registerTool'](a0_0x4da148),await this[_0x136c43(0x12a)]['registerTool'](a0_0x1ff97b),await this[_0x136c43(0x12a)][_0x136c43(0x125)](a0_0x20f41a),await this['toolsRegistry']['registerTool'](a0_0x410481),await this[_0x136c43(0x12a)]['registerTool'](a0_0x407e82),await this[_0x136c43(0x12a)]['registerTool'](a0_0x53853e),await this[_0x136c43(0x12a)]['registerTool'](a0_0x4c6c5f),await this['toolsRegistry'][_0x136c43(0x125)](a0_0x2feec9);if(this[_0x136c43(0x145)][_0x136c43(0x147)]?.['browser']?.[_0x136c43(0x152)]!==![])try{await this[_0x136c43(0x12a)]['registerTool'](a0_0x28b7e4),this[_0x136c43(0x159)]['info']('Browser\x20tool\x20registered\x20(requires\x20puppeteer)');}catch(_0x33bc7f){this[_0x136c43(0x159)]['warn']('Browser\x20tool\x20registration\x20skipped',{'reason':_0x33bc7f[_0x136c43(0x136)],'suggestion':_0x136c43(0x11e)});}const _0x4dc83f=this[_0x136c43(0x12a)][_0x136c43(0x13d)]('agentdelay');_0x4dc83f&&typeof _0x4dc83f['setAgentPool']===_0x136c43(0x134)&&_0x4dc83f[_0x136c43(0x126)](this[_0x136c43(0x12f)]);const _0x2c9ddd=this[_0x136c43(0x12a)][_0x136c43(0x13d)](_0x136c43(0x139));_0x2c9ddd&&typeof _0x2c9ddd[_0x136c43(0x126)]==='function'&&_0x2c9ddd['setAgentPool'](this['agentPool']);const _0x4517d8=this[_0x136c43(0x12a)][_0x136c43(0x13d)](_0x136c43(0x12b));_0x4517d8&&typeof _0x4517d8[_0x136c43(0x126)]===_0x136c43(0x134)&&_0x4517d8['setAgentPool'](this[_0x136c43(0x12f)]);_0x4517d8&&typeof _0x4517d8['setScheduler']==='function'&&_0x4517d8['setScheduler'](this[_0x136c43(0x171)]);const _0x3d9e84=this[_0x136c43(0x12a)]['getTool']('agentcommunication');_0x3d9e84&&this['logger'][_0x136c43(0x180)](_0x136c43(0x119));const _0x539540=this[_0x136c43(0x12a)][_0x136c43(0x13d)]('image-gen');_0x539540&&typeof _0x539540[_0x136c43(0x123)]==='function'&&(_0x539540[_0x136c43(0x123)](this['aiService']),this['logger']['info']('AIService\x20set\x20for\x20Image\x20Generation\x20Tool'));_0x539540&&typeof _0x539540['setAgentPool']===_0x136c43(0x134)&&(_0x539540['setAgentPool'](this['agentPool']),this['logger'][_0x136c43(0x180)](_0x136c43(0x15c)));const _0x32aed4=this[_0x136c43(0x12a)][_0x136c43(0x135)]();this['logger']['info']('Tools\x20initialized',{'toolCount':Object['keys'](_0x32aed4)['length'],'enabledTools':Object['keys'](_0x32aed4)[_0x136c43(0x14f)](_0x2f89bb=>_0x32aed4[_0x2f89bb]['capabilities'][_0x136c43(0x152)]),'registeredTools':this[_0x136c43(0x12a)]['listTools']()});if(this[_0x136c43(0x159)]['level']===_0x136c43(0x121))for(const [_0x34596a,_0x2972d3]of Object[_0x136c43(0x154)](_0x32aed4)){this[_0x136c43(0x159)]['debug'](_0x136c43(0x166)+_0x34596a+_0x136c43(0x16f),_0x2972d3['capabilities']);}}async['initializeInterfaces'](_0x3d4e8c){const _0x3243c4=a0_0xfa603b;this['logger']['info'](_0x3243c4(0x168));const _0x4e474a=this[_0x3243c4(0x145)][_0x3243c4(0x16c)]||{},_0x4558e1=process[_0x3243c4(0x155)][_0x3243c4(0x122)]||'cli';if(_0x4e474a['cli']?.['enabled']!==![]&&_0x4558e1!=='terminal'){this[_0x3243c4(0x159)][_0x3243c4(0x180)]('Loading\x20CLI\x20(readline)...');const {default:_0x7a68df}=await import(_0x3243c4(0x142)),_0x58a975=new _0x7a68df(this['orchestrator'],this[_0x3243c4(0x159)],_0x4e474a[_0x3243c4(0x13f)]||{});await _0x58a975['initialize'](),this[_0x3243c4(0x16c)][_0x3243c4(0x17d)](INTERFACE_TYPES['CLI'],_0x58a975),this['logger'][_0x3243c4(0x180)](_0x3243c4(0x16a));}_0x4558e1==='terminal'&&this[_0x3243c4(0x159)][_0x3243c4(0x180)]('Terminal\x20UI\x20mode:\x20Server-only\x20startup\x20(Terminal\x20UI\x20will\x20connect\x20as\x20WebSocket\x20client)');if(_0x4e474a[_0x3243c4(0x17f)]?.[_0x3243c4(0x152)]!==![]){const _0x2253db=new a0_0x2a8548(this['orchestrator'],this['logger'],_0x4e474a['web']||{'port':0x1f90,'host':'localhost'});_0x2253db[_0x3243c4(0x12a)]=this[_0x3243c4(0x12a)],_0x2253db['setApiKeyManager'](this[_0x3243c4(0x164)]),await _0x2253db['initialize'](),this[_0x3243c4(0x16c)]['set'](INTERFACE_TYPES['WEB'],_0x2253db),this['orchestrator']['webServer']=_0x2253db,this[_0x3243c4(0x129)]['setWebSocketManager'](_0x2253db),this[_0x3243c4(0x128)]['webSocketManager']=_0x2253db,this['agentScheduler']['start'](),this[_0x3243c4(0x159)]['info']('Agent\x20Scheduler\x20started\x20with\x20WebSocket\x20integration'),global[_0x3243c4(0x14b)]=_0x2253db;const _0xd5e7f0=_0x2253db['getStatus']();this[_0x3243c4(0x159)][_0x3243c4(0x180)]('Web\x20interface\x20initialized',{'url':_0xd5e7f0[_0x3243c4(0x133)]}),console['log'](_0x3243c4(0x170)+_0xd5e7f0['url']),console[_0x3243c4(0x13a)](_0x3243c4(0x16e)+_0xd5e7f0['url']);}_0x4e474a['vscode']?.['enabled']===!![]&&this[_0x3243c4(0x159)]['info'](_0x3243c4(0x173));}[a0_0xfa603b(0x15a)](){const _0x5e1aa2=a0_0xfa603b;process['on'](_0x5e1aa2(0x12c),async()=>{const _0xb984f4=_0x5e1aa2;console['log'](_0xb984f4(0x14e)),await this['shutdown']();}),process['on'](_0x5e1aa2(0x130),async()=>{const _0x5dc466=_0x5e1aa2;console['log'](_0x5dc466(0x162)),await this['shutdown']();}),process['on']('uncaughtException',async _0x12a12f=>{const _0x13bd15=_0x5e1aa2;console['error'](_0x13bd15(0x13e),_0x12a12f),this['logger']&&this['logger']['error'](_0x13bd15(0x15b),{'error':_0x12a12f['message'],'stack':_0x12a12f['stack']}),await this[_0x13bd15(0x132)](),process['exit'](0x1);}),process['on']('unhandledRejection',async(_0x5f3c74,_0x9b4943)=>{const _0x3970da=_0x5e1aa2;console['error']('❌\x20Unhandled\x20promise\x20rejection:',_0x5f3c74),this['logger']&&this[_0x3970da(0x159)][_0x3970da(0x172)](_0x3970da(0x144),{'reason':_0x5f3c74?.[_0x3970da(0x136)]||_0x5f3c74,'promise':_0x9b4943['toString']()}),await this['shutdown'](),process[_0x3970da(0x17b)](0x1);});}async[a0_0xfa603b(0x132)](){const _0x52ad7f=a0_0xfa603b;if(this[_0x52ad7f(0x16d)])return;this['isShuttingDown']=!![];try{console[_0x52ad7f(0x13a)](_0x52ad7f(0x11c));this[_0x52ad7f(0x159)]&&this['logger']['info'](_0x52ad7f(0x14a));for(const [_0x2b6c13,_0x17bbdc]of this[_0x52ad7f(0x16c)]){try{_0x17bbdc['shutdown']&&await _0x17bbdc[_0x52ad7f(0x132)](),this['logger']?.['info'](_0x2b6c13+_0x52ad7f(0x176));}catch(_0x133338){console['error'](_0x52ad7f(0x140)+_0x2b6c13+'\x20interface:',_0x133338[_0x52ad7f(0x136)]);}}this[_0x52ad7f(0x14d)]&&(await this['asyncToolManager'][_0x52ad7f(0x132)](),this[_0x52ad7f(0x159)]?.[_0x52ad7f(0x180)]('Async\x20tool\x20manager\x20shutdown\x20complete')),this[_0x52ad7f(0x138)]&&(await this['orchestrator']['shutdown'](),this[_0x52ad7f(0x159)]?.['info']('Orchestrator\x20shutdown\x20complete')),this[_0x52ad7f(0x161)]&&this['configManager'][_0x52ad7f(0x12e)](),this[_0x52ad7f(0x159)]&&await this[_0x52ad7f(0x159)][_0x52ad7f(0x158)](),console[_0x52ad7f(0x13a)](_0x52ad7f(0x14c));}catch(_0x587422){console[_0x52ad7f(0x172)]('❌\x20Error\x20during\x20shutdown:',_0x587422[_0x52ad7f(0x136)]);}finally{process['exit'](0x0);}}[a0_0xfa603b(0x177)](){const _0x8a53ce=a0_0xfa603b;return{'version':SYSTEM_VERSION,'uptime':process['uptime'](),'memoryUsage':process['memoryUsage'](),'interfaces':Array['from'](this[_0x8a53ce(0x16c)]['keys']()),'isShuttingDown':this['isShuttingDown']};}}async function main(){const _0x58341a=a0_0xfa603b,_0x1e5961=new LoxiaApplication(),_0xfd6876=process['argv']['slice'](0x2),_0x4d01bc={'projectDir':process['cwd'](),'watchConfig':_0xfd6876[_0x58341a(0x174)]('--watch-config'),'configPaths':[]},_0x28e2a4=_0xfd6876['indexOf']('--config');return _0x28e2a4!==-0x1&&_0xfd6876[_0x28e2a4+0x1]&&_0x4d01bc['configPaths']['push'](_0xfd6876[_0x28e2a4+0x1]),await _0x1e5961[_0x58341a(0x149)](_0x4d01bc),_0x1e5961;}const __filename=fileURLToPath(import.meta.url);process[a0_0xfa603b(0x15f)][0x1]===__filename&&(console['log']('🚀\x20Starting\x20Loxia\x20Autopilot\x20One...'),main()[a0_0xfa603b(0x17a)](_0x1810ab=>{const _0xf63b35=a0_0xfa603b;console[_0xf63b35(0x172)](_0xf63b35(0x11f),_0x1810ab[_0xf63b35(0x136)]),console['error']('Stack\x20trace:',_0x1810ab[_0xf63b35(0x11b)]),process['exit'](0x1);}));export{LoxiaApplication,main};
|