@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/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_0x2177(_0x28c294,_0x194e4e){_0x28c294=_0x28c294-0x1ba;const _0x25db74=a0_0x25db();let _0x217729=_0x25db74[_0x28c294];if(a0_0x2177['dpjScL']===undefined){var _0x54b1d5=function(_0x37a401){const _0x296058='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xc5e6ff='',_0x2ee141='';for(let _0x399081=0x0,_0x1183ca,_0xb9eefe,_0x27bba4=0x0;_0xb9eefe=_0x37a401['charAt'](_0x27bba4++);~_0xb9eefe&&(_0x1183ca=_0x399081%0x4?_0x1183ca*0x40+_0xb9eefe:_0xb9eefe,_0x399081++%0x4)?_0xc5e6ff+=String['fromCharCode'](0xff&_0x1183ca>>(-0x2*_0x399081&0x6)):0x0){_0xb9eefe=_0x296058['indexOf'](_0xb9eefe);}for(let _0x4def11=0x0,_0x362df3=_0xc5e6ff['length'];_0x4def11<_0x362df3;_0x4def11++){_0x2ee141+='%'+('00'+_0xc5e6ff['charCodeAt'](_0x4def11)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x2ee141);};a0_0x2177['dCwuzK']=_0x54b1d5,a0_0x2177['pUFdfw']={},a0_0x2177['dpjScL']=!![];}const _0x3e4aa1=_0x25db74[0x0],_0x2f8d31=_0x28c294+_0x3e4aa1,_0x333213=a0_0x2177['pUFdfw'][_0x2f8d31];return!_0x333213?(_0x217729=a0_0x2177['dCwuzK'](_0x217729),a0_0x2177['pUFdfw'][_0x2f8d31]=_0x217729):_0x217729=_0x333213,_0x217729;}function a0_0x25db(){const _0x51fd90=['twvZC2fNzsbXDwv1zwqGzM9YigfNzw50ihbYB2nLC3nPBMC','vxbKyxrPBMCGywDLBNqGD2L0AcbWyxLSB2fK','x2HHBMrSzuDLDefNzw50u3rHDhvZ','x2HHBMrSzurLBgv0zufNzw50','n0Dbz0fOzq','x2HHBMrSzvn3AxrJAe1VzgvS','ywDLBNrqB29S','u0vorf9nrvntquDf','A2v5CW','qwDLBNqT','BMfTzq','Bg9Nz2vY','ywDLBNrZ','DxnLCG','C3DPDgnOqwDLBNrnB2rLBa','C3vIC3rYAw5N','x2HHBMrSzuDLDfnLC3nPB25tDgf0zq','CMvZDg9YzufNzw50','ywn0AxzLu2vZC2LVBNm','x3zHBgLKyxrLuMvXDwvZDa','y3DK','zxjYB3i','C3rHDgvnyw5Hz2vY','uMvXDwvZDcbWCM9JzxnZAw5NigzHAwXLzdOG','mZmWndm4oe5NrKzouW','CMvZDw1LuhjVAMvJDa','Bw9Kzvn0yxrL','Aw5JBhvKzxm','y2XLyxi','z2v0u2vZC2LVBLn0yxrL','ChjVAMvJDerPCG','Bw9Kzq','ChjVy2vZC1jLCxvLC3q','x3nHBML0AxPLuMvXDwvZDezVCKXVz2DPBMC','y29UDMvYC2f0Aw9UCW','BgfZDefJDgL2Axr5','BwvZC2fNzvbYB2nLC3nVCG','Aw50zxjMywnL','BgvUz3rO','C2vZC2LVBKLK','C3rHDhvZ','uKvtvu1fx0fhru5u','y2fWywjPBgL0AwvZ','DxbKyxrLqwDLBNq','qwDLBNqGBM90igzVDw5KoIa','mteWmte2n2vREK5bva','Aw5MBW','r0vux0fhru5ux0nptLzfuLnbveLptLm','C2H1DgrVD24','mZuZndqWmKzIwgf3Ea','x2vUC3vYzvnLC3nPB24','DhLWzq','ywDLBNrjza','Cgf1C2vKvw50AwW','CMvXDwvZDeHHBMrSzxjZ','C2v0','teLtvf9br0vovfm','CMvZDhjPy3ruB1bYB2PLy3q','ntq3odC4nxvnrg1PAG','vvbeqvrfx0fhru5u','y29UzMLN','y3jLyxrLqwDLBNq','z2v0','CxvLDwvKlq','x2HHBMrSzvvWzgf0zufNzw50','BgLZDefJDgL2zufNzw50CW','x2HHBMrSzuXPC3rbz2vUDhm','yMLUza','Cgf1C2vbz2vUDa','Dg9ju09tDhjPBMC','vw5RBM93BIbHy3rPB246ia','qwDLBNqGDxbKyxrLzdOG','ywLtzxj2AwnL','r0vux0fhru5ux1nuqvrvuW','CMvHze9UBhLeAxjLy3rVCMLLCW','BM93','uKvtvu1fx1nfu1njt04','x2HHBMrSzunYzwf0zufNzw50','CM91DgvuB0fNzw50','x2HHBMrSzvbHDxnLqwDLBNq','x2HHBMrSzvnLBMrnzxnZywDL','uefvu0vFquDftLq','y2fSBa','mtC3nde0y3buD1vc','mJCWmtK2nuDjBeP6Eq','mJq5odC0ntzJwuHUBM0','lI4UifT0CNvUy2f0zwrD','ywn0Aw9U','q3jLyxrPBMCGywDLBNqGD2L0AcbWyxLSB2fK','BwvZC2fNzq','y3vYCMvUDe1VzgvS','z2v0qwDLBNq','DMfSDwvZ','Cgf5Bg9Hza','BwvZC2fNzxm','Cgf1C2vK','r0vux1nfu1njt05Fu1rbveu','zNjVBq','igLZihbHDxnLzcb1BNrPBca'];a0_0x25db=function(){return _0x51fd90;};return a0_0x25db();}const a0_0x45916c=a0_0x2177;(function(_0x3ce0b6,_0x335a5c){const _0x43ce34=a0_0x2177,_0x22a560=_0x3ce0b6();while(!![]){try{const _0x1dc28=-parseInt(_0x43ce34(0x1bc))/0x1+-parseInt(_0x43ce34(0x1e2))/0x2+-parseInt(_0x43ce34(0x1e3))/0x3+-parseInt(_0x43ce34(0x20a))/0x4+parseInt(_0x43ce34(0x1c9))/0x5+-parseInt(_0x43ce34(0x1c0))/0x6*(parseInt(_0x43ce34(0x1f6))/0x7)+parseInt(_0x43ce34(0x1e4))/0x8;if(_0x1dc28===_0x335a5c)break;else _0x22a560['push'](_0x22a560['shift']());}catch(_0x6bcd14){_0x22a560['push'](_0x22a560['shift']());}}}(a0_0x25db,0xae318));import{INTERFACE_TYPES,AGENT_TYPES,AGENT_STATUS,MESSAGE_MODES,ORCHESTRATOR_ACTIONS,SYSTEM_DEFAULTS}from'../utilities/constants.js';class Orchestrator{constructor(_0xc5e6ff,_0x2ee141,_0x399081,_0x1183ca,_0xb9eefe,_0x27bba4){const _0x1af8d2=a0_0x2177;this[_0x1af8d2(0x1cb)]=_0xc5e6ff,this[_0x1af8d2(0x1fd)]=_0x2ee141,this['agentPool']=_0x399081,this[_0x1af8d2(0x216)]=_0x1183ca,this[_0x1af8d2(0x1d7)]=_0xb9eefe,this[_0x1af8d2(0x208)]=_0x27bba4,this['activeSessions']=new Map(),this['requestHandlers']=new Map(),this['_initializeRequestHandlers']();}async[a0_0x45916c(0x212)](_0x4def11){const _0xbf7ffe=a0_0x45916c,_0x362df3=Date[_0xbf7ffe(0x1da)]();try{this['_validateRequest'](_0x4def11);const _0xd035cf=this['requestHandlers'][_0xbf7ffe(0x1cd)](_0x4def11[_0xbf7ffe(0x1e6)]);if(!_0xd035cf){this[_0xbf7ffe(0x1fd)]['error']('Unknown\x20action\x20received:\x20'+_0x4def11[_0xbf7ffe(0x1e6)],{'availableActions':Array[_0xbf7ffe(0x1f0)](this[_0xbf7ffe(0x1c5)][_0xbf7ffe(0x1fa)]()),'requestAction':_0x4def11[_0xbf7ffe(0x1e6)],'actionType':typeof _0x4def11[_0xbf7ffe(0x1e6)]});throw new Error(_0xbf7ffe(0x1d5)+_0x4def11[_0xbf7ffe(0x1e6)]);}await this['_ensureSession'](_0x4def11[_0xbf7ffe(0x219)],_0x4def11[_0xbf7ffe(0x210)]);const _0x5e47c0=await _0xd035cf[_0xbf7ffe(0x1e1)](this,_0x4def11),_0x557e83={'timestamp':new Date()['toISOString'](),'executionTime':Date[_0xbf7ffe(0x1da)]()-_0x362df3,'sessionId':_0x4def11[_0xbf7ffe(0x219)],'interface':_0x4def11[_0xbf7ffe(0x217)]};return{'success':!![],'data':_0x5e47c0,'error':null,'metadata':_0x557e83};}catch(_0x202413){return this[_0xbf7ffe(0x1fd)][_0xbf7ffe(0x207)](_0xbf7ffe(0x209)+_0x202413[_0xbf7ffe(0x1e8)],{'request':this[_0xbf7ffe(0x213)](_0x4def11),'error':_0x202413['stack']}),{'success':![],'data':null,'error':_0x202413['message'],'metadata':{'timestamp':new Date()[_0xbf7ffe(0x1d4)](),'executionTime':Date['now']()-_0x362df3,'sessionId':_0x4def11[_0xbf7ffe(0x219)],'interface':_0x4def11[_0xbf7ffe(0x217)]}};}}async[a0_0x45916c(0x1cc)](_0x2ca399,_0x53de13,_0x5d428e={}){const _0x591929=a0_0x45916c,_0x235498={'name':_0x5d428e['name']||_0x591929(0x1fb)+Date[_0x591929(0x1da)](),'type':_0x5d428e[_0x591929(0x1c2)]||AGENT_TYPES['USER_CREATED'],'systemPrompt':_0x2ca399,'preferredModel':_0x53de13,'capabilities':_0x5d428e[_0x591929(0x21c)]||[],..._0x5d428e},_0x301d31=await this[_0x591929(0x1f8)][_0x591929(0x1cc)](_0x235498);return this[_0x591929(0x1fd)]['info']('Agent\x20created:\x20'+_0x301d31['id'],{'agentId':_0x301d31['id'],'name':_0x301d31[_0x591929(0x1fc)],'model':_0x301d31['preferredModel']}),_0x301d31;}async['routeToAgent'](_0x5ebbe7,_0x357fa1,_0x4d45c4={}){const _0x401d8b=a0_0x45916c,_0x22b5e4=await this['agentPool'][_0x401d8b(0x1ea)](_0x5ebbe7);if(!_0x22b5e4)throw new Error(_0x401d8b(0x1bb)+_0x5ebbe7);if(_0x22b5e4[_0x401d8b(0x21a)]===AGENT_STATUS['PAUSED']&&_0x22b5e4[_0x401d8b(0x1c4)]&&new Date()<new Date(_0x22b5e4[_0x401d8b(0x1c4)]))throw new Error('Agent\x20'+_0x5ebbe7+_0x401d8b(0x1f1)+_0x22b5e4['pausedUntil']);const _0x37d862=await this['messageProcessor']['processMessage'](_0x5ebbe7,_0x357fa1,_0x4d45c4);if(_0x37d862['success']){const _0x185cdf={'success':!![],'data':{'message':_0x401d8b(0x1f2),'agentId':_0x37d862[_0x401d8b(0x1c3)],'queuedAt':_0x37d862['queuedAt'],'status':'queued','toolResults':[],'agentRedirects':[],'currentModel':_0x22b5e4[_0x401d8b(0x1e9)]},'processingId':_0x401d8b(0x1ce)+Date['now']()};return this[_0x401d8b(0x1fd)]['info']('Message\x20queued\x20for\x20agent:\x20'+_0x5ebbe7,{'agentName':_0x22b5e4[_0x401d8b(0x1fc)],'messageLength':_0x357fa1['length'],'sessionId':_0x4d45c4[_0x401d8b(0x219)]}),_0x185cdf;}else return _0x37d862;}async['getSessionState'](_0x484919){const _0x26ec46=a0_0x45916c,_0x5be490=this[_0x26ec46(0x204)]['get'](_0x484919);if(!_0x5be490)throw new Error('Session\x20not\x20found:\x20'+_0x484919);const _0x11204a=await this[_0x26ec46(0x1f8)]['listActiveAgents'](),_0x273591=await this[_0x26ec46(0x208)]['getProjectState'](_0x5be490[_0x26ec46(0x210)]);return{'sessionId':_0x484919,'projectDir':_0x5be490[_0x26ec46(0x210)],'createdAt':_0x5be490['createdAt'],'lastActivity':_0x5be490['lastActivity'],'agents':_0x11204a,'projectState':_0x273591};}async[a0_0x45916c(0x1bf)](){const _0x28fa59=a0_0x45916c;this[_0x28fa59(0x1fd)][_0x28fa59(0x1bd)]('Shutting\x20down\x20orchestrator...');const _0x28729b=await this[_0x28fa59(0x1f8)][_0x28fa59(0x1d0)]();for(const _0x3f81c4 of _0x28729b){await this['stateManager']['persistAgentState'](_0x3f81c4['id']);}this[_0x28fa59(0x204)][_0x28fa59(0x20e)](),this['logger'][_0x28fa59(0x1bd)]('Orchestrator\x20shutdown\x20complete');}['_initializeRequestHandlers'](){const _0x4ea3a4=a0_0x45916c;this[_0x4ea3a4(0x1c5)][_0x4ea3a4(0x1c6)](ORCHESTRATOR_ACTIONS['CREATE_AGENT'],this['_handleCreateAgent'][_0x4ea3a4(0x1d2)](this)),this['requestHandlers'][_0x4ea3a4(0x1c6)](ORCHESTRATOR_ACTIONS[_0x4ea3a4(0x1ca)],this['_handleUpdateAgent'][_0x4ea3a4(0x1d2)](this)),this['requestHandlers']['set'](ORCHESTRATOR_ACTIONS['DELETE_AGENT'],this['_handleDeleteAgent'][_0x4ea3a4(0x1d2)](this)),this[_0x4ea3a4(0x1c5)][_0x4ea3a4(0x1c6)](ORCHESTRATOR_ACTIONS[_0x4ea3a4(0x1f9)],this[_0x4ea3a4(0x1df)]['bind'](this)),this['requestHandlers'][_0x4ea3a4(0x1c6)](ORCHESTRATOR_ACTIONS[_0x4ea3a4(0x1c7)],this[_0x4ea3a4(0x1d1)]['bind'](this)),this[_0x4ea3a4(0x1c5)][_0x4ea3a4(0x1c6)](ORCHESTRATOR_ACTIONS[_0x4ea3a4(0x1db)],this['_handleResumeSession']['bind'](this)),this['requestHandlers'][_0x4ea3a4(0x1c6)](ORCHESTRATOR_ACTIONS[_0x4ea3a4(0x1ef)],this[_0x4ea3a4(0x202)][_0x4ea3a4(0x1d2)](this)),this['requestHandlers'][_0x4ea3a4(0x1c6)](ORCHESTRATOR_ACTIONS[_0x4ea3a4(0x1e0)],this[_0x4ea3a4(0x1de)]['bind'](this)),this['requestHandlers']['set'](ORCHESTRATOR_ACTIONS[_0x4ea3a4(0x21b)],this['_handleResumeAgent'][_0x4ea3a4(0x1d2)](this)),this[_0x4ea3a4(0x1c5)][_0x4ea3a4(0x1c6)](ORCHESTRATOR_ACTIONS['SWITCH_MODEL'],this['_handleSwitchModel']['bind'](this)),this['requestHandlers'][_0x4ea3a4(0x1c6)](ORCHESTRATOR_ACTIONS[_0x4ea3a4(0x1d8)],this['_handleGetAgentStatus']['bind'](this)),this[_0x4ea3a4(0x1c5)][_0x4ea3a4(0x1c6)](ORCHESTRATOR_ACTIONS[_0x4ea3a4(0x1be)],this['_handleGetAgentConversations']['bind'](this));}async[a0_0x45916c(0x1dc)](_0x3dc73d){const _0x5d45d3=a0_0x45916c,{name:_0xaadcff,systemPrompt:_0x5bb769,model:_0x4c330c,capabilities:_0x2e0538,dynamicModelRouting:_0x42ed85,platformProvided:_0xed0ed1,directoryAccess:_0xf3dfa1}=_0x3dc73d[_0x5d45d3(0x1ec)];return this[_0x5d45d3(0x1fd)]['info'](_0x5d45d3(0x1e7),{'name':_0xaadcff,'model':_0x4c330c,'dynamicModelRouting':_0x42ed85,'platformProvided':_0xed0ed1,'capabilities':_0x2e0538,'directoryAccess':_0xf3dfa1?{'workingDirectory':_0xf3dfa1['workingDirectory'],'readOnlyDirectories':_0xf3dfa1[_0x5d45d3(0x1d9)]?.['length']||0x0,'writeEnabledDirectories':_0xf3dfa1['writeEnabledDirectories']?.[_0x5d45d3(0x218)]||0x0,'restrictToProject':_0xf3dfa1[_0x5d45d3(0x1c8)]}:null}),await this['createAgent'](_0x5bb769,_0x4c330c,{'name':_0xaadcff,'capabilities':_0x2e0538,'dynamicModelRouting':_0x42ed85,'platformProvided':_0xed0ed1,'directoryAccess':_0xf3dfa1,'sessionId':_0x3dc73d[_0x5d45d3(0x219)],'projectDir':_0x3dc73d[_0x5d45d3(0x210)]});}async[a0_0x45916c(0x1cf)](_0x247991){const _0x1fe973=a0_0x45916c,{agentId:_0x17115f,updates:_0x2462c4}=_0x247991[_0x1fe973(0x1ec)];if(!_0x17115f)throw new Error('Agent\x20ID\x20is\x20required\x20for\x20update');if(!_0x2462c4||typeof _0x2462c4!=='object')throw new Error('Updates\x20object\x20is\x20required');const _0x4e4250=await this['agentPool']['getAgent'](_0x17115f);if(!_0x4e4250)throw new Error(_0x1fe973(0x1bb)+_0x17115f);this['logger']['info'](_0x1fe973(0x1f3),{'agentId':_0x17115f,'updates':_0x2462c4,'agentName':_0x4e4250['name']});const _0x214b0e={..._0x2462c4,'sessionId':_0x247991[_0x1fe973(0x219)]},_0x85fb89=await this[_0x1fe973(0x1f8)][_0x1fe973(0x1ba)](_0x17115f,_0x214b0e);return this[_0x1fe973(0x1fd)]['info'](_0x1fe973(0x1d6)+_0x17115f,{'agentName':_0x85fb89['name'],'newMode':_0x85fb89[_0x1fe973(0x211)],'sessionId':_0x247991[_0x1fe973(0x219)]}),_0x85fb89;}async[a0_0x45916c(0x1f5)](_0xeeca67){const _0x20bd40=a0_0x45916c,{agentId:_0x519c91}=_0xeeca67[_0x20bd40(0x1ec)];if(!_0x519c91)throw new Error('Agent\x20ID\x20is\x20required\x20for\x20deletion');const _0x308853=await this[_0x20bd40(0x1f8)]['getAgent'](_0x519c91);if(!_0x308853)throw new Error('Agent\x20not\x20found:\x20'+_0x519c91);const _0x54fe8b=await this[_0x20bd40(0x1f8)]['deleteAgent'](_0x519c91);return this['logger']['info']('Agent\x20deleted:\x20'+_0x519c91,{'agentName':_0x308853['name'],'sessionId':_0xeeca67[_0x20bd40(0x219)]}),{'success':!![],'deletedAgent':{'id':_0x308853['id'],'name':_0x308853[_0x20bd40(0x1fc)]},..._0x54fe8b};}async['_handleSendMessage'](_0x9119b7){const _0x44eb27=a0_0x45916c,{agentId:_0x1cdc63,message:_0x40d7de,mode:_0x14368c,contextReferences:_0x357775,apiKey:_0x111b9e,customApiKeys:_0x5f2f15}=_0x9119b7['payload'],_0x39a04d={'projectDir':_0x9119b7[_0x44eb27(0x210)],'sessionId':_0x9119b7['sessionId'],'interface':_0x9119b7['interface'],'mode':_0x14368c||MESSAGE_MODES['CHAT'],'contextReferences':_0x357775||[],'apiKey':_0x111b9e,'customApiKeys':_0x5f2f15||{}};return await this[_0x44eb27(0x1dd)](_0x1cdc63,_0x40d7de,_0x39a04d);}async[a0_0x45916c(0x1d1)](_0x239860){const _0x55b333=a0_0x45916c;return await this[_0x55b333(0x1f8)][_0x55b333(0x1d0)]();}async['_handleResumeSession'](_0x25f319){const _0x2be732=a0_0x45916c,{projectDir:_0x35c1e7}=_0x25f319['payload'],_0x541395=await this['stateManager'][_0x2be732(0x20b)](_0x35c1e7);for(const _0x20a7a0 of _0x541395[_0x2be732(0x1fe)]){await this[_0x2be732(0x1f8)][_0x2be732(0x203)](_0x20a7a0);}return _0x541395;}async['_handleGetSessionState'](_0x547cf5){const _0x583d94=a0_0x45916c;return await this[_0x583d94(0x20f)](_0x547cf5['sessionId']);}async['_handlePauseAgent'](_0xd6d638){const _0x22f79a=a0_0x45916c,{agentId:_0x3d37e9,duration:_0x2ba5d4,reason:_0x3db4af}=_0xd6d638['payload'];return await this[_0x22f79a(0x1f8)][_0x22f79a(0x1d3)](_0x3d37e9,_0x2ba5d4,_0x3db4af);}async['_handleResumeAgent'](_0x10987c){const _0x3ee979=a0_0x45916c,{agentId:_0x570da0}=_0x10987c[_0x3ee979(0x1ec)];return await this['agentPool']['resumeAgent'](_0x570da0);}async[a0_0x45916c(0x1f7)](_0x2f15e5){const _0x469ba4=a0_0x45916c,{agentId:_0x34db22,newModel:_0x2b5b94}=_0x2f15e5[_0x469ba4(0x1ec)],_0x414ab2=await this['agentPool']['getAgent'](_0x34db22);if(!_0x414ab2)throw new Error(_0x469ba4(0x1bb)+_0x34db22);return await this['aiService'][_0x469ba4(0x200)](_0x34db22,_0x2b5b94);}async[a0_0x45916c(0x1f4)](_0x394d14){const _0xbd07fd=a0_0x45916c,{agentId:_0xc2c889}=_0x394d14[_0xbd07fd(0x1ec)],_0x24b8fe=await this[_0xbd07fd(0x1f8)]['getAgent'](_0xc2c889);if(!_0x24b8fe)throw new Error('Agent\x20not\x20found:\x20'+_0xc2c889);return{'id':_0x24b8fe['id'],'name':_0x24b8fe[_0xbd07fd(0x1fc)],'status':_0x24b8fe['status'],'mode':_0x24b8fe[_0xbd07fd(0x211)],'modeState':_0x24b8fe[_0xbd07fd(0x20c)],'currentModel':_0x24b8fe[_0xbd07fd(0x1e9)],'lastActivity':_0x24b8fe[_0xbd07fd(0x215)],'isPaused':_0x24b8fe[_0xbd07fd(0x21a)]===_0xbd07fd(0x1ee),'pausedUntil':_0x24b8fe[_0xbd07fd(0x1c4)]};}async['_handleGetAgentConversations'](_0x5544d5){const _0xcb44e3=a0_0x45916c,{agentId:_0x1b037b}=_0x5544d5[_0xcb44e3(0x1ec)],_0x34e5cd=await this['agentPool']['getAgent'](_0x1b037b);if(!_0x34e5cd)throw new Error(_0xcb44e3(0x1bb)+_0x1b037b);return{'agentId':_0x34e5cd['id'],'conversations':_0x34e5cd[_0xcb44e3(0x214)],'messageCount':_0x34e5cd['conversations']?.['full']?.[_0xcb44e3(0x1ed)]?.['length']||0x0};}[a0_0x45916c(0x205)](_0x401711){const _0x3bb68c=a0_0x45916c;if(!_0x401711||typeof _0x401711!=='object')throw new Error('Invalid\x20request\x20format');const requiredFields=['interface','sessionId',_0x3bb68c(0x1e6),_0x3bb68c(0x1ec)];for(const _0x39c5f7 of requiredFields){if(!(_0x39c5f7 in _0x401711))throw new Error('Missing\x20required\x20field:\x20'+_0x39c5f7);}const _0x45568c=Object[_0x3bb68c(0x1eb)](INTERFACE_TYPES);if(!_0x45568c[_0x3bb68c(0x20d)](_0x401711['interface']))throw new Error('Invalid\x20interface:\x20'+_0x401711['interface']);}async[a0_0x45916c(0x1c1)](_0x2e4686,_0x571dde){const _0x10f173=a0_0x45916c;if(!this['activeSessions']['has'](_0x2e4686)){const _0x1d67d9={'id':_0x2e4686,'projectDir':_0x571dde||process[_0x10f173(0x206)](),'createdAt':new Date()[_0x10f173(0x1d4)](),'lastActivity':new Date()[_0x10f173(0x1d4)]()};this['activeSessions'][_0x10f173(0x1c6)](_0x2e4686,_0x1d67d9),this['logger'][_0x10f173(0x1bd)]('Session\x20created:\x20'+_0x2e4686,{'projectDir':_0x1d67d9[_0x10f173(0x210)]});}else{const _0x23b708=this[_0x10f173(0x204)]['get'](_0x2e4686);_0x23b708['lastActivity']=new Date()[_0x10f173(0x1d4)]();}}['_sanitizeRequestForLogging'](_0xa57684){const _0x31f486=a0_0x45916c,_0x2ab5cf={..._0xa57684};return _0x2ab5cf['user']&&(_0x2ab5cf[_0x31f486(0x1ff)]={'id':_0x2ab5cf['user']['id']}),_0x2ab5cf['payload']&&_0x2ab5cf['payload']['message']&&_0x2ab5cf[_0x31f486(0x1ec)][_0x31f486(0x1e8)][_0x31f486(0x218)]>0x1f4&&(_0x2ab5cf['payload']['message']=_0x2ab5cf[_0x31f486(0x1ec)][_0x31f486(0x1e8)][_0x31f486(0x201)](0x0,0x1f4)+_0x31f486(0x1e5)),_0x2ab5cf;}}export default Orchestrator;
|