@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/core/orchestrator.js
CHANGED
|
@@ -1,548 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Orchestrator - Central coordination hub for Loxia AI Agents System
|
|
3
|
-
*
|
|
4
|
-
* Purpose:
|
|
5
|
-
* - Unified request/response handling for all interfaces (CLI, Web, VSCode)
|
|
6
|
-
* - Agent lifecycle management
|
|
7
|
-
* - Session management
|
|
8
|
-
* - Error handling and response formatting
|
|
9
|
-
* - Interface-agnostic communication protocol
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
INTERFACE_TYPES,
|
|
14
|
-
AGENT_TYPES,
|
|
15
|
-
AGENT_STATUS,
|
|
16
|
-
MESSAGE_MODES,
|
|
17
|
-
ORCHESTRATOR_ACTIONS,
|
|
18
|
-
SYSTEM_DEFAULTS
|
|
19
|
-
} from '../utilities/constants.js';
|
|
20
|
-
|
|
21
|
-
class Orchestrator {
|
|
22
|
-
constructor(config, logger, agentPool, messageProcessor, aiService, stateManager) {
|
|
23
|
-
this.config = config;
|
|
24
|
-
this.logger = logger;
|
|
25
|
-
this.agentPool = agentPool;
|
|
26
|
-
this.messageProcessor = messageProcessor;
|
|
27
|
-
this.aiService = aiService;
|
|
28
|
-
this.stateManager = stateManager;
|
|
29
|
-
|
|
30
|
-
this.activeSessions = new Map();
|
|
31
|
-
this.requestHandlers = new Map();
|
|
32
|
-
|
|
33
|
-
this._initializeRequestHandlers();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Main entry point for all requests from client interfaces
|
|
38
|
-
* @param {Object} request - Request object with interface, sessionId, action, payload, projectDir, user
|
|
39
|
-
* @returns {Promise<Object>} Response object with success, data, error, metadata
|
|
40
|
-
*/
|
|
41
|
-
async processRequest(request) {
|
|
42
|
-
const startTime = Date.now();
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
this._validateRequest(request);
|
|
46
|
-
|
|
47
|
-
const handler = this.requestHandlers.get(request.action);
|
|
48
|
-
if (!handler) {
|
|
49
|
-
this.logger.error(`Unknown action received: ${request.action}`, {
|
|
50
|
-
availableActions: Array.from(this.requestHandlers.keys()),
|
|
51
|
-
requestAction: request.action,
|
|
52
|
-
actionType: typeof request.action
|
|
53
|
-
});
|
|
54
|
-
throw new Error(`Unknown action: ${request.action}`);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Ensure session exists
|
|
58
|
-
await this._ensureSession(request.sessionId, request.projectDir);
|
|
59
|
-
|
|
60
|
-
// Execute request handler
|
|
61
|
-
const result = await handler.call(this, request);
|
|
62
|
-
|
|
63
|
-
// Generate response metadata
|
|
64
|
-
const metadata = {
|
|
65
|
-
timestamp: new Date().toISOString(),
|
|
66
|
-
executionTime: Date.now() - startTime,
|
|
67
|
-
sessionId: request.sessionId,
|
|
68
|
-
interface: request.interface
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
success: true,
|
|
73
|
-
data: result,
|
|
74
|
-
error: null,
|
|
75
|
-
metadata
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
} catch (error) {
|
|
79
|
-
this.logger.error(`Request processing failed: ${error.message}`, {
|
|
80
|
-
request: this._sanitizeRequestForLogging(request),
|
|
81
|
-
error: error.stack
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
success: false,
|
|
86
|
-
data: null,
|
|
87
|
-
error: error.message,
|
|
88
|
-
metadata: {
|
|
89
|
-
timestamp: new Date().toISOString(),
|
|
90
|
-
executionTime: Date.now() - startTime,
|
|
91
|
-
sessionId: request.sessionId,
|
|
92
|
-
interface: request.interface
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Create a new agent with specified configuration
|
|
100
|
-
* @param {string} systemPrompt - Agent's system prompt
|
|
101
|
-
* @param {string} model - Preferred LLM model
|
|
102
|
-
* @param {Object} options - Additional agent configuration
|
|
103
|
-
* @returns {Promise<Object>} Created agent object
|
|
104
|
-
*/
|
|
105
|
-
async createAgent(systemPrompt, model, options = {}) {
|
|
106
|
-
const agentConfig = {
|
|
107
|
-
name: options.name || `Agent-${Date.now()}`,
|
|
108
|
-
type: options.type || AGENT_TYPES.USER_CREATED,
|
|
109
|
-
systemPrompt,
|
|
110
|
-
preferredModel: model,
|
|
111
|
-
capabilities: options.capabilities || [],
|
|
112
|
-
...options
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const agent = await this.agentPool.createAgent(agentConfig);
|
|
116
|
-
|
|
117
|
-
this.logger.info(`Agent created: ${agent.id}`, {
|
|
118
|
-
agentId: agent.id,
|
|
119
|
-
name: agent.name,
|
|
120
|
-
model: agent.preferredModel
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
return agent;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Route message to specified agent
|
|
128
|
-
* @param {string} agentId - Target agent ID
|
|
129
|
-
* @param {string} message - Message content
|
|
130
|
-
* @param {Object} context - Message context (projectDir, contextReferences, etc.)
|
|
131
|
-
* @returns {Promise<Object>} Agent response
|
|
132
|
-
*/
|
|
133
|
-
async routeToAgent(agentId, message, context = {}) {
|
|
134
|
-
const agent = await this.agentPool.getAgent(agentId);
|
|
135
|
-
if (!agent) {
|
|
136
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Check if agent is paused
|
|
140
|
-
if (agent.status === AGENT_STATUS.PAUSED && agent.pausedUntil && new Date() < new Date(agent.pausedUntil)) {
|
|
141
|
-
throw new Error(`Agent ${agentId} is paused until ${agent.pausedUntil}`);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Process message through message processor (NEW ARCHITECTURE: just queues message)
|
|
145
|
-
const result = await this.messageProcessor.processMessage(agentId, message, context);
|
|
146
|
-
|
|
147
|
-
// NEW ARCHITECTURE: MessageProcessor just queues messages, actual processing happens in AgentScheduler
|
|
148
|
-
// Return immediate queuing confirmation to UI
|
|
149
|
-
if (result.success) {
|
|
150
|
-
const response = {
|
|
151
|
-
success: true,
|
|
152
|
-
data: {
|
|
153
|
-
message: `Message queued for agent processing`,
|
|
154
|
-
agentId: result.agentId,
|
|
155
|
-
queuedAt: result.queuedAt,
|
|
156
|
-
status: 'queued',
|
|
157
|
-
// Legacy fields for backward compatibility
|
|
158
|
-
toolResults: [],
|
|
159
|
-
agentRedirects: [],
|
|
160
|
-
currentModel: agent.currentModel
|
|
161
|
-
},
|
|
162
|
-
processingId: `queued-${Date.now()}`
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
this.logger.info(`Message queued for agent: ${agentId}`, {
|
|
166
|
-
agentName: agent.name,
|
|
167
|
-
messageLength: message.length,
|
|
168
|
-
sessionId: context.sessionId
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
return response;
|
|
172
|
-
} else {
|
|
173
|
-
return result; // Return error response as-is
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Get current session state
|
|
179
|
-
* @param {string} sessionId - Session identifier
|
|
180
|
-
* @returns {Promise<Object>} Session state object
|
|
181
|
-
*/
|
|
182
|
-
async getSessionState(sessionId) {
|
|
183
|
-
const session = this.activeSessions.get(sessionId);
|
|
184
|
-
if (!session) {
|
|
185
|
-
throw new Error(`Session not found: ${sessionId}`);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const agents = await this.agentPool.listActiveAgents();
|
|
189
|
-
const projectState = await this.stateManager.getProjectState(session.projectDir);
|
|
190
|
-
|
|
191
|
-
return {
|
|
192
|
-
sessionId,
|
|
193
|
-
projectDir: session.projectDir,
|
|
194
|
-
createdAt: session.createdAt,
|
|
195
|
-
lastActivity: session.lastActivity,
|
|
196
|
-
agents: agents, // Return full agent objects since listActiveAgents already filters appropriately
|
|
197
|
-
projectState
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Shutdown orchestrator and cleanup resources
|
|
203
|
-
* @returns {Promise<void>}
|
|
204
|
-
*/
|
|
205
|
-
async shutdown() {
|
|
206
|
-
this.logger.info('Shutting down orchestrator...');
|
|
207
|
-
|
|
208
|
-
// Save all agent states
|
|
209
|
-
const agents = await this.agentPool.listActiveAgents();
|
|
210
|
-
for (const agent of agents) {
|
|
211
|
-
await this.stateManager.persistAgentState(agent.id);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// Clear active sessions
|
|
215
|
-
this.activeSessions.clear();
|
|
216
|
-
|
|
217
|
-
this.logger.info('Orchestrator shutdown complete');
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Initialize request handlers for different actions
|
|
222
|
-
* @private
|
|
223
|
-
*/
|
|
224
|
-
_initializeRequestHandlers() {
|
|
225
|
-
this.requestHandlers.set(ORCHESTRATOR_ACTIONS.CREATE_AGENT, this._handleCreateAgent.bind(this));
|
|
226
|
-
this.requestHandlers.set(ORCHESTRATOR_ACTIONS.UPDATE_AGENT, this._handleUpdateAgent.bind(this));
|
|
227
|
-
this.requestHandlers.set(ORCHESTRATOR_ACTIONS.DELETE_AGENT, this._handleDeleteAgent.bind(this));
|
|
228
|
-
this.requestHandlers.set(ORCHESTRATOR_ACTIONS.SEND_MESSAGE, this._handleSendMessage.bind(this));
|
|
229
|
-
this.requestHandlers.set(ORCHESTRATOR_ACTIONS.LIST_AGENTS, this._handleListAgents.bind(this));
|
|
230
|
-
this.requestHandlers.set(ORCHESTRATOR_ACTIONS.RESUME_SESSION, this._handleResumeSession.bind(this));
|
|
231
|
-
this.requestHandlers.set(ORCHESTRATOR_ACTIONS.GET_SESSION_STATE, this._handleGetSessionState.bind(this));
|
|
232
|
-
this.requestHandlers.set(ORCHESTRATOR_ACTIONS.PAUSE_AGENT, this._handlePauseAgent.bind(this));
|
|
233
|
-
this.requestHandlers.set(ORCHESTRATOR_ACTIONS.RESUME_AGENT, this._handleResumeAgent.bind(this));
|
|
234
|
-
this.requestHandlers.set(ORCHESTRATOR_ACTIONS.SWITCH_MODEL, this._handleSwitchModel.bind(this));
|
|
235
|
-
this.requestHandlers.set(ORCHESTRATOR_ACTIONS.GET_AGENT_STATUS, this._handleGetAgentStatus.bind(this));
|
|
236
|
-
this.requestHandlers.set(ORCHESTRATOR_ACTIONS.GET_AGENT_CONVERSATIONS, this._handleGetAgentConversations.bind(this));
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Handle create agent requests
|
|
241
|
-
* @private
|
|
242
|
-
*/
|
|
243
|
-
async _handleCreateAgent(request) {
|
|
244
|
-
const { name, systemPrompt, model, capabilities, dynamicModelRouting, platformProvided, directoryAccess } = request.payload;
|
|
245
|
-
|
|
246
|
-
this.logger.info('Creating agent with payload', {
|
|
247
|
-
name,
|
|
248
|
-
model,
|
|
249
|
-
dynamicModelRouting,
|
|
250
|
-
platformProvided,
|
|
251
|
-
capabilities,
|
|
252
|
-
directoryAccess: directoryAccess ? {
|
|
253
|
-
workingDirectory: directoryAccess.workingDirectory,
|
|
254
|
-
readOnlyDirectories: directoryAccess.readOnlyDirectories?.length || 0,
|
|
255
|
-
writeEnabledDirectories: directoryAccess.writeEnabledDirectories?.length || 0,
|
|
256
|
-
restrictToProject: directoryAccess.restrictToProject
|
|
257
|
-
} : null
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
return await this.createAgent(systemPrompt, model, {
|
|
261
|
-
name,
|
|
262
|
-
capabilities,
|
|
263
|
-
dynamicModelRouting,
|
|
264
|
-
platformProvided,
|
|
265
|
-
directoryAccess,
|
|
266
|
-
sessionId: request.sessionId,
|
|
267
|
-
projectDir: request.projectDir
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Handle update agent requests
|
|
273
|
-
* @private
|
|
274
|
-
*/
|
|
275
|
-
async _handleUpdateAgent(request) {
|
|
276
|
-
const { agentId, updates } = request.payload;
|
|
277
|
-
|
|
278
|
-
if (!agentId) {
|
|
279
|
-
throw new Error('Agent ID is required for update');
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (!updates || typeof updates !== 'object') {
|
|
283
|
-
throw new Error('Updates object is required');
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// Get agent before update to ensure it exists
|
|
287
|
-
const agent = await this.agentPool.getAgent(agentId);
|
|
288
|
-
if (!agent) {
|
|
289
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
this.logger.info('Updating agent with payload', {
|
|
293
|
-
agentId,
|
|
294
|
-
updates,
|
|
295
|
-
agentName: agent.name
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
// Update the agent through the agent pool
|
|
299
|
-
// Include sessionId in updates to maintain API key context
|
|
300
|
-
const updatesWithSession = {
|
|
301
|
-
...updates,
|
|
302
|
-
sessionId: request.sessionId // Ensure current session context is preserved
|
|
303
|
-
};
|
|
304
|
-
const updatedAgent = await this.agentPool.updateAgent(agentId, updatesWithSession);
|
|
305
|
-
|
|
306
|
-
this.logger.info(`Agent updated: ${agentId}`, {
|
|
307
|
-
agentName: updatedAgent.name,
|
|
308
|
-
newMode: updatedAgent.mode,
|
|
309
|
-
sessionId: request.sessionId
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
return updatedAgent;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* Handle delete agent requests
|
|
317
|
-
* @private
|
|
318
|
-
*/
|
|
319
|
-
async _handleDeleteAgent(request) {
|
|
320
|
-
const { agentId } = request.payload;
|
|
321
|
-
|
|
322
|
-
if (!agentId) {
|
|
323
|
-
throw new Error('Agent ID is required for deletion');
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
// Get agent before deletion to return info
|
|
327
|
-
const agent = await this.agentPool.getAgent(agentId);
|
|
328
|
-
if (!agent) {
|
|
329
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// Delete the agent
|
|
333
|
-
const result = await this.agentPool.deleteAgent(agentId);
|
|
334
|
-
|
|
335
|
-
this.logger.info(`Agent deleted: ${agentId}`, {
|
|
336
|
-
agentName: agent.name,
|
|
337
|
-
sessionId: request.sessionId
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
return {
|
|
341
|
-
success: true,
|
|
342
|
-
deletedAgent: {
|
|
343
|
-
id: agent.id,
|
|
344
|
-
name: agent.name
|
|
345
|
-
},
|
|
346
|
-
...result
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Handle send message requests
|
|
352
|
-
* @private
|
|
353
|
-
*/
|
|
354
|
-
async _handleSendMessage(request) {
|
|
355
|
-
const { agentId, message, mode, contextReferences, apiKey, customApiKeys } = request.payload;
|
|
356
|
-
|
|
357
|
-
const context = {
|
|
358
|
-
projectDir: request.projectDir,
|
|
359
|
-
sessionId: request.sessionId,
|
|
360
|
-
interface: request.interface,
|
|
361
|
-
mode: mode || MESSAGE_MODES.CHAT,
|
|
362
|
-
contextReferences: contextReferences || [],
|
|
363
|
-
apiKey: apiKey, // Pass Loxia API key through context
|
|
364
|
-
customApiKeys: customApiKeys || {} // Pass custom API keys through context
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
return await this.routeToAgent(agentId, message, context);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Handle list agents requests
|
|
372
|
-
* @private
|
|
373
|
-
*/
|
|
374
|
-
async _handleListAgents(request) {
|
|
375
|
-
return await this.agentPool.listActiveAgents();
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Handle resume session requests
|
|
380
|
-
* @private
|
|
381
|
-
*/
|
|
382
|
-
async _handleResumeSession(request) {
|
|
383
|
-
const { projectDir } = request.payload;
|
|
384
|
-
|
|
385
|
-
const resumedState = await this.stateManager.resumeProject(projectDir);
|
|
386
|
-
|
|
387
|
-
// Restore agents to agent pool
|
|
388
|
-
for (const agent of resumedState.agents) {
|
|
389
|
-
await this.agentPool.restoreAgent(agent);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
return resumedState;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* Handle get session state requests
|
|
397
|
-
* @private
|
|
398
|
-
*/
|
|
399
|
-
async _handleGetSessionState(request) {
|
|
400
|
-
return await this.getSessionState(request.sessionId);
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* Handle pause agent requests
|
|
405
|
-
* @private
|
|
406
|
-
*/
|
|
407
|
-
async _handlePauseAgent(request) {
|
|
408
|
-
const { agentId, duration, reason } = request.payload;
|
|
409
|
-
|
|
410
|
-
return await this.agentPool.pauseAgent(agentId, duration, reason);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Handle resume agent requests
|
|
415
|
-
* @private
|
|
416
|
-
*/
|
|
417
|
-
async _handleResumeAgent(request) {
|
|
418
|
-
const { agentId } = request.payload;
|
|
419
|
-
|
|
420
|
-
return await this.agentPool.resumeAgent(agentId);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
* Handle switch model requests
|
|
425
|
-
* @private
|
|
426
|
-
*/
|
|
427
|
-
async _handleSwitchModel(request) {
|
|
428
|
-
const { agentId, newModel } = request.payload;
|
|
429
|
-
|
|
430
|
-
const agent = await this.agentPool.getAgent(agentId);
|
|
431
|
-
if (!agent) {
|
|
432
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
// Switch model via AI service conversation manager
|
|
436
|
-
return await this.aiService.switchAgentModel(agentId, newModel);
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
* Handle get agent status requests
|
|
441
|
-
* @private
|
|
442
|
-
*/
|
|
443
|
-
async _handleGetAgentStatus(request) {
|
|
444
|
-
const { agentId } = request.payload;
|
|
445
|
-
|
|
446
|
-
const agent = await this.agentPool.getAgent(agentId);
|
|
447
|
-
if (!agent) {
|
|
448
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
return {
|
|
452
|
-
id: agent.id,
|
|
453
|
-
name: agent.name,
|
|
454
|
-
status: agent.status,
|
|
455
|
-
mode: agent.mode,
|
|
456
|
-
modeState: agent.modeState,
|
|
457
|
-
currentModel: agent.currentModel,
|
|
458
|
-
lastActivity: agent.lastActivity,
|
|
459
|
-
isPaused: agent.status === 'paused',
|
|
460
|
-
pausedUntil: agent.pausedUntil
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
* Handle get agent conversations requests
|
|
466
|
-
* @private
|
|
467
|
-
*/
|
|
468
|
-
async _handleGetAgentConversations(request) {
|
|
469
|
-
const { agentId } = request.payload;
|
|
470
|
-
|
|
471
|
-
const agent = await this.agentPool.getAgent(agentId);
|
|
472
|
-
if (!agent) {
|
|
473
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
return {
|
|
477
|
-
agentId: agent.id,
|
|
478
|
-
conversations: agent.conversations,
|
|
479
|
-
messageCount: agent.conversations?.full?.messages?.length || 0
|
|
480
|
-
};
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
/**
|
|
484
|
-
* Validate request format
|
|
485
|
-
* @private
|
|
486
|
-
*/
|
|
487
|
-
_validateRequest(request) {
|
|
488
|
-
if (!request || typeof request !== 'object') {
|
|
489
|
-
throw new Error('Invalid request format');
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
const requiredFields = ['interface', 'sessionId', 'action', 'payload'];
|
|
493
|
-
for (const field of requiredFields) {
|
|
494
|
-
if (!(field in request)) {
|
|
495
|
-
throw new Error(`Missing required field: ${field}`);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
const validInterfaces = Object.values(INTERFACE_TYPES);
|
|
500
|
-
if (!validInterfaces.includes(request.interface)) {
|
|
501
|
-
throw new Error(`Invalid interface: ${request.interface}`);
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
/**
|
|
506
|
-
* Ensure session exists, create if needed
|
|
507
|
-
* @private
|
|
508
|
-
*/
|
|
509
|
-
async _ensureSession(sessionId, projectDir) {
|
|
510
|
-
if (!this.activeSessions.has(sessionId)) {
|
|
511
|
-
const session = {
|
|
512
|
-
id: sessionId,
|
|
513
|
-
projectDir: projectDir || process.cwd(),
|
|
514
|
-
createdAt: new Date().toISOString(),
|
|
515
|
-
lastActivity: new Date().toISOString()
|
|
516
|
-
};
|
|
517
|
-
|
|
518
|
-
this.activeSessions.set(sessionId, session);
|
|
519
|
-
this.logger.info(`Session created: ${sessionId}`, { projectDir: session.projectDir });
|
|
520
|
-
} else {
|
|
521
|
-
// Update last activity
|
|
522
|
-
const session = this.activeSessions.get(sessionId);
|
|
523
|
-
session.lastActivity = new Date().toISOString();
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
/**
|
|
528
|
-
* Sanitize request for logging (remove sensitive data)
|
|
529
|
-
* @private
|
|
530
|
-
*/
|
|
531
|
-
_sanitizeRequestForLogging(request) {
|
|
532
|
-
const sanitized = { ...request };
|
|
533
|
-
|
|
534
|
-
// Remove potentially sensitive user data
|
|
535
|
-
if (sanitized.user) {
|
|
536
|
-
sanitized.user = { id: sanitized.user.id };
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
// Truncate large message content
|
|
540
|
-
if (sanitized.payload && sanitized.payload.message && sanitized.payload.message.length > 500) {
|
|
541
|
-
sanitized.payload.message = sanitized.payload.message.substring(0, 500) + '... [truncated]';
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
return sanitized;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
export default Orchestrator;
|
|
1
|
+
function a0_0x25f6(){const _0x2b9b8f=['lI4UifT0CNvUy2f0zwrD','CxvLDwvKqxq','u0vorf9nrvntquDf','Aw5JBhvKzxm','B2jQzwn0','C2H1DgrVD24','x2vUC3vYzvnLC3nPB24','C3rHDgvnyw5Hz2vY','r0vux1nfu1njt05Fu1rbveu','ChjVAMvJDerPCG','vxbKyxrPBMCGywDLBNqGD2L0AcbWyxLSB2fK','Bw9Kzvn0yxrL','vxbKyxrLCYbVyMPLy3qGAxmGCMvXDwLYzwq','y3DK','C2v0','C3rHDhvZ','ywDLBNrZ','x2HHBMrSzvjLC3vTzvnLC3nPB24','mtK2otG1nMXfq094Ca','CgvYC2LZDefNzw50u3rHDgu','x2HHBMrSzvnLBMrnzxnZywDL','qwDLBNqGDxbKyxrLzdOG','Bw9Kzq','twvZC2fNzsbXDwv1zwqGzM9YigfNzw50ihbYB2nLC3nPBMC','CxvLDwvKlq','qwDLBNqT','x2HHBMrSzuDLDfnLC3nPB25tDgf0zq','uKvtvu1fx0fhru5u','BwvZC2fNzq','zNjVBq','m3rfugrRtG','x2HHBMrSzuDLDefNzw50q29UDMvYC2f0Aw9UCW','CMvZDhjPy3ruB1bYB2PLy3q','x2LUAxrPywXPEMvszxf1zxn0sgfUzgXLCNm','twvZC2fNzsbXDwv1zwqGzM9YigfNzw50oIa','mtG2nJq5mLjUu3DODG','ChjLzMvYCMvKtw9KzwW','D29YA2LUz0rPCMvJDg9YEq','sw52ywXPzcbYzxf1zxn0igzVCM1HDa','BgLZDefJDgL2zufNzw50CW','x3nHBML0AxPLuMvXDwvZDezVCKXVz2DPBMC','Aw5MBW','C2vZC2LVBKLK','zgvSzxrLqwDLBNq','ywLtzxj2AwnL','y3jLyxrLzef0','x2HHBMrSzvvWzgf0zufNzw50','u2vZC2LVBIbUB3qGzM91BMq6ia','mtGWmte3yKrIrfHY','x2HHBMrSzuDLDefNzw50u3rHDhvZ','ywn0AxzLu2vZC2LVBNm','r0vux0fhru5ux1nuqvrvuW','mtjgDeXgCg8','BwvZC2fNzxm','Cgf5Bg9Hza','yMLUza','C3rHy2S','y3vYCMvUDe1VzgvS','CxvLDwvK','mZjVENHOCei','x2HHBMrSzuXPC3rbz2vUDhm','BwvZC2fNzvbYB2nLC3nVCG','CMvXDwvZDeHHBMrSzxjZ','x2HHBMrSzurLBgv0zufNzw50','uKvtvu1fx1nfu1njt04','mty2otu5mMDcvLj1zq','u1Djvenix01prevm','qwDLBNqG','y29UDMvYC2f0Aw9UCW','vvbeqvrfx0fhru5u','sw52ywXPzcbPBNrLCMzHy2u6ia','qwDLBNqGzgvSzxrLzdOG','x2HHBMrSzunYzwf0zufNzw50','uefvu0vFquDftLq','BMfTzq','y2fWywjPBgL0AwvZ','mJqYotaYnZDQCNPlDgm','ywn0Aw9U','BM93','ywDLBNrqB29S','ntm5mZq3nxHtCeX3ra','C3vIC3rYAw5N','u2H1DhrPBMCGzg93BIbVCMnOzxn0CMf0B3iUlI4','mvLKB29LAq','BgfZDefJDgL2Axr5','qwDLBNqGBM90igzVDw5KoIa','y29UzMLN','z2v0qwDLBNq','x2HHBMrSzvjLC3vTzufNzw50','CMvZDw1LuhjVAMvJDa','CM91DgvuB0fNzw50','vw5RBM93BIbHy3rPB24GCMvJzwL2zwq6ia','mtb2rM5IDKS','x2HHBMrSzvbHDxnLqwDLBNq','qwDLBNqGy3jLyxrLzdOG','x2HHBMrSzvn3AxrJAe1VzgvS','DxnLCG','z2v0','y3jLyxrLqwDLBNq','A2v5CW','DMfSDwvZ','Aw50zxjMywnL','x3zHBgLKyxrLuMvXDwvZDa','mtyXnJmWrKHZu3nn','CMvHze9UBhLeAxjLy3rVCMLLCW','BgvUz3rO','Bg9Nz2vY','t3jJAgvZDhjHDg9YihnODxrKB3DUignVBxbSzxrL','q3jLyxrPBMCGywDLBNqGD2L0AcbWyxLSB2fK'];a0_0x25f6=function(){return _0x2b9b8f;};return a0_0x25f6();}const a0_0x5f5498=a0_0x432e;(function(_0x362002,_0x46818e){const _0x6705cf=a0_0x432e,_0x11dc38=_0x362002();while(!![]){try{const _0x6e85c1=-parseInt(_0x6705cf(0x205))/0x1*(parseInt(_0x6705cf(0x1f3))/0x2)+parseInt(_0x6705cf(0x1d0))/0x3*(parseInt(_0x6705cf(0x231))/0x4)+-parseInt(_0x6705cf(0x202))/0x5+-parseInt(_0x6705cf(0x1d5))/0x6+-parseInt(_0x6705cf(0x219))/0x7*(-parseInt(_0x6705cf(0x1ed))/0x8)+parseInt(_0x6705cf(0x1e2))/0x9*(-parseInt(_0x6705cf(0x20e))/0xa)+-parseInt(_0x6705cf(0x1fe))/0xb*(-parseInt(_0x6705cf(0x1e6))/0xc);if(_0x6e85c1===_0x46818e)break;else _0x11dc38['push'](_0x11dc38['shift']());}catch(_0x30cad5){_0x11dc38['push'](_0x11dc38['shift']());}}}(a0_0x25f6,0x85e5d));import{INTERFACE_TYPES,AGENT_TYPES,AGENT_STATUS,MESSAGE_MODES,ORCHESTRATOR_ACTIONS,SYSTEM_DEFAULTS}from'../utilities/constants.js';class Orchestrator{constructor(_0x39cfce,_0x3dc7ab,_0x3ba5f7,_0xca5152,_0x1ff0ca,_0x27ed78){const _0x5cad23=a0_0x432e;this[_0x5cad23(0x208)]=_0x39cfce,this['logger']=_0x3dc7ab,this[_0x5cad23(0x201)]=_0x3ba5f7,this[_0x5cad23(0x1ef)]=_0xca5152,this[_0x5cad23(0x1de)]=_0x1ff0ca,this['stateManager']=_0x27ed78,this[_0x5cad23(0x1e4)]=new Map(),this['requestHandlers']=new Map(),this['_initializeRequestHandlers']();}async['processRequest'](_0x177db8){const _0x5947f1=a0_0x432e,_0x378cfb=Date['now']();try{this[_0x5947f1(0x218)](_0x177db8);const _0x2318d0=this[_0x5947f1(0x1f0)]['get'](_0x177db8[_0x5947f1(0x1ff)]);if(!_0x2318d0){this['logger']['error'](_0x5947f1(0x20d)+_0x177db8[_0x5947f1(0x1ff)],{'availableActions':Array[_0x5947f1(0x1cf)](this[_0x5947f1(0x1f0)][_0x5947f1(0x215)]()),'requestAction':_0x177db8['action'],'actionType':typeof _0x177db8['action']});throw new Error('Unknown\x20action:\x20'+_0x177db8[_0x5947f1(0x1ff)]);}await this['_ensureSession'](_0x177db8[_0x5947f1(0x1dc)],_0x177db8['projectDir']);const _0x1de17b=await _0x2318d0['call'](this,_0x177db8),_0x276904={'timestamp':new Date()['toISOString'](),'executionTime':Date['now']()-_0x378cfb,'sessionId':_0x177db8[_0x5947f1(0x1dc)],'interface':_0x177db8['interface']};return{'success':!![],'data':_0x1de17b,'error':null,'metadata':_0x276904};}catch(_0x2c675c){return this[_0x5947f1(0x21c)]['error']('Request\x20processing\x20failed:\x20'+_0x2c675c[_0x5947f1(0x23b)],{'request':this[_0x5947f1(0x1da)](_0x177db8),'error':_0x2c675c[_0x5947f1(0x1ea)]}),{'success':![],'data':null,'error':_0x2c675c['message'],'metadata':{'timestamp':new Date()['toISOString'](),'executionTime':Date[_0x5947f1(0x200)]()-_0x378cfb,'sessionId':_0x177db8[_0x5947f1(0x1dc)],'interface':_0x177db8[_0x5947f1(0x217)]}};}}async['createAgent'](_0x4c3aa4,_0x1ef9bb,_0x2749f8={}){const _0xb342e2=a0_0x432e,_0xa66d20={'name':_0x2749f8[_0xb342e2(0x1fc)]||_0xb342e2(0x238)+Date['now'](),'type':_0x2749f8['type']||AGENT_TYPES['USER_CREATED'],'systemPrompt':_0x4c3aa4,'preferredModel':_0x1ef9bb,'capabilities':_0x2749f8[_0xb342e2(0x1fd)]||[],..._0x2749f8},_0x971a74=await this['agentPool']['createAgent'](_0xa66d20);return this['logger'][_0xb342e2(0x1db)](_0xb342e2(0x210)+_0x971a74['id'],{'agentId':_0x971a74['id'],'name':_0x971a74['name'],'model':_0x971a74[_0xb342e2(0x1d6)]}),_0x971a74;}async[a0_0x5f5498(0x20c)](_0x576a7c,_0x18a7bd,_0x3b5b3d={}){const _0x459f38=a0_0x5f5498,_0x4369a0=await this['agentPool'][_0x459f38(0x209)](_0x576a7c);if(!_0x4369a0)throw new Error('Agent\x20not\x20found:\x20'+_0x576a7c);if(_0x4369a0[_0x459f38(0x22e)]===AGENT_STATUS['PAUSED']&&_0x4369a0['pausedUntil']&&new Date()<new Date(_0x4369a0['pausedUntil']))throw new Error(_0x459f38(0x1f5)+_0x576a7c+'\x20is\x20paused\x20until\x20'+_0x4369a0['pausedUntil']);const _0x4767e7=await this['messageProcessor']['processMessage'](_0x576a7c,_0x18a7bd,_0x3b5b3d);if(_0x4767e7['success']){const _0x4e0dd2={'success':!![],'data':{'message':_0x459f38(0x236),'agentId':_0x4767e7['agentId'],'queuedAt':_0x4767e7[_0x459f38(0x220)],'status':_0x459f38(0x1ec),'toolResults':[],'agentRedirects':[],'currentModel':_0x4369a0[_0x459f38(0x1eb)]},'processingId':_0x459f38(0x237)+Date[_0x459f38(0x200)]()};return this[_0x459f38(0x21c)][_0x459f38(0x1db)](_0x459f38(0x1d4)+_0x576a7c,{'agentName':_0x4369a0[_0x459f38(0x1fc)],'messageLength':_0x18a7bd[_0x459f38(0x21b)],'sessionId':_0x3b5b3d['sessionId']}),_0x4e0dd2;}else return _0x4767e7;}async['getSessionState'](_0x3255ed){const _0x3cf0ca=a0_0x5f5498,_0x2f9436=this['activeSessions'][_0x3cf0ca(0x213)](_0x3255ed);if(!_0x2f9436)throw new Error(_0x3cf0ca(0x1e1)+_0x3255ed);const _0x1f983d=await this['agentPool']['listActiveAgents'](),_0xf4042b=await this['stateManager']['getProjectState'](_0x2f9436['projectDir']);return{'sessionId':_0x3255ed,'projectDir':_0x2f9436[_0x3cf0ca(0x228)],'createdAt':_0x2f9436[_0x3cf0ca(0x1df)],'lastActivity':_0x2f9436[_0x3cf0ca(0x206)],'agents':_0x1f983d,'projectState':_0xf4042b};}async[a0_0x5f5498(0x224)](){const _0x2c7873=a0_0x5f5498;this[_0x2c7873(0x21c)][_0x2c7873(0x1db)](_0x2c7873(0x204));const _0x498954=await this[_0x2c7873(0x201)][_0x2c7873(0x1d9)]();for(const _0x422804 of _0x498954){await this[_0x2c7873(0x226)][_0x2c7873(0x232)](_0x422804['id']);}this[_0x2c7873(0x1e4)]['clear'](),this[_0x2c7873(0x21c)][_0x2c7873(0x1db)](_0x2c7873(0x21d));}[a0_0x5f5498(0x1d3)](){const _0x12fc82=a0_0x5f5498;this[_0x12fc82(0x1f0)][_0x12fc82(0x22d)](ORCHESTRATOR_ACTIONS['CREATE_AGENT'],this['_handleCreateAgent'][_0x12fc82(0x1e9)](this)),this['requestHandlers'][_0x12fc82(0x22d)](ORCHESTRATOR_ACTIONS[_0x12fc82(0x1f7)],this['_handleUpdateAgent']['bind'](this)),this[_0x12fc82(0x1f0)][_0x12fc82(0x22d)](ORCHESTRATOR_ACTIONS['DELETE_AGENT'],this[_0x12fc82(0x1f1)]['bind'](this)),this['requestHandlers'][_0x12fc82(0x22d)](ORCHESTRATOR_ACTIONS[_0x12fc82(0x221)],this[_0x12fc82(0x233)][_0x12fc82(0x1e9)](this)),this[_0x12fc82(0x1f0)][_0x12fc82(0x22d)](ORCHESTRATOR_ACTIONS['LIST_AGENTS'],this[_0x12fc82(0x1ee)]['bind'](this)),this[_0x12fc82(0x1f0)][_0x12fc82(0x22d)](ORCHESTRATOR_ACTIONS[_0x12fc82(0x1f2)],this[_0x12fc82(0x230)]['bind'](this)),this['requestHandlers']['set'](ORCHESTRATOR_ACTIONS[_0x12fc82(0x227)],this[_0x12fc82(0x239)]['bind'](this)),this['requestHandlers']['set'](ORCHESTRATOR_ACTIONS[_0x12fc82(0x1fb)],this['_handlePauseAgent']['bind'](this)),this['requestHandlers']['set'](ORCHESTRATOR_ACTIONS[_0x12fc82(0x23a)],this[_0x12fc82(0x20a)]['bind'](this)),this[_0x12fc82(0x1f0)][_0x12fc82(0x22d)](ORCHESTRATOR_ACTIONS[_0x12fc82(0x1f4)],this[_0x12fc82(0x211)]['bind'](this)),this['requestHandlers']['set'](ORCHESTRATOR_ACTIONS[_0x12fc82(0x1e5)],this[_0x12fc82(0x1e3)]['bind'](this)),this['requestHandlers']['set'](ORCHESTRATOR_ACTIONS['GET_AGENT_CONVERSATIONS'],this[_0x12fc82(0x1d1)][_0x12fc82(0x1e9)](this));}async[a0_0x5f5498(0x1fa)](_0x5bcd5d){const _0x169062=a0_0x5f5498,{name:_0x3e7717,systemPrompt:_0x4e699a,model:_0x37655b,capabilities:_0x273649,dynamicModelRouting:_0x4570c8,platformProvided:_0x458a18,directoryAccess:_0x3a4cc2}=_0x5bcd5d['payload'];return this['logger']['info'](_0x169062(0x21e),{'name':_0x3e7717,'model':_0x37655b,'dynamicModelRouting':_0x4570c8,'platformProvided':_0x458a18,'capabilities':_0x273649,'directoryAccess':_0x3a4cc2?{'workingDirectory':_0x3a4cc2[_0x169062(0x1d7)],'readOnlyDirectories':_0x3a4cc2[_0x169062(0x21a)]?.[_0x169062(0x21b)]||0x0,'writeEnabledDirectories':_0x3a4cc2['writeEnabledDirectories']?.[_0x169062(0x21b)]||0x0,'restrictToProject':_0x3a4cc2[_0x169062(0x1d2)]}:null}),await this[_0x169062(0x214)](_0x4e699a,_0x37655b,{'name':_0x3e7717,'capabilities':_0x273649,'dynamicModelRouting':_0x4570c8,'platformProvided':_0x458a18,'directoryAccess':_0x3a4cc2,'sessionId':_0x5bcd5d[_0x169062(0x1dc)],'projectDir':_0x5bcd5d[_0x169062(0x228)]});}async[a0_0x5f5498(0x1e0)](_0x238032){const _0x581996=a0_0x5f5498,{agentId:_0x6ed0c7,updates:_0x49e182}=_0x238032['payload'];if(!_0x6ed0c7)throw new Error('Agent\x20ID\x20is\x20required\x20for\x20update');if(!_0x49e182||typeof _0x49e182!==_0x581996(0x223))throw new Error(_0x581996(0x22b));const _0x149e69=await this[_0x581996(0x201)][_0x581996(0x209)](_0x6ed0c7);if(!_0x149e69)throw new Error(_0x581996(0x207)+_0x6ed0c7);this[_0x581996(0x21c)][_0x581996(0x1db)](_0x581996(0x229),{'agentId':_0x6ed0c7,'updates':_0x49e182,'agentName':_0x149e69['name']});const _0x150c5c={..._0x49e182,'sessionId':_0x238032[_0x581996(0x1dc)]},_0x26e37f=await this['agentPool']['updateAgent'](_0x6ed0c7,_0x150c5c);return this[_0x581996(0x21c)]['info'](_0x581996(0x234)+_0x6ed0c7,{'agentName':_0x26e37f[_0x581996(0x1fc)],'newMode':_0x26e37f[_0x581996(0x235)],'sessionId':_0x238032['sessionId']}),_0x26e37f;}async['_handleDeleteAgent'](_0x13c719){const _0x63001c=a0_0x5f5498,{agentId:_0x55e5b4}=_0x13c719[_0x63001c(0x1e8)];if(!_0x55e5b4)throw new Error('Agent\x20ID\x20is\x20required\x20for\x20deletion');const _0x3af302=await this['agentPool'][_0x63001c(0x209)](_0x55e5b4);if(!_0x3af302)throw new Error(_0x63001c(0x207)+_0x55e5b4);const _0x24f67e=await this['agentPool'][_0x63001c(0x1dd)](_0x55e5b4);return this[_0x63001c(0x21c)][_0x63001c(0x1db)](_0x63001c(0x1f9)+_0x55e5b4,{'agentName':_0x3af302['name'],'sessionId':_0x13c719[_0x63001c(0x1dc)]}),{'success':!![],'deletedAgent':{'id':_0x3af302['id'],'name':_0x3af302['name']},..._0x24f67e};}async['_handleSendMessage'](_0x451d03){const _0x5b1687=a0_0x5f5498,{agentId:_0x4c5c3f,message:_0x14a1e4,mode:_0x3fa953,contextReferences:_0x414f39,apiKey:_0x17abb2,customApiKeys:_0x4a3ee8}=_0x451d03['payload'],_0x195fa1={'projectDir':_0x451d03[_0x5b1687(0x228)],'sessionId':_0x451d03['sessionId'],'interface':_0x451d03[_0x5b1687(0x217)],'mode':_0x3fa953||MESSAGE_MODES['CHAT'],'contextReferences':_0x414f39||[],'apiKey':_0x17abb2,'customApiKeys':_0x4a3ee8||{}};return await this[_0x5b1687(0x20c)](_0x4c5c3f,_0x14a1e4,_0x195fa1);}async[a0_0x5f5498(0x1ee)](_0x63827f){return await this['agentPool']['listActiveAgents']();}async[a0_0x5f5498(0x230)](_0x31833a){const _0x5a0e43=a0_0x5f5498,{projectDir:_0x1a3cf0}=_0x31833a['payload'],_0x422098=await this['stateManager'][_0x5a0e43(0x20b)](_0x1a3cf0);for(const _0x509f18 of _0x422098[_0x5a0e43(0x22f)]){await this['agentPool']['restoreAgent'](_0x509f18);}return _0x422098;}async[a0_0x5f5498(0x239)](_0x52a15b){return await this['getSessionState'](_0x52a15b['sessionId']);}async[a0_0x5f5498(0x20f)](_0x589e2b){const {agentId:_0x2ce676,duration:_0x186c14,reason:_0x48f51a}=_0x589e2b['payload'];return await this['agentPool']['pauseAgent'](_0x2ce676,_0x186c14,_0x48f51a);}async[a0_0x5f5498(0x20a)](_0x3049d8){const {agentId:_0x1959b1}=_0x3049d8['payload'];return await this['agentPool']['resumeAgent'](_0x1959b1);}async['_handleSwitchModel'](_0x3d84e1){const _0x6ae700=a0_0x5f5498,{agentId:_0x4bffa4,newModel:_0x2f9b7d}=_0x3d84e1[_0x6ae700(0x1e8)],_0x2221a5=await this[_0x6ae700(0x201)]['getAgent'](_0x4bffa4);if(!_0x2221a5)throw new Error('Agent\x20not\x20found:\x20'+_0x4bffa4);return await this['aiService']['switchAgentModel'](_0x4bffa4,_0x2f9b7d);}async[a0_0x5f5498(0x1e3)](_0x5ebbed){const _0x12ead5=a0_0x5f5498,{agentId:_0x3944cd}=_0x5ebbed[_0x12ead5(0x1e8)],_0x5ede84=await this['agentPool'][_0x12ead5(0x209)](_0x3944cd);if(!_0x5ede84)throw new Error(_0x12ead5(0x207)+_0x3944cd);return{'id':_0x5ede84['id'],'name':_0x5ede84['name'],'status':_0x5ede84['status'],'mode':_0x5ede84[_0x12ead5(0x235)],'modeState':_0x5ede84[_0x12ead5(0x22a)],'currentModel':_0x5ede84[_0x12ead5(0x1eb)],'lastActivity':_0x5ede84[_0x12ead5(0x206)],'isPaused':_0x5ede84['status']==='paused','pausedUntil':_0x5ede84['pausedUntil']};}async['_handleGetAgentConversations'](_0xb93b3d){const _0x32b2e9=a0_0x5f5498,{agentId:_0x1fb6f5}=_0xb93b3d[_0x32b2e9(0x1e8)],_0x4e4b7a=await this['agentPool']['getAgent'](_0x1fb6f5);if(!_0x4e4b7a)throw new Error('Agent\x20not\x20found:\x20'+_0x1fb6f5);return{'agentId':_0x4e4b7a['id'],'conversations':_0x4e4b7a[_0x32b2e9(0x1f6)],'messageCount':_0x4e4b7a[_0x32b2e9(0x1f6)]?.['full']?.[_0x32b2e9(0x1e7)]?.['length']||0x0};}['_validateRequest'](_0x5963b3){const _0x3ad0d4=a0_0x5f5498;if(!_0x5963b3||typeof _0x5963b3!==_0x3ad0d4(0x223))throw new Error(_0x3ad0d4(0x1d8));const requiredFields=[_0x3ad0d4(0x217),'sessionId',_0x3ad0d4(0x1ff),_0x3ad0d4(0x1e8)];for(const _0x51ecf2 of requiredFields){if(!(_0x51ecf2 in _0x5963b3))throw new Error('Missing\x20required\x20field:\x20'+_0x51ecf2);}const _0x4c6223=Object[_0x3ad0d4(0x216)](INTERFACE_TYPES);if(!_0x4c6223[_0x3ad0d4(0x222)](_0x5963b3['interface']))throw new Error(_0x3ad0d4(0x1f8)+_0x5963b3['interface']);}async[a0_0x5f5498(0x225)](_0x4f042b,_0x4d4034){const _0x21068d=a0_0x5f5498;if(!this[_0x21068d(0x1e4)]['has'](_0x4f042b)){const _0x49e22f={'id':_0x4f042b,'projectDir':_0x4d4034||process[_0x21068d(0x22c)](),'createdAt':new Date()['toISOString'](),'lastActivity':new Date()['toISOString']()};this[_0x21068d(0x1e4)][_0x21068d(0x22d)](_0x4f042b,_0x49e22f),this[_0x21068d(0x21c)]['info']('Session\x20created:\x20'+_0x4f042b,{'projectDir':_0x49e22f['projectDir']});}else{const _0x59b784=this[_0x21068d(0x1e4)][_0x21068d(0x213)](_0x4f042b);_0x59b784[_0x21068d(0x206)]=new Date()['toISOString']();}}[a0_0x5f5498(0x1da)](_0x436425){const _0x42a887=a0_0x5f5498,_0x1a034b={..._0x436425};return _0x1a034b[_0x42a887(0x212)]&&(_0x1a034b['user']={'id':_0x1a034b[_0x42a887(0x212)]['id']}),_0x1a034b[_0x42a887(0x1e8)]&&_0x1a034b['payload'][_0x42a887(0x23b)]&&_0x1a034b['payload']['message']['length']>0x1f4&&(_0x1a034b['payload'][_0x42a887(0x23b)]=_0x1a034b['payload'][_0x42a887(0x23b)][_0x42a887(0x203)](0x0,0x1f4)+_0x42a887(0x21f)),_0x1a034b;}}function a0_0x432e(_0x1eeb2c,_0x29c07b){_0x1eeb2c=_0x1eeb2c-0x1cf;const _0x25f679=a0_0x25f6();let _0x432ee7=_0x25f679[_0x1eeb2c];if(a0_0x432e['ruiMuA']===undefined){var _0x2db377=function(_0x2448e3){const _0x2ddc76='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x39cfce='',_0x3dc7ab='';for(let _0x3ba5f7=0x0,_0xca5152,_0x1ff0ca,_0x27ed78=0x0;_0x1ff0ca=_0x2448e3['charAt'](_0x27ed78++);~_0x1ff0ca&&(_0xca5152=_0x3ba5f7%0x4?_0xca5152*0x40+_0x1ff0ca:_0x1ff0ca,_0x3ba5f7++%0x4)?_0x39cfce+=String['fromCharCode'](0xff&_0xca5152>>(-0x2*_0x3ba5f7&0x6)):0x0){_0x1ff0ca=_0x2ddc76['indexOf'](_0x1ff0ca);}for(let _0x177db8=0x0,_0x378cfb=_0x39cfce['length'];_0x177db8<_0x378cfb;_0x177db8++){_0x3dc7ab+='%'+('00'+_0x39cfce['charCodeAt'](_0x177db8)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3dc7ab);};a0_0x432e['AMAyfs']=_0x2db377,a0_0x432e['GsEXwl']={},a0_0x432e['ruiMuA']=!![];}const _0x588ea8=_0x25f679[0x0],_0x2c7e6a=_0x1eeb2c+_0x588ea8,_0x737f9f=a0_0x432e['GsEXwl'][_0x2c7e6a];return!_0x737f9f?(_0x432ee7=a0_0x432e['AMAyfs'](_0x432ee7),a0_0x432e['GsEXwl'][_0x2c7e6a]=_0x432ee7):_0x432ee7=_0x737f9f,_0x432ee7;}export default Orchestrator;
|