@loxia-labs/loxia-autopilot-one 1.0.1 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -54
- package/bin/cli.js +1 -115
- package/bin/loxia-terminal-v2.js +3 -0
- package/bin/loxia-terminal.js +3 -0
- package/bin/start-with-terminal.js +3 -0
- package/package.json +15 -15
- package/scripts/install-scanners.js +1 -235
- package/src/analyzers/CSSAnalyzer.js +1 -297
- package/src/analyzers/ConfigValidator.js +1 -690
- package/src/analyzers/ESLintAnalyzer.js +1 -320
- package/src/analyzers/JavaScriptAnalyzer.js +1 -261
- package/src/analyzers/PrettierFormatter.js +1 -247
- package/src/analyzers/PythonAnalyzer.js +1 -266
- package/src/analyzers/SecurityAnalyzer.js +1 -729
- package/src/analyzers/TypeScriptAnalyzer.js +1 -247
- package/src/analyzers/codeCloneDetector/analyzer.js +1 -344
- package/src/analyzers/codeCloneDetector/detector.js +1 -203
- package/src/analyzers/codeCloneDetector/index.js +1 -160
- package/src/analyzers/codeCloneDetector/parser.js +1 -199
- package/src/analyzers/codeCloneDetector/reporter.js +1 -148
- package/src/analyzers/codeCloneDetector/scanner.js +1 -59
- package/src/core/agentPool.js +1 -1474
- package/src/core/agentScheduler.js +1 -2147
- package/src/core/contextManager.js +1 -709
- package/src/core/messageProcessor.js +1 -732
- package/src/core/orchestrator.js +1 -548
- package/src/core/stateManager.js +1 -877
- package/src/index.js +1 -631
- package/src/interfaces/cli.js +1 -549
- package/src/interfaces/terminal/__tests__/smoke/advancedFeatures.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/agentControl.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/agents.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/components.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/connection.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/enhancements.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/imports.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/messages.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/tools.test.js +1 -0
- package/src/interfaces/terminal/api/apiClient.js +1 -0
- package/src/interfaces/terminal/api/messageRouter.js +1 -0
- package/src/interfaces/terminal/api/session.js +1 -0
- package/src/interfaces/terminal/api/websocket.js +1 -0
- package/src/interfaces/terminal/components/AgentCreator.js +1 -0
- package/src/interfaces/terminal/components/AgentEditor.js +1 -0
- package/src/interfaces/terminal/components/AgentSwitcher.js +1 -0
- package/src/interfaces/terminal/components/ErrorBoundary.js +1 -0
- package/src/interfaces/terminal/components/ErrorPanel.js +1 -0
- package/src/interfaces/terminal/components/Header.js +1 -0
- package/src/interfaces/terminal/components/HelpPanel.js +1 -0
- package/src/interfaces/terminal/components/InputBox.js +1 -0
- package/src/interfaces/terminal/components/Layout.js +1 -0
- package/src/interfaces/terminal/components/LoadingSpinner.js +1 -0
- package/src/interfaces/terminal/components/MessageList.js +1 -0
- package/src/interfaces/terminal/components/MultilineTextInput.js +1 -0
- package/src/interfaces/terminal/components/SearchPanel.js +1 -0
- package/src/interfaces/terminal/components/SettingsPanel.js +1 -0
- package/src/interfaces/terminal/components/StatusBar.js +1 -0
- package/src/interfaces/terminal/components/TextInput.js +1 -0
- package/src/interfaces/terminal/config/agentEditorConstants.js +1 -0
- package/src/interfaces/terminal/config/constants.js +1 -0
- package/src/interfaces/terminal/index.js +1 -0
- package/src/interfaces/terminal/state/useAgentControl.js +1 -0
- package/src/interfaces/terminal/state/useAgents.js +1 -0
- package/src/interfaces/terminal/state/useConnection.js +1 -0
- package/src/interfaces/terminal/state/useMessages.js +1 -0
- package/src/interfaces/terminal/state/useTools.js +1 -0
- package/src/interfaces/terminal/utils/debugLogger.js +1 -0
- package/src/interfaces/terminal/utils/settingsStorage.js +1 -0
- package/src/interfaces/terminal/utils/theme.js +1 -0
- package/src/interfaces/webServer.js +1 -2162
- package/src/modules/fileExplorer/controller.js +1 -280
- package/src/modules/fileExplorer/index.js +1 -37
- package/src/modules/fileExplorer/middleware.js +1 -92
- package/src/modules/fileExplorer/routes.js +1 -125
- package/src/modules/fileExplorer/types.js +1 -44
- package/src/services/aiService.js +1 -1232
- package/src/services/apiKeyManager.js +1 -164
- package/src/services/benchmarkService.js +1 -366
- package/src/services/budgetService.js +1 -539
- package/src/services/contextInjectionService.js +1 -247
- package/src/services/conversationCompactionService.js +1 -637
- package/src/services/errorHandler.js +1 -810
- package/src/services/fileAttachmentService.js +1 -544
- package/src/services/modelRouterService.js +1 -366
- package/src/services/modelsService.js +1 -322
- package/src/services/qualityInspector.js +1 -796
- package/src/services/tokenCountingService.js +1 -536
- package/src/tools/agentCommunicationTool.js +1 -1344
- package/src/tools/agentDelayTool.js +1 -485
- package/src/tools/asyncToolManager.js +1 -604
- package/src/tools/baseTool.js +1 -800
- package/src/tools/browserTool.js +1 -920
- package/src/tools/cloneDetectionTool.js +1 -621
- package/src/tools/dependencyResolverTool.js +1 -1215
- package/src/tools/fileContentReplaceTool.js +1 -875
- package/src/tools/fileSystemTool.js +1 -1107
- package/src/tools/fileTreeTool.js +1 -853
- package/src/tools/imageTool.js +1 -901
- package/src/tools/importAnalyzerTool.js +1 -1060
- package/src/tools/jobDoneTool.js +1 -248
- package/src/tools/seekTool.js +1 -956
- package/src/tools/staticAnalysisTool.js +1 -1778
- package/src/tools/taskManagerTool.js +1 -2873
- package/src/tools/terminalTool.js +1 -2304
- package/src/tools/webTool.js +1 -1430
- package/src/types/agent.js +1 -519
- package/src/types/contextReference.js +1 -972
- package/src/types/conversation.js +1 -730
- package/src/types/toolCommand.js +1 -747
- package/src/utilities/attachmentValidator.js +1 -292
- package/src/utilities/configManager.js +1 -582
- package/src/utilities/constants.js +1 -722
- package/src/utilities/directoryAccessManager.js +1 -535
- package/src/utilities/fileProcessor.js +1 -307
- package/src/utilities/logger.js +1 -436
- package/src/utilities/tagParser.js +1 -1246
- package/src/utilities/toolConstants.js +1 -317
- package/web-ui/build/index.html +2 -2
- package/web-ui/build/static/{index-Dy2bYbOa.css → index-CClD1090.css} +1 -1
- package/web-ui/build/static/{index-CjkkcnFA.js → index-lCBai6dX.js} +66 -67
|
@@ -1,732 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MessageProcessor - Processes messages from agents, extracts tool commands, executes tools
|
|
3
|
-
*
|
|
4
|
-
* NEW ARCHITECTURE:
|
|
5
|
-
* - Only handles message queuing and tool execution
|
|
6
|
-
* - No scheduling or autonomous loops (handled by AgentScheduler)
|
|
7
|
-
* - Clean separation of concerns
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { AGENT_MODES, AGENT_MODE_STATES } from '../utilities/constants.js';
|
|
11
|
-
import TagParser from '../utilities/tagParser.js';
|
|
12
|
-
import { TOOL_IDS, COMMAND_FORMATS } from '../utilities/toolConstants.js';
|
|
13
|
-
|
|
14
|
-
class MessageProcessor {
|
|
15
|
-
constructor(config, logger, toolsRegistry, agentPool, contextManager, aiService, modelRouterService = null, modelsService = null) {
|
|
16
|
-
this.config = config;
|
|
17
|
-
this.logger = logger;
|
|
18
|
-
this.toolsRegistry = toolsRegistry;
|
|
19
|
-
this.agentPool = agentPool;
|
|
20
|
-
this.contextManager = contextManager;
|
|
21
|
-
this.aiService = aiService;
|
|
22
|
-
this.modelRouterService = modelRouterService;
|
|
23
|
-
this.modelsService = modelsService;
|
|
24
|
-
|
|
25
|
-
// Active async operations tracking
|
|
26
|
-
this.asyncOperations = new Map();
|
|
27
|
-
|
|
28
|
-
// Tool execution history
|
|
29
|
-
this.executionHistory = new Map();
|
|
30
|
-
|
|
31
|
-
// Operation ID counter
|
|
32
|
-
this.operationCounter = 0;
|
|
33
|
-
|
|
34
|
-
// WebSocket manager for real-time updates
|
|
35
|
-
this.webSocketManager = null;
|
|
36
|
-
|
|
37
|
-
// AgentScheduler reference
|
|
38
|
-
this.scheduler = null;
|
|
39
|
-
|
|
40
|
-
// Orchestrator reference (for backward compatibility)
|
|
41
|
-
this.orchestrator = null;
|
|
42
|
-
|
|
43
|
-
// Initialize TagParser for comprehensive tool command extraction
|
|
44
|
-
this.tagParser = new TagParser();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Set WebSocket manager for real-time UI updates
|
|
49
|
-
* @param {Object} webSocketManager - WebSocket manager instance
|
|
50
|
-
*/
|
|
51
|
-
setWebSocketManager(webSocketManager) {
|
|
52
|
-
this.webSocketManager = webSocketManager;
|
|
53
|
-
this.logger?.info('WebSocket manager set for MessageProcessor', {
|
|
54
|
-
hasManager: !!webSocketManager
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Set AgentScheduler reference
|
|
60
|
-
* @param {AgentScheduler} scheduler - AgentScheduler instance
|
|
61
|
-
*/
|
|
62
|
-
setScheduler(scheduler) {
|
|
63
|
-
this.scheduler = scheduler;
|
|
64
|
-
this.logger?.info('AgentScheduler set for MessageProcessor', {
|
|
65
|
-
hasScheduler: !!scheduler
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Main message processing entry point - NEW ARCHITECTURE
|
|
71
|
-
* Simply queues messages for scheduler processing
|
|
72
|
-
* @param {string} agentId - Target agent ID
|
|
73
|
-
* @param {string} message - Message content
|
|
74
|
-
* @param {Object} context - Message context
|
|
75
|
-
* @returns {Promise<Object>} Queuing result
|
|
76
|
-
*/
|
|
77
|
-
async processMessage(agentId, message, context = {}) {
|
|
78
|
-
const agent = await this.agentPool.getAgent(agentId);
|
|
79
|
-
if (!agent) {
|
|
80
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const messageString = typeof message === 'string' ? message : (message ? JSON.stringify(message) : '');
|
|
84
|
-
this.logger.info(`Queueing message for agent: ${agentId}`, {
|
|
85
|
-
messageLength: messageString.length,
|
|
86
|
-
messageType: typeof message,
|
|
87
|
-
isInterAgentMessage: context.isInterAgentMessage,
|
|
88
|
-
contextMessageType: context.messageType || 'user'
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// Determine message type and queue appropriately
|
|
92
|
-
if (context.isInterAgentMessage) {
|
|
93
|
-
// Inter-agent message
|
|
94
|
-
await this.agentPool.addInterAgentMessage(agentId, {
|
|
95
|
-
content: message,
|
|
96
|
-
sender: context.originalSender,
|
|
97
|
-
senderName: context.senderName,
|
|
98
|
-
subject: context.subject || 'Inter-agent message',
|
|
99
|
-
timestamp: new Date().toISOString(),
|
|
100
|
-
sessionId: context.sessionId,
|
|
101
|
-
requiresReply: context.requiresReply || false
|
|
102
|
-
});
|
|
103
|
-
} else {
|
|
104
|
-
// User message
|
|
105
|
-
await this.agentPool.addUserMessage(agentId, {
|
|
106
|
-
content: message,
|
|
107
|
-
role: 'user',
|
|
108
|
-
timestamp: new Date().toISOString(),
|
|
109
|
-
contextReferences: context.contextReferences || [],
|
|
110
|
-
sessionId: context.sessionId
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Add agent to scheduler if not already active
|
|
115
|
-
if (this.scheduler) {
|
|
116
|
-
await this.scheduler.addAgent(agentId, {
|
|
117
|
-
triggeredBy: context.isInterAgentMessage ? 'inter-agent-message' : 'user-message',
|
|
118
|
-
sessionId: context.sessionId
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return {
|
|
123
|
-
success: true,
|
|
124
|
-
message: 'Message queued for processing',
|
|
125
|
-
agentId: agentId,
|
|
126
|
-
queuedAt: new Date().toISOString()
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Unwrap TagParser format parameters
|
|
132
|
-
* TagParser wraps XML parameters in {value, attributes} objects
|
|
133
|
-
* This method unwraps them to direct values for tool consumption
|
|
134
|
-
* @param {Object} params - Parameters to unwrap
|
|
135
|
-
* @returns {Object} Unwrapped parameters
|
|
136
|
-
*/
|
|
137
|
-
unwrapParameters(params) {
|
|
138
|
-
if (!params || typeof params !== 'object') {
|
|
139
|
-
return params;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const unwrapped = {};
|
|
143
|
-
for (const [key, value] of Object.entries(params)) {
|
|
144
|
-
if (value && typeof value === 'object' && 'value' in value && 'attributes' in value) {
|
|
145
|
-
// TagParser wrapped format: {value: "...", attributes: {}}
|
|
146
|
-
unwrapped[key] = value.value;
|
|
147
|
-
|
|
148
|
-
// Also preserve attributes if tool needs them
|
|
149
|
-
if (value.attributes && Object.keys(value.attributes).length > 0) {
|
|
150
|
-
unwrapped[`${key}_attributes`] = value.attributes;
|
|
151
|
-
}
|
|
152
|
-
} else {
|
|
153
|
-
// Already unwrapped or direct value
|
|
154
|
-
unwrapped[key] = value;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return unwrapped;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Extract tool commands from message content
|
|
163
|
-
* Supports multiple formats: XML, JSON, and simple bracket notation
|
|
164
|
-
* @param {string} message - Message containing tool commands
|
|
165
|
-
* @returns {Promise<Array>} Array of tool commands
|
|
166
|
-
*/
|
|
167
|
-
async extractToolCommands(message) {
|
|
168
|
-
const commands = [];
|
|
169
|
-
|
|
170
|
-
// Use TagParser to extract XML and JSON format commands
|
|
171
|
-
const tagParserCommands = this.tagParser.extractToolCommands(message);
|
|
172
|
-
|
|
173
|
-
// Process TagParser commands and normalize them
|
|
174
|
-
for (const cmd of tagParserCommands) {
|
|
175
|
-
const normalized = this.tagParser.normalizeToolCommand(cmd);
|
|
176
|
-
commands.push({
|
|
177
|
-
toolId: normalized.toolId,
|
|
178
|
-
content: JSON.stringify(normalized.parameters), // Convert parameters to JSON string for tool execution
|
|
179
|
-
parameters: normalized.parameters,
|
|
180
|
-
type: normalized.type,
|
|
181
|
-
isAsync: normalized.parameters?.async === true,
|
|
182
|
-
raw: normalized.rawContent,
|
|
183
|
-
position: cmd.position || {}
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// Also check for simple bracket notation [tool id="..."] for backward compatibility
|
|
188
|
-
const toolPattern = /\[tool\s+id="([^"]+)"(?:\s+async="(true|false)")?\]([\s\S]*?)\[\/tool\]/gi;
|
|
189
|
-
|
|
190
|
-
console.log('MessageProcessor DEBUG: checking bracket pattern on message length:', message.length);
|
|
191
|
-
|
|
192
|
-
let match;
|
|
193
|
-
while ((match = toolPattern.exec(message)) !== null) {
|
|
194
|
-
const [fullMatch, toolId, isAsync, content] = match;
|
|
195
|
-
|
|
196
|
-
console.log('MessageProcessor DEBUG: bracket pattern matched:', {
|
|
197
|
-
toolId: toolId.trim(),
|
|
198
|
-
contentLength: content.trim().length,
|
|
199
|
-
contentPreview: content.trim().substring(0, 100)
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
// Check if this command was already extracted by TagParser
|
|
203
|
-
const alreadyExtracted = commands.some(cmd =>
|
|
204
|
-
cmd.raw === fullMatch || (cmd.position.start === match.index && cmd.position.end === match.index + fullMatch.length)
|
|
205
|
-
);
|
|
206
|
-
|
|
207
|
-
if (!alreadyExtracted) {
|
|
208
|
-
console.log('MessageProcessor DEBUG: adding bracket command (not already extracted by TagParser)');
|
|
209
|
-
|
|
210
|
-
const trimmedContent = content.trim();
|
|
211
|
-
|
|
212
|
-
// Check if the content inside brackets contains XML tags
|
|
213
|
-
const hasXmlTags = /<[^>]+>/g.test(trimmedContent);
|
|
214
|
-
|
|
215
|
-
if (hasXmlTags) {
|
|
216
|
-
console.log('MessageProcessor DEBUG: detected XML content inside brackets, parsing with TagParser');
|
|
217
|
-
|
|
218
|
-
// Decode HTML entities before parsing XML
|
|
219
|
-
const decodedXmlContent = this.tagParser.decodeHtmlEntities(trimmedContent);
|
|
220
|
-
console.log('MessageProcessor DEBUG: HTML decoding changed content:', trimmedContent !== decodedXmlContent);
|
|
221
|
-
|
|
222
|
-
// Parse the XML content using TagParser
|
|
223
|
-
try {
|
|
224
|
-
const xmlParameters = this.tagParser.parseXMLParameters(decodedXmlContent);
|
|
225
|
-
|
|
226
|
-
console.log('MessageProcessor DEBUG: XML parameters extracted:', Object.keys(xmlParameters));
|
|
227
|
-
|
|
228
|
-
// Check if we got valid parameters
|
|
229
|
-
if (!xmlParameters || typeof xmlParameters !== 'object') {
|
|
230
|
-
throw new Error('Invalid XML parameters returned');
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// Create a temporary XML command structure for normalization
|
|
234
|
-
const xmlCommand = {
|
|
235
|
-
type: COMMAND_FORMATS.XML,
|
|
236
|
-
toolId: toolId.trim(),
|
|
237
|
-
parameters: xmlParameters,
|
|
238
|
-
rawContent: decodedXmlContent
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
// Normalize it to get the actions array
|
|
242
|
-
const normalized = this.tagParser.normalizeToolCommand(xmlCommand);
|
|
243
|
-
|
|
244
|
-
console.log('MessageProcessor DEBUG: normalized XML command:', {
|
|
245
|
-
toolId: normalized.toolId,
|
|
246
|
-
hasActions: !!normalized.parameters.actions,
|
|
247
|
-
actionsLength: normalized.parameters.actions?.length || 0
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
// Add the properly parsed command
|
|
251
|
-
commands.push({
|
|
252
|
-
toolId: normalized.toolId,
|
|
253
|
-
content: JSON.stringify(normalized.parameters),
|
|
254
|
-
parameters: normalized.parameters,
|
|
255
|
-
type: COMMAND_FORMATS.XML, // Mark as XML since we parsed it
|
|
256
|
-
isAsync: isAsync === 'true',
|
|
257
|
-
raw: fullMatch,
|
|
258
|
-
position: {
|
|
259
|
-
start: match.index,
|
|
260
|
-
end: match.index + fullMatch.length
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
} catch (error) {
|
|
265
|
-
console.log('MessageProcessor DEBUG: XML parsing failed:', error.message);
|
|
266
|
-
console.log('MessageProcessor DEBUG: falling back to raw bracket format');
|
|
267
|
-
|
|
268
|
-
// Fall back to treating it as a simple bracket command
|
|
269
|
-
commands.push({
|
|
270
|
-
toolId: toolId.trim(),
|
|
271
|
-
content: trimmedContent,
|
|
272
|
-
type: COMMAND_FORMATS.BRACKET,
|
|
273
|
-
isAsync: isAsync === 'true',
|
|
274
|
-
raw: fullMatch,
|
|
275
|
-
position: {
|
|
276
|
-
start: match.index,
|
|
277
|
-
end: match.index + fullMatch.length
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
} else {
|
|
282
|
-
console.log('MessageProcessor DEBUG: no XML detected, treating as simple bracket command');
|
|
283
|
-
|
|
284
|
-
// Simple bracket command without XML content
|
|
285
|
-
commands.push({
|
|
286
|
-
toolId: toolId.trim(),
|
|
287
|
-
content: trimmedContent,
|
|
288
|
-
type: COMMAND_FORMATS.BRACKET,
|
|
289
|
-
isAsync: isAsync === 'true',
|
|
290
|
-
raw: fullMatch,
|
|
291
|
-
position: {
|
|
292
|
-
start: match.index,
|
|
293
|
-
end: match.index + fullMatch.length
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
} else {
|
|
298
|
-
console.log('MessageProcessor DEBUG: bracket command already extracted by TagParser, skipping');
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// Extract agent redirects as well (for inter-agent communication)
|
|
303
|
-
const redirects = this.tagParser.extractAgentRedirects(message);
|
|
304
|
-
for (const redirect of redirects) {
|
|
305
|
-
commands.push({
|
|
306
|
-
toolId: TOOL_IDS.AGENT_COMMUNICATION,
|
|
307
|
-
content: JSON.stringify({
|
|
308
|
-
to: redirect.to,
|
|
309
|
-
message: redirect.content,
|
|
310
|
-
urgent: redirect.urgent,
|
|
311
|
-
requiresResponse: redirect.requiresResponse,
|
|
312
|
-
context: redirect.context
|
|
313
|
-
}),
|
|
314
|
-
type: COMMAND_FORMATS.REDIRECT,
|
|
315
|
-
isAsync: false,
|
|
316
|
-
raw: redirect.rawMatch,
|
|
317
|
-
position: {}
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
this.logger.debug(`Extracted ${commands.length} tool commands from message`, {
|
|
322
|
-
formats: commands.map(c => c.type),
|
|
323
|
-
tools: commands.map(c => c.toolId)
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
return commands;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Execute tool commands
|
|
331
|
-
* @param {Array} commands - Array of tool commands
|
|
332
|
-
* @param {Object} context - Execution context
|
|
333
|
-
* @returns {Promise<Array>} Array of execution results
|
|
334
|
-
*/
|
|
335
|
-
async executeTools(commands, context) {
|
|
336
|
-
const results = [];
|
|
337
|
-
|
|
338
|
-
for (const command of commands) {
|
|
339
|
-
try {
|
|
340
|
-
const tool = this.toolsRegistry.getTool(command.toolId);
|
|
341
|
-
|
|
342
|
-
if (!tool) {
|
|
343
|
-
results.push({
|
|
344
|
-
toolId: command.toolId,
|
|
345
|
-
status: 'failed',
|
|
346
|
-
error: `Tool not found: ${command.toolId}`,
|
|
347
|
-
timestamp: new Date().toISOString()
|
|
348
|
-
});
|
|
349
|
-
continue;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
this.logger.info(`Executing tool: ${command.toolId}`, {
|
|
353
|
-
agentId: context.agentId,
|
|
354
|
-
isAsync: command.isAsync
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
let result;
|
|
358
|
-
if (command.isAsync) {
|
|
359
|
-
result = await this.executeAsyncTool(command, tool, context);
|
|
360
|
-
} else {
|
|
361
|
-
// Synchronous tool execution
|
|
362
|
-
// If we have parameters object, use it. Otherwise parse the content.
|
|
363
|
-
let toolInput = command.parameters;
|
|
364
|
-
|
|
365
|
-
if (!toolInput && command.content) {
|
|
366
|
-
// Content is a string, need to parse it using tool's parseParameters method
|
|
367
|
-
if (typeof tool.parseParameters === 'function') {
|
|
368
|
-
try {
|
|
369
|
-
toolInput = tool.parseParameters(command.content);
|
|
370
|
-
this.logger?.debug(`Parsed parameters for tool: ${command.toolId}`, {
|
|
371
|
-
parsedKeys: Object.keys(toolInput)
|
|
372
|
-
});
|
|
373
|
-
} catch (error) {
|
|
374
|
-
this.logger?.warn(`Failed to parse parameters for tool: ${command.toolId}`, {
|
|
375
|
-
error: error.message
|
|
376
|
-
});
|
|
377
|
-
// Fall back to raw content
|
|
378
|
-
toolInput = command.content;
|
|
379
|
-
}
|
|
380
|
-
} else {
|
|
381
|
-
// Tool doesn't have parseParameters, use raw content
|
|
382
|
-
toolInput = command.content;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
// CRITICAL FIX: Unwrap TagParser format before tool execution
|
|
387
|
-
// TagParser wraps XML parameters in {value, attributes} objects
|
|
388
|
-
// This unwrapping makes all tools work consistently
|
|
389
|
-
if (toolInput && typeof toolInput === 'object') {
|
|
390
|
-
toolInput = this.unwrapParameters(toolInput);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
const toolResult = await tool.execute(toolInput, context);
|
|
394
|
-
result = {
|
|
395
|
-
toolId: command.toolId,
|
|
396
|
-
status: 'completed',
|
|
397
|
-
result: toolResult,
|
|
398
|
-
timestamp: new Date().toISOString()
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
results.push(result);
|
|
403
|
-
|
|
404
|
-
// Store in execution history
|
|
405
|
-
const historyKey = `${context.agentId}-${Date.now()}`;
|
|
406
|
-
this.executionHistory.set(historyKey, {
|
|
407
|
-
...result,
|
|
408
|
-
agentId: context.agentId,
|
|
409
|
-
sessionId: context.sessionId
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
} catch (error) {
|
|
413
|
-
this.logger.error(`Tool execution failed: ${command.toolId}`, {
|
|
414
|
-
error: error.message,
|
|
415
|
-
agentId: context.agentId
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
results.push({
|
|
419
|
-
toolId: command.toolId,
|
|
420
|
-
status: 'failed',
|
|
421
|
-
error: error.message,
|
|
422
|
-
timestamp: new Date().toISOString()
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
return results;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* Execute async tool
|
|
432
|
-
* @param {Object} command - Tool command
|
|
433
|
-
* @param {Object} tool - Tool instance
|
|
434
|
-
* @param {Object} context - Execution context
|
|
435
|
-
* @returns {Promise<Object>} Async operation reference
|
|
436
|
-
*/
|
|
437
|
-
async executeAsyncTool(command, tool, context) {
|
|
438
|
-
const operationId = `async-${Date.now()}-${this.operationCounter++}`;
|
|
439
|
-
|
|
440
|
-
// Create async operation entry
|
|
441
|
-
const operation = {
|
|
442
|
-
id: operationId,
|
|
443
|
-
toolId: command.toolId,
|
|
444
|
-
agentId: context.agentId,
|
|
445
|
-
status: 'pending',
|
|
446
|
-
startTime: new Date().toISOString(),
|
|
447
|
-
context: context
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
this.asyncOperations.set(operationId, operation);
|
|
451
|
-
|
|
452
|
-
// Start async execution
|
|
453
|
-
// If we have parameters object, use it. Otherwise parse the content.
|
|
454
|
-
let toolInput = command.parameters;
|
|
455
|
-
|
|
456
|
-
if (!toolInput && command.content) {
|
|
457
|
-
// Content is a string, need to parse it using tool's parseParameters method
|
|
458
|
-
if (typeof tool.parseParameters === 'function') {
|
|
459
|
-
try {
|
|
460
|
-
toolInput = tool.parseParameters(command.content);
|
|
461
|
-
} catch (error) {
|
|
462
|
-
this.logger?.warn(`Failed to parse parameters for async tool: ${command.toolId}`, {
|
|
463
|
-
error: error.message
|
|
464
|
-
});
|
|
465
|
-
// Fall back to raw content
|
|
466
|
-
toolInput = command.content;
|
|
467
|
-
}
|
|
468
|
-
} else {
|
|
469
|
-
// Tool doesn't have parseParameters, use raw content
|
|
470
|
-
toolInput = command.content;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
// CRITICAL FIX: Unwrap TagParser format before tool execution
|
|
475
|
-
// TagParser wraps XML parameters in {value, attributes} objects
|
|
476
|
-
// This unwrapping makes all tools work consistently
|
|
477
|
-
if (toolInput && typeof toolInput === 'object') {
|
|
478
|
-
toolInput = this.unwrapParameters(toolInput);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
tool.execute(toolInput, context)
|
|
482
|
-
.then(result => {
|
|
483
|
-
operation.status = 'completed';
|
|
484
|
-
operation.result = result;
|
|
485
|
-
operation.endTime = new Date().toISOString();
|
|
486
|
-
this.notifyAgentOfToolCompletion(operation);
|
|
487
|
-
})
|
|
488
|
-
.catch(error => {
|
|
489
|
-
operation.status = 'failed';
|
|
490
|
-
operation.error = error.message;
|
|
491
|
-
operation.endTime = new Date().toISOString();
|
|
492
|
-
this.notifyAgentOfToolCompletion(operation);
|
|
493
|
-
});
|
|
494
|
-
|
|
495
|
-
// Start monitoring
|
|
496
|
-
this.monitorAsyncOperation(operationId);
|
|
497
|
-
|
|
498
|
-
return {
|
|
499
|
-
toolId: command.toolId,
|
|
500
|
-
status: 'async-pending',
|
|
501
|
-
operationId: operationId,
|
|
502
|
-
message: `Async tool started with operation ID: ${operationId}`,
|
|
503
|
-
timestamp: new Date().toISOString()
|
|
504
|
-
};
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
/**
|
|
508
|
-
* Monitor async operation
|
|
509
|
-
* @param {string} operationId - Operation ID to monitor
|
|
510
|
-
*/
|
|
511
|
-
async monitorAsyncOperation(operationId) {
|
|
512
|
-
const checkInterval = 5000; // 5 seconds
|
|
513
|
-
const maxChecks = 120; // 10 minutes max
|
|
514
|
-
let checks = 0;
|
|
515
|
-
|
|
516
|
-
const monitor = setInterval(() => {
|
|
517
|
-
const operation = this.asyncOperations.get(operationId);
|
|
518
|
-
|
|
519
|
-
if (!operation) {
|
|
520
|
-
clearInterval(monitor);
|
|
521
|
-
return;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
checks++;
|
|
525
|
-
|
|
526
|
-
if (operation.status !== 'pending' || checks >= maxChecks) {
|
|
527
|
-
clearInterval(monitor);
|
|
528
|
-
|
|
529
|
-
if (checks >= maxChecks) {
|
|
530
|
-
operation.status = 'timeout';
|
|
531
|
-
operation.error = 'Operation timed out';
|
|
532
|
-
operation.endTime = new Date().toISOString();
|
|
533
|
-
this.notifyAgentOfToolCompletion(operation);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
}, checkInterval);
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
/**
|
|
540
|
-
* Notify agent of tool completion
|
|
541
|
-
* @param {Object} operation - Completed operation
|
|
542
|
-
*/
|
|
543
|
-
async notifyAgentOfToolCompletion(operation) {
|
|
544
|
-
if (!operation.agentId) return;
|
|
545
|
-
|
|
546
|
-
try {
|
|
547
|
-
// Queue tool result for the agent
|
|
548
|
-
await this.agentPool.addToolResult(operation.agentId, {
|
|
549
|
-
toolId: operation.toolId,
|
|
550
|
-
status: operation.status,
|
|
551
|
-
result: operation.result,
|
|
552
|
-
error: operation.error,
|
|
553
|
-
executionTime: operation.endTime ?
|
|
554
|
-
new Date(operation.endTime) - new Date(operation.startTime) : null,
|
|
555
|
-
timestamp: operation.endTime || new Date().toISOString()
|
|
556
|
-
});
|
|
557
|
-
|
|
558
|
-
// Add agent back to scheduler if needed
|
|
559
|
-
if (this.scheduler) {
|
|
560
|
-
await this.scheduler.addAgent(operation.agentId, {
|
|
561
|
-
triggeredBy: 'tool-completion',
|
|
562
|
-
sessionId: operation.context?.sessionId
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
this.logger.info(`Agent notified of tool completion: ${operation.agentId}`, {
|
|
567
|
-
toolId: operation.toolId,
|
|
568
|
-
status: operation.status
|
|
569
|
-
});
|
|
570
|
-
|
|
571
|
-
} catch (error) {
|
|
572
|
-
this.logger.error(`Failed to notify agent of tool completion`, {
|
|
573
|
-
agentId: operation.agentId,
|
|
574
|
-
toolId: operation.toolId,
|
|
575
|
-
error: error.message
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
/**
|
|
581
|
-
* Get tool status
|
|
582
|
-
* @param {string} operationId - Operation ID
|
|
583
|
-
* @returns {Promise<Object>} Operation status
|
|
584
|
-
*/
|
|
585
|
-
async getToolStatus(operationId) {
|
|
586
|
-
const operation = this.asyncOperations.get(operationId);
|
|
587
|
-
|
|
588
|
-
if (!operation) {
|
|
589
|
-
return {
|
|
590
|
-
status: 'not-found',
|
|
591
|
-
error: `Operation not found: ${operationId}`
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
return {
|
|
596
|
-
id: operation.id,
|
|
597
|
-
toolId: operation.toolId,
|
|
598
|
-
status: operation.status,
|
|
599
|
-
result: operation.result,
|
|
600
|
-
error: operation.error,
|
|
601
|
-
startTime: operation.startTime,
|
|
602
|
-
endTime: operation.endTime
|
|
603
|
-
};
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
/**
|
|
607
|
-
* Extract and execute tools from content
|
|
608
|
-
* Called by AgentScheduler after getting AI response
|
|
609
|
-
* @param {string} content - Content containing tool commands
|
|
610
|
-
* @param {string} agentId - Agent ID
|
|
611
|
-
* @param {Object} context - Execution context
|
|
612
|
-
* @returns {Promise<Array>} Tool execution results
|
|
613
|
-
*/
|
|
614
|
-
async extractAndExecuteTools(content, agentId, context) {
|
|
615
|
-
try {
|
|
616
|
-
// Extract tool commands
|
|
617
|
-
const commands = await this.extractToolCommands(content);
|
|
618
|
-
|
|
619
|
-
if (commands.length === 0) {
|
|
620
|
-
return [];
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
// Get agent to include its directoryAccess configuration
|
|
624
|
-
const agent = await this.agentPool.getAgent(agentId);
|
|
625
|
-
|
|
626
|
-
// Execute tools with agent context including sessionId and directoryAccess
|
|
627
|
-
const toolContext = {
|
|
628
|
-
...context,
|
|
629
|
-
agentId,
|
|
630
|
-
sessionId: context.sessionId, // Ensure sessionId is explicitly available for tools
|
|
631
|
-
directoryAccess: agent?.directoryAccess, // Include agent's directory access configuration
|
|
632
|
-
projectDir: agent?.directoryAccess?.workingDirectory || agent?.projectDir || context.projectDir, // Extract project directory from directoryAccess
|
|
633
|
-
agentPool: this.agentPool,
|
|
634
|
-
contextManager: this.contextManager,
|
|
635
|
-
aiService: this.aiService,
|
|
636
|
-
messageProcessor: this,
|
|
637
|
-
orchestrator: this.orchestrator
|
|
638
|
-
};
|
|
639
|
-
|
|
640
|
-
const results = await this.executeTools(commands, toolContext);
|
|
641
|
-
|
|
642
|
-
this.logger.info(`Executed ${results.length} tools for agent: ${agentId}`, {
|
|
643
|
-
tools: results.map(r => ({ toolId: r.toolId, status: r.status }))
|
|
644
|
-
});
|
|
645
|
-
|
|
646
|
-
return results;
|
|
647
|
-
|
|
648
|
-
} catch (error) {
|
|
649
|
-
this.logger.error(`Tool extraction/execution failed for agent: ${agentId}`, {
|
|
650
|
-
error: error.message
|
|
651
|
-
});
|
|
652
|
-
return [];
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
/**
|
|
657
|
-
* Stop autonomous execution for an agent
|
|
658
|
-
* Proxy method to AgentScheduler
|
|
659
|
-
* @param {string} agentId - Agent ID to stop
|
|
660
|
-
* @returns {Promise<Object>} Result with agent state
|
|
661
|
-
*/
|
|
662
|
-
async stopAutonomousExecution(agentId) {
|
|
663
|
-
if (!this.scheduler) {
|
|
664
|
-
return {
|
|
665
|
-
success: false,
|
|
666
|
-
error: 'Scheduler not available'
|
|
667
|
-
};
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
return await this.scheduler.stopAgentExecution(agentId);
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
/**
|
|
674
|
-
* Inject tool results into conversation
|
|
675
|
-
* @param {string} agentId - Agent ID
|
|
676
|
-
* @param {Array} toolResults - Tool execution results
|
|
677
|
-
* @returns {Promise<void>}
|
|
678
|
-
*/
|
|
679
|
-
async injectToolResultsIntoConversation(agentId, toolResults) {
|
|
680
|
-
const agent = await this.agentPool.getAgent(agentId);
|
|
681
|
-
if (!agent) return;
|
|
682
|
-
|
|
683
|
-
for (const result of toolResults) {
|
|
684
|
-
const toolMessage = {
|
|
685
|
-
id: `tool-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
686
|
-
role: 'system',
|
|
687
|
-
content: this.formatToolResultForAgent(result),
|
|
688
|
-
timestamp: new Date().toISOString(),
|
|
689
|
-
type: 'tool-result',
|
|
690
|
-
toolId: result.toolId,
|
|
691
|
-
status: result.status
|
|
692
|
-
};
|
|
693
|
-
|
|
694
|
-
// Add to conversation history
|
|
695
|
-
agent.conversations.full.messages.push(toolMessage);
|
|
696
|
-
|
|
697
|
-
// Also add to current model conversation if exists
|
|
698
|
-
if (agent.currentModel && agent.conversations[agent.currentModel]) {
|
|
699
|
-
agent.conversations[agent.currentModel].messages.push(toolMessage);
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
// Update last activity
|
|
704
|
-
agent.conversations.full.lastUpdated = new Date().toISOString();
|
|
705
|
-
if (agent.currentModel && agent.conversations[agent.currentModel]) {
|
|
706
|
-
agent.conversations[agent.currentModel].lastUpdated = new Date().toISOString();
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
await this.agentPool.persistAgentState(agentId);
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
/**
|
|
713
|
-
* Format tool result for agent consumption
|
|
714
|
-
* @param {Object} result - Tool execution result
|
|
715
|
-
* @returns {string} Formatted result
|
|
716
|
-
*/
|
|
717
|
-
formatToolResultForAgent(result) {
|
|
718
|
-
if (result.status === 'completed') {
|
|
719
|
-
if (typeof result.result === 'object') {
|
|
720
|
-
return `Tool ${result.toolId} completed successfully:\n${JSON.stringify(result.result, null, 2)}`;
|
|
721
|
-
}
|
|
722
|
-
return `Tool ${result.toolId} completed successfully:\n${result.result}`;
|
|
723
|
-
} else if (result.status === 'failed') {
|
|
724
|
-
return `Tool ${result.toolId} failed: ${result.error || 'Unknown error'}`;
|
|
725
|
-
} else if (result.status === 'async-pending') {
|
|
726
|
-
return `Tool ${result.toolId} is running asynchronously (Operation ID: ${result.operationId})`;
|
|
727
|
-
}
|
|
728
|
-
return `Tool ${result.toolId} status: ${result.status}`;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
export default MessageProcessor;
|
|
1
|
+
function a0_0x5a93(){const _0xebb6e0=['AxnjBNrLCKfNzw50twvZC2fNzq','ignVBxbSzxrLzcbZDwnJzxnZzNvSBhK6cG','Bg9Nz2vY','zM9YBwf0vg9VBfjLC3vSDezVCKfNzw50','rxHLy3v0Aw5NihrVB2W6ia','DxnLCG','ywDLBNrqB29S','z2v0vg9VBfn0yxr1CW','zxHLy3v0Aw9UsgLZDg9YEq','Dg9VBc1Yzxn1Bhq','mtG2B0rkBvri','mZKZndm1rfLzr0rx','zxjYB3i','mtCYmty5mZbZs2nmsw8','Dg9VBhnszwDPC3rYEq','Aw5MBW','BwvZC2fNzxm','DMfSDwu','vw5RBM93BIbLCNjVCG','zNvSBa','CMvZDwX0','ywrKvxnLCK1LC3nHz2u','u2nOzwr1BgvYig5VDcbHDMfPBgfIBgu','BM9YBwfSAxPLvg9VBenVBw1HBMq','BgvUz3rO','y2f0y2G','Bw9UAxrVCKfZEw5Jt3bLCMf0Aw9U','ChjVAMvJDerPCG','CgfYyw1LDgvYCW','ndvfD1P1C3O','C3rHCNruAw1L','B2jQzwn0','zw50CMLLCW','DhLWzq','zxHLyW','y29UDgvUDa','y29UDgv4De1HBMfNzxi','ywLtzxj2AwnL','Bw9KzwXZu2vYDMLJzq','C2nOzwr1BgvY','mtjrvNDzwwW','twvZC2fNzvbYB2nLC3nVCIberujvrZOGBM9YBwfSAxPLzcbytuWGy29TBwfUzdO','nJGYnJq3meTTu21guq','zxH0CMfJDfrVB2XdB21Tyw5KCW','qxn5BMmGDg9VBcbZDgfYDgvKihDPDgGGB3bLCMf0Aw9UieLeoIa','CgfYC2vqyxjHBwv0zxjZ','C2v0','Dhj1zq','rxH0CMfJDgvKia','C3rYAw5NAwz5','rMfPBgvKihrVig5VDgLMEsbHz2vUDcbVzIb0B29SignVBxbSzxrPB24','CMf3q29UDgvUDa','mtu3EMDnrKHf','C3rHDhvZ','z2v0vg9VBa','DxjNzw50','Dg9VBeLK','y29UDgv4DfjLzMvYzw5Jzxm','ChjVy2vZC01LC3nHz2u','ChvZAa','zxH0CMfJDefUzev4zwn1DgvuB29SCW','mty0nJG3mdvPuM5qtgm','t3bLCMf0Aw9Uig5VDcbMB3vUzdOG','qwDLBNqGBM90igzVDw5KoIa','B3bLCMf0Aw9Uq291BNrLCG','yxn5BMm','ihn0yxr1CZOG','B3jPz2LUywXtzw5Kzxi','zw5KvgLTzq','Bg9N','C2vZC2LVBKLK','yxn5BMnpCgvYyxrPB25Z','Aw5KzxG','z2v0qwDLBNq','we1m','vg9VBcbLEhrYywn0Aw9Ul2v4zwn1DgLVBIbMywLSzwqGzM9YigfNzw50oIa','DhjPBq','B3jJAgvZDhjHDg9Y','ywrKsw50zxjbz2vUDe1LC3nHz2u','y29UDMvYC2f0Aw9UCW','BwvZC2fNzq','vg9VBcbUB3qGzM91BMq6ia','Bw9KzwXsB3v0zxjtzxj2AwnL','zgvJB2rLshrTBevUDgL0AwvZ','zxHLy3v0zvrVB2XZ','AxnbC3LUyW','ihrVB2XZigzVCIbHz2vUDdOG','A2v5CW','BgfZDfvWzgf0zwq','y29UDgv4Da','D2vIu29JA2v0twfUywDLCG','ywDLBNrjza','C2v0u2nOzwr1BgvY','Dg9tDhjPBMC','qLjbq0Tfva','ywrKvg9VBfjLC3vSDa','C3vIC3rYAw5N','BwfW','CgvYC2LZDefNzw50u3rHDgu','uxvLDwvPBMCGBwvZC2fNzsbMB3iGywDLBNq6ia','C3LZDgvT','Dw53CMfWugfYyw1LDgvYCW','DgfNugfYC2vY','uKvesvjfq1q','rMfPBgvKihrVihbHCNnLihbHCMfTzxrLCNmGzM9YihrVB2W6ia','zNvUy3rPB24','D2fYBG','Cg9ZAxrPB24','zgLYzwn0B3j5qwnJzxnZ','zgvIDwC','vg9VBca','mtq3nZC0nfrPwKXMua','mty1otzwD1fPz00','mtiZmJm5mwPcuNr4sG','Dg9ju09tDhjPBMC','BM90Awz5qwDLBNrpzLrVB2XdB21WBgv0Aw9U','x2f0DhjPyNv0zxm','C29Tzq','sw52ywXPzcbytuWGCgfYyw1LDgvYCYbYzxr1CM5Lza','zMfPBgvK','vg9VBcbLEgvJDxrPB24GzMfPBgvKoIa','twvZC2fNzvbYB2nLC3nVCIberujvrZOGBM8Gwe1migrLDgvJDgvKlcb0CMvHDgLUzYbHCYbZAw1WBguGyNjHy2TLDcbJB21Tyw5K','zxHLy3v0zufZEw5Jvg9VBa','y3vYCMvUDe1VzgvS','BM93','D29YA2LUz0rPCMvJDg9YEq','twvZC2fNzvbYB2nLC3nVCIberujvrZOGy2HLy2TPBMCGyNjHy2TLDcbWyxr0zxjUig9Uig1LC3nHz2uGBgvUz3rOoG','DgvZDa'];a0_0x5a93=function(){return _0xebb6e0;};return a0_0x5a93();}function a0_0x5c36(_0x42c937,_0x148d59){_0x42c937=_0x42c937-0x78;const _0x5a931e=a0_0x5a93();let _0x5c3604=_0x5a931e[_0x42c937];if(a0_0x5c36['ZLyiuX']===undefined){var _0x5086b6=function(_0x38011d){const _0x1092e6='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x520abe='',_0x14cb11='';for(let _0x438e4b=0x0,_0x3b0f11,_0x5bc3cf,_0xae8bb9=0x0;_0x5bc3cf=_0x38011d['charAt'](_0xae8bb9++);~_0x5bc3cf&&(_0x3b0f11=_0x438e4b%0x4?_0x3b0f11*0x40+_0x5bc3cf:_0x5bc3cf,_0x438e4b++%0x4)?_0x520abe+=String['fromCharCode'](0xff&_0x3b0f11>>(-0x2*_0x438e4b&0x6)):0x0){_0x5bc3cf=_0x1092e6['indexOf'](_0x5bc3cf);}for(let _0x19bd84=0x0,_0x5d07dc=_0x520abe['length'];_0x19bd84<_0x5d07dc;_0x19bd84++){_0x14cb11+='%'+('00'+_0x520abe['charCodeAt'](_0x19bd84)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x14cb11);};a0_0x5c36['DgYfhC']=_0x5086b6,a0_0x5c36['SwXKLC']={},a0_0x5c36['ZLyiuX']=!![];}const _0x40d223=_0x5a931e[0x0],_0x273423=_0x42c937+_0x40d223,_0x5ed500=a0_0x5c36['SwXKLC'][_0x273423];return!_0x5ed500?(_0x5c3604=a0_0x5c36['DgYfhC'](_0x5c3604),a0_0x5c36['SwXKLC'][_0x273423]=_0x5c3604):_0x5c3604=_0x5ed500,_0x5c3604;}const a0_0xfd677d=a0_0x5c36;(function(_0x492afd,_0x3340ae){const _0x1fda47=a0_0x5c36,_0x4c70ac=_0x492afd();while(!![]){try{const _0x4beb26=-parseInt(_0x1fda47(0xc3))/0x1*(parseInt(_0x1fda47(0x7f))/0x2)+parseInt(_0x1fda47(0x80))/0x3*(parseInt(_0x1fda47(0xb7))/0x4)+-parseInt(_0x1fda47(0xb9))/0x5+-parseInt(_0x1fda47(0x99))/0x6*(parseInt(_0x1fda47(0x9a))/0x7)+parseInt(_0x1fda47(0x7e))/0x8*(parseInt(_0x1fda47(0xac))/0x9)+parseInt(_0x1fda47(0x9c))/0xa+parseInt(_0x1fda47(0xcc))/0xb;if(_0x4beb26===_0x3340ae)break;else _0x4c70ac['push'](_0x4c70ac['shift']());}catch(_0x31d4b6){_0x4c70ac['push'](_0x4c70ac['shift']());}}}(a0_0x5a93,0xeb72a));import{AGENT_MODES,AGENT_MODE_STATES}from'../utilities/constants.js';import a0_0x520abe from'../utilities/tagParser.js';import{TOOL_IDS,COMMAND_FORMATS}from'../utilities/toolConstants.js';class MessageProcessor{constructor(_0x14cb11,_0x438e4b,_0x3b0f11,_0x5bc3cf,_0xae8bb9,_0x19bd84,_0x5d07dc=null,_0x49e423=null){const _0x3b694c=a0_0x5c36;this['config']=_0x14cb11,this[_0x3b694c(0x91)]=_0x438e4b,this['toolsRegistry']=_0x3b0f11,this['agentPool']=_0x5bc3cf,this['contextManager']=_0xae8bb9,this[_0x3b694c(0xb4)]=_0x19bd84,this[_0x3b694c(0xe1)]=_0x5d07dc,this[_0x3b694c(0xb5)]=_0x49e423,this['asyncOperations']=new Map(),this[_0x3b694c(0x97)]=new Map(),this[_0x3b694c(0xcf)]=0x0,this[_0x3b694c(0xe9)]=null,this[_0x3b694c(0xb6)]=null,this['orchestrator']=null,this[_0x3b694c(0xf5)]=new a0_0x520abe();}['setWebSocketManager'](_0x2fa7d3){this['webSocketManager']=_0x2fa7d3,this['logger']?.['info']('WebSocket\x20manager\x20set\x20for\x20MessageProcessor',{'hasManager':!!_0x2fa7d3});}[a0_0xfd677d(0xeb)](_0x2d9b39){const _0x24144c=a0_0xfd677d;this[_0x24144c(0xb6)]=_0x2d9b39,this[_0x24144c(0x91)]?.[_0x24144c(0x9e)]('AgentScheduler\x20set\x20for\x20MessageProcessor',{'hasScheduler':!!_0x2d9b39});}async[a0_0xfd677d(0xc9)](_0x4bd471,_0x216034,_0x4e8326={}){const _0x4412b0=a0_0xfd677d,_0x2f4da1=await this['agentPool']['getAgent'](_0x4bd471);if(!_0x2f4da1)throw new Error(_0x4412b0(0xce)+_0x4bd471);const _0x4a983f=typeof _0x216034==='string'?_0x216034:_0x216034?JSON[_0x4412b0(0xc0)](_0x216034):'';return this[_0x4412b0(0x91)][_0x4412b0(0x9e)](_0x4412b0(0xf2)+_0x4bd471,{'messageLength':_0x4a983f['length'],'messageType':typeof _0x216034,'isInterAgentMessage':_0x4e8326['isInterAgentMessage'],'contextMessageType':_0x4e8326['messageType']||_0x4412b0(0x94)}),_0x4e8326['isInterAgentMessage']?await this[_0x4412b0(0x95)][_0x4412b0(0xdd)](_0x4bd471,{'content':_0x216034,'sender':_0x4e8326[_0x4412b0(0xd2)],'senderName':_0x4e8326['senderName'],'subject':_0x4e8326['subject']||'Inter-agent\x20message','timestamp':new Date()[_0x4412b0(0x81)](),'sessionId':_0x4e8326[_0x4412b0(0xd5)],'requiresReply':_0x4e8326['requiresReply']||![]}):await this['agentPool'][_0x4412b0(0xa4)](_0x4bd471,{'content':_0x216034,'role':_0x4412b0(0x94),'timestamp':new Date()[_0x4412b0(0x81)](),'contextReferences':_0x4e8326[_0x4412b0(0xc8)]||[],'sessionId':_0x4e8326[_0x4412b0(0xd5)]}),this[_0x4412b0(0xb6)]&&await this['scheduler']['addAgent'](_0x4bd471,{'triggeredBy':_0x4e8326[_0x4412b0(0x8f)]?'inter-agent-message':'user-message','sessionId':_0x4e8326['sessionId']}),{'success':!![],'message':'Message\x20queued\x20for\x20processing','agentId':_0x4bd471,'queuedAt':new Date()['toISOString']()};}[a0_0xfd677d(0xf4)](_0x1ef50d){const _0x27ba74=a0_0xfd677d;if(!_0x1ef50d||typeof _0x1ef50d!=='object')return _0x1ef50d;const _0x3473fc={};for(const [_0x2fe2c4,_0x399baa]of Object[_0x27ba74(0xaf)](_0x1ef50d)){_0x399baa&&typeof _0x399baa==='object'&&'value'in _0x399baa&&'attributes'in _0x399baa?(_0x3473fc[_0x2fe2c4]=_0x399baa[_0x27ba74(0xa0)],_0x399baa['attributes']&&Object[_0x27ba74(0xe6)](_0x399baa['attributes'])['length']>0x0&&(_0x3473fc[_0x2fe2c4+_0x27ba74(0x83)]=_0x399baa['attributes'])):_0x3473fc[_0x2fe2c4]=_0x399baa;}return _0x3473fc;}async[a0_0xfd677d(0xba)](_0x4d8c53){const _0x762773=a0_0xfd677d,_0xce9030=[],_0x5e351=this[_0x762773(0xf5)][_0x762773(0xba)](_0x4d8c53);for(const _0x2fad9c of _0x5e351){const _0x522805=this['tagParser'][_0x762773(0xa6)](_0x2fad9c);_0xce9030[_0x762773(0xca)]({'toolId':_0x522805['toolId'],'content':JSON['stringify'](_0x522805[_0x762773(0xab)]),'parameters':_0x522805['parameters'],'type':_0x522805[_0x762773(0xb0)],'isAsync':_0x522805[_0x762773(0xab)]?.[_0x762773(0xd0)]===!![],'raw':_0x522805[_0x762773(0xc2)],'position':_0x2fad9c[_0x762773(0x7a)]||{}});}const _0x43b45f=/\[tool\s+id="([^"]+)"(?:\s+async="(true|false)")?\]([\s\S]*?)\[\/tool\]/gi;console['log'](_0x762773(0x8d),_0x4d8c53['length']);let _0x4e6d6f;while((_0x4e6d6f=_0x43b45f[_0x762773(0xb1)](_0x4d8c53))!==null){const [_0x2b7c67,_0x2a1f87,_0x259fe2,_0x4ab3de]=_0x4e6d6f;console['log']('MessageProcessor\x20DEBUG:\x20bracket\x20pattern\x20matched:',{'toolId':_0x2a1f87[_0x762773(0xdb)](),'contentLength':_0x4ab3de[_0x762773(0xdb)]()['length'],'contentPreview':_0x4ab3de[_0x762773(0xdb)]()[_0x762773(0xef)](0x0,0x64)});const _0x2b7004=_0xce9030[_0x762773(0x84)](_0x27753e=>_0x27753e['raw']===_0x2b7c67||_0x27753e[_0x762773(0x7a)]['start']===_0x4e6d6f[_0x762773(0xd7)]&&_0x27753e['position']['end']===_0x4e6d6f[_0x762773(0xd7)]+_0x2b7c67[_0x762773(0xa7)]);if(!_0x2b7004){console[_0x762773(0xd4)]('MessageProcessor\x20DEBUG:\x20adding\x20bracket\x20command\x20(not\x20already\x20extracted\x20by\x20TagParser)');const _0x4902f3=_0x4ab3de['trim'](),_0x3500df=/<[^>]+>/g[_0x762773(0x8e)](_0x4902f3);if(_0x3500df){console[_0x762773(0xd4)]('MessageProcessor\x20DEBUG:\x20detected\x20XML\x20content\x20inside\x20brackets,\x20parsing\x20with\x20TagParser');const _0x235ade=this['tagParser'][_0x762773(0xe2)](_0x4902f3);console['log']('MessageProcessor\x20DEBUG:\x20HTML\x20decoding\x20changed\x20content:',_0x4902f3!==_0x235ade);try{const _0x12061a=this['tagParser']['parseXMLParameters'](_0x235ade);console['log']('MessageProcessor\x20DEBUG:\x20XML\x20parameters\x20extracted:',Object['keys'](_0x12061a));if(!_0x12061a||typeof _0x12061a!==_0x762773(0xae))throw new Error(_0x762773(0x85));const _0x3e123c={'type':COMMAND_FORMATS[_0x762773(0xd9)],'toolId':_0x2a1f87[_0x762773(0xdb)](),'parameters':_0x12061a,'rawContent':_0x235ade},_0x249026=this[_0x762773(0xf5)][_0x762773(0xa6)](_0x3e123c);console['log'](_0x762773(0xb8),{'toolId':_0x249026[_0x762773(0xc7)],'hasActions':!!_0x249026['parameters']['actions'],'actionsLength':_0x249026['parameters']['actions']?.[_0x762773(0xa7)]||0x0}),_0xce9030[_0x762773(0xca)]({'toolId':_0x249026['toolId'],'content':JSON['stringify'](_0x249026['parameters']),'parameters':_0x249026['parameters'],'type':COMMAND_FORMATS['XML'],'isAsync':_0x259fe2==='true','raw':_0x2b7c67,'position':{'start':_0x4e6d6f[_0x762773(0xd7)],'end':_0x4e6d6f[_0x762773(0xd7)]+_0x2b7c67['length']}});}catch(_0x2e01a1){console['log']('MessageProcessor\x20DEBUG:\x20XML\x20parsing\x20failed:',_0x2e01a1[_0x762773(0xdf)]),console[_0x762773(0xd4)]('MessageProcessor\x20DEBUG:\x20falling\x20back\x20to\x20raw\x20bracket\x20format'),_0xce9030['push']({'toolId':_0x2a1f87[_0x762773(0xdb)](),'content':_0x4902f3,'type':COMMAND_FORMATS['BRACKET'],'isAsync':_0x259fe2==='true','raw':_0x2b7c67,'position':{'start':_0x4e6d6f['index'],'end':_0x4e6d6f[_0x762773(0xd7)]+_0x2b7c67['length']}});}}else console[_0x762773(0xd4)](_0x762773(0x88)),_0xce9030['push']({'toolId':_0x2a1f87['trim'](),'content':_0x4902f3,'type':COMMAND_FORMATS[_0x762773(0xed)],'isAsync':_0x259fe2===_0x762773(0xbe),'raw':_0x2b7c67,'position':{'start':_0x4e6d6f['index'],'end':_0x4e6d6f[_0x762773(0xd7)]+_0x2b7c67[_0x762773(0xa7)]}});}else console[_0x762773(0xd4)]('MessageProcessor\x20DEBUG:\x20bracket\x20command\x20already\x20extracted\x20by\x20TagParser,\x20skipping');}const _0x17cd75=this[_0x762773(0xf5)]['extractAgentRedirects'](_0x4d8c53);for(const _0x4306f7 of _0x17cd75){_0xce9030['push']({'toolId':TOOL_IDS['AGENT_COMMUNICATION'],'content':JSON[_0x762773(0xc0)]({'to':_0x4306f7['to'],'message':_0x4306f7[_0x762773(0xb2)],'urgent':_0x4306f7[_0x762773(0xc6)],'requiresResponse':_0x4306f7['requiresResponse'],'context':_0x4306f7[_0x762773(0xe8)]}),'type':COMMAND_FORMATS[_0x762773(0xf6)],'isAsync':![],'raw':_0x4306f7['rawMatch'],'position':{}});}return this[_0x762773(0x91)][_0x762773(0x7c)](_0x762773(0xbf)+_0xce9030[_0x762773(0xa7)]+'\x20tool\x20commands\x20from\x20message',{'formats':_0xce9030['map'](_0x50b8b0=>_0x50b8b0['type']),'tools':_0xce9030[_0x762773(0xf0)](_0x5f2e8b=>_0x5f2e8b['toolId'])}),_0xce9030;}async['executeTools'](_0x51c7a7,_0x122d86){const _0x1bbfe1=a0_0xfd677d,_0x51ec5d=[];for(const _0x4642fe of _0x51c7a7){try{const _0x1b6b99=this[_0x1bbfe1(0x9d)][_0x1bbfe1(0xc5)](_0x4642fe[_0x1bbfe1(0xc7)]);if(!_0x1b6b99){_0x51ec5d['push']({'toolId':_0x4642fe[_0x1bbfe1(0xc7)],'status':_0x1bbfe1(0x86),'error':_0x1bbfe1(0xe0)+_0x4642fe['toolId'],'timestamp':new Date()[_0x1bbfe1(0x81)]()});continue;}this['logger']['info'](_0x1bbfe1(0x93)+_0x4642fe[_0x1bbfe1(0xc7)],{'agentId':_0x122d86[_0x1bbfe1(0xea)],'isAsync':_0x4642fe[_0x1bbfe1(0xe4)]});let _0x553b0d;if(_0x4642fe['isAsync'])_0x553b0d=await this[_0x1bbfe1(0x89)](_0x4642fe,_0x1b6b99,_0x122d86);else{let _0xbb3b23=_0x4642fe[_0x1bbfe1(0xab)];if(!_0xbb3b23&&_0x4642fe['content']){if(typeof _0x1b6b99['parseParameters']===_0x1bbfe1(0x78))try{_0xbb3b23=_0x1b6b99['parseParameters'](_0x4642fe['content']),this['logger']?.[_0x1bbfe1(0x7c)]('Parsed\x20parameters\x20for\x20tool:\x20'+_0x4642fe[_0x1bbfe1(0xc7)],{'parsedKeys':Object[_0x1bbfe1(0xe6)](_0xbb3b23)});}catch(_0x32ab30){this['logger']?.['warn'](_0x1bbfe1(0xf7)+_0x4642fe['toolId'],{'error':_0x32ab30[_0x1bbfe1(0xdf)]}),_0xbb3b23=_0x4642fe[_0x1bbfe1(0xb2)];}else _0xbb3b23=_0x4642fe[_0x1bbfe1(0xb2)];}_0xbb3b23&&typeof _0xbb3b23===_0x1bbfe1(0xae)&&(_0xbb3b23=this[_0x1bbfe1(0xf4)](_0xbb3b23));const _0x3e66e1=await _0x1b6b99['execute'](_0xbb3b23,_0x122d86);_0x553b0d={'toolId':_0x4642fe['toolId'],'status':'completed','result':_0x3e66e1,'timestamp':new Date()['toISOString']()};}_0x51ec5d[_0x1bbfe1(0xca)](_0x553b0d);const _0x23f39d=_0x122d86['agentId']+'-'+Date[_0x1bbfe1(0x8b)]();this['executionHistory'][_0x1bbfe1(0xbd)](_0x23f39d,{..._0x553b0d,'agentId':_0x122d86[_0x1bbfe1(0xea)],'sessionId':_0x122d86[_0x1bbfe1(0xd5)]});}catch(_0x11e1b0){this['logger']['error'](_0x1bbfe1(0x87)+_0x4642fe['toolId'],{'error':_0x11e1b0['message'],'agentId':_0x122d86[_0x1bbfe1(0xea)]}),_0x51ec5d[_0x1bbfe1(0xca)]({'toolId':_0x4642fe[_0x1bbfe1(0xc7)],'status':_0x1bbfe1(0x86),'error':_0x11e1b0[_0x1bbfe1(0xdf)],'timestamp':new Date()['toISOString']()});}}return _0x51ec5d;}async[a0_0xfd677d(0x89)](_0x4bea1a,_0x5ebde8,_0x4a7e50){const _0x2b7528=a0_0xfd677d,_0x2ebf2d='async-'+Date['now']()+'-'+this[_0x2b7528(0xcf)]++,_0x40f9fa={'id':_0x2ebf2d,'toolId':_0x4bea1a[_0x2b7528(0xc7)],'agentId':_0x4a7e50[_0x2b7528(0xea)],'status':'pending','startTime':new Date()[_0x2b7528(0x81)](),'context':_0x4a7e50};this['asyncOperations'][_0x2b7528(0xbd)](_0x2ebf2d,_0x40f9fa);let _0x256666=_0x4bea1a['parameters'];if(!_0x256666&&_0x4bea1a[_0x2b7528(0xb2)]){if(typeof _0x5ebde8[_0x2b7528(0xbc)]==='function')try{_0x256666=_0x5ebde8[_0x2b7528(0xbc)](_0x4bea1a[_0x2b7528(0xb2)]);}catch(_0x14b551){this['logger']?.[_0x2b7528(0x79)]('Failed\x20to\x20parse\x20parameters\x20for\x20async\x20tool:\x20'+_0x4bea1a[_0x2b7528(0xc7)],{'error':_0x14b551[_0x2b7528(0xdf)]}),_0x256666=_0x4bea1a['content'];}else _0x256666=_0x4bea1a['content'];}return _0x256666&&typeof _0x256666===_0x2b7528(0xae)&&(_0x256666=this['unwrapParameters'](_0x256666)),_0x5ebde8['execute'](_0x256666,_0x4a7e50)['then'](_0x460e75=>{const _0x1f8dd8=_0x2b7528;_0x40f9fa['status']='completed',_0x40f9fa['result']=_0x460e75,_0x40f9fa[_0x1f8dd8(0xd3)]=new Date()['toISOString'](),this['notifyAgentOfToolCompletion'](_0x40f9fa);})[_0x2b7528(0xa8)](_0x3ca2f2=>{const _0x472a4a=_0x2b7528;_0x40f9fa[_0x472a4a(0xc4)]=_0x472a4a(0x86),_0x40f9fa['error']=_0x3ca2f2[_0x472a4a(0xdf)],_0x40f9fa['endTime']=new Date()['toISOString'](),this[_0x472a4a(0x82)](_0x40f9fa);}),this[_0x2b7528(0xa9)](_0x2ebf2d),{'toolId':_0x4bea1a['toolId'],'status':'async-pending','operationId':_0x2ebf2d,'message':_0x2b7528(0xbb)+_0x2ebf2d,'timestamp':new Date()['toISOString']()};}async[a0_0xfd677d(0xa9)](_0x301495){const _0x13ea06=0x1388,_0x5ab4c9=0x78;let _0x1c32d4=0x0;const _0x203644=setInterval(()=>{const _0x40f88c=a0_0x5c36,_0x42eb9f=this['asyncOperations']['get'](_0x301495);if(!_0x42eb9f){clearInterval(_0x203644);return;}_0x1c32d4++,(_0x42eb9f['status']!=='pending'||_0x1c32d4>=_0x5ab4c9)&&(clearInterval(_0x203644),_0x1c32d4>=_0x5ab4c9&&(_0x42eb9f[_0x40f88c(0xc4)]='timeout',_0x42eb9f[_0x40f88c(0x9b)]='Operation\x20timed\x20out',_0x42eb9f[_0x40f88c(0xd3)]=new Date()['toISOString'](),this['notifyAgentOfToolCompletion'](_0x42eb9f)));},_0x13ea06);}async[a0_0xfd677d(0x82)](_0x202e0c){const _0x15fdf5=a0_0xfd677d;if(!_0x202e0c['agentId'])return;try{await this[_0x15fdf5(0x95)][_0x15fdf5(0xee)](_0x202e0c[_0x15fdf5(0xea)],{'toolId':_0x202e0c[_0x15fdf5(0xc7)],'status':_0x202e0c['status'],'result':_0x202e0c[_0x15fdf5(0xa3)],'error':_0x202e0c[_0x15fdf5(0x9b)],'executionTime':_0x202e0c[_0x15fdf5(0xd3)]?new Date(_0x202e0c['endTime'])-new Date(_0x202e0c[_0x15fdf5(0xad)]):null,'timestamp':_0x202e0c['endTime']||new Date()[_0x15fdf5(0x81)]()}),this[_0x15fdf5(0xb6)]&&await this['scheduler']['addAgent'](_0x202e0c[_0x15fdf5(0xea)],{'triggeredBy':'tool-completion','sessionId':_0x202e0c['context']?.['sessionId']}),this['logger']['info']('Agent\x20notified\x20of\x20tool\x20completion:\x20'+_0x202e0c['agentId'],{'toolId':_0x202e0c[_0x15fdf5(0xc7)],'status':_0x202e0c[_0x15fdf5(0xc4)]});}catch(_0x35ef04){this[_0x15fdf5(0x91)][_0x15fdf5(0x9b)](_0x15fdf5(0xc1),{'agentId':_0x202e0c['agentId'],'toolId':_0x202e0c['toolId'],'error':_0x35ef04['message']});}}async[a0_0xfd677d(0x96)](_0x277027){const _0x3a9cf2=a0_0xfd677d,_0x1d2408=this[_0x3a9cf2(0xd6)]['get'](_0x277027);if(!_0x1d2408)return{'status':'not-found','error':_0x3a9cf2(0xcd)+_0x277027};return{'id':_0x1d2408['id'],'toolId':_0x1d2408[_0x3a9cf2(0xc7)],'status':_0x1d2408['status'],'result':_0x1d2408['result'],'error':_0x1d2408[_0x3a9cf2(0x9b)],'startTime':_0x1d2408['startTime'],'endTime':_0x1d2408['endTime']};}async[a0_0xfd677d(0xcb)](_0x2bc4bf,_0x12005d,_0x15d6f8){const _0x3f73e5=a0_0xfd677d;try{const _0x5e71b4=await this['extractToolCommands'](_0x2bc4bf);if(_0x5e71b4[_0x3f73e5(0xa7)]===0x0)return[];const _0x43b20e=await this['agentPool'][_0x3f73e5(0xd8)](_0x12005d),_0x3d0db7={..._0x15d6f8,'agentId':_0x12005d,'sessionId':_0x15d6f8['sessionId'],'directoryAccess':_0x43b20e?.[_0x3f73e5(0x7b)],'projectDir':_0x43b20e?.[_0x3f73e5(0x7b)]?.[_0x3f73e5(0x8c)]||_0x43b20e?.[_0x3f73e5(0xaa)]||_0x15d6f8['projectDir'],'agentPool':this['agentPool'],'contextManager':this[_0x3f73e5(0xb3)],'aiService':this['aiService'],'messageProcessor':this,'orchestrator':this[_0x3f73e5(0xdc)]},_0x4c7bab=await this[_0x3f73e5(0xe3)](_0x5e71b4,_0x3d0db7);return this[_0x3f73e5(0x91)]['info']('Executed\x20'+_0x4c7bab['length']+_0x3f73e5(0xe5)+_0x12005d,{'tools':_0x4c7bab['map'](_0x1a3ac5=>({'toolId':_0x1a3ac5[_0x3f73e5(0xc7)],'status':_0x1a3ac5[_0x3f73e5(0xc4)]}))}),_0x4c7bab;}catch(_0x46ea9c){return this[_0x3f73e5(0x91)]['error'](_0x3f73e5(0xda)+_0x12005d,{'error':_0x46ea9c['message']}),[];}}async['stopAutonomousExecution'](_0x42ec31){const _0x21da80=a0_0xfd677d;if(!this['scheduler'])return{'success':![],'error':_0x21da80(0xa5)};return await this['scheduler']['stopAgentExecution'](_0x42ec31);}async['injectToolResultsIntoConversation'](_0xfbd000,_0x518586){const _0x1663c5=a0_0xfd677d,_0x6b3af5=await this[_0x1663c5(0x95)][_0x1663c5(0xd8)](_0xfbd000);if(!_0x6b3af5)return;for(const _0x46563a of _0x518586){const _0x2f6e02={'id':'tool-'+Date['now']()+'-'+Math['random']()[_0x1663c5(0xec)](0x24)['substr'](0x2,0x9),'role':_0x1663c5(0xf3),'content':this['formatToolResultForAgent'](_0x46563a),'timestamp':new Date()['toISOString'](),'type':_0x1663c5(0x98),'toolId':_0x46563a[_0x1663c5(0xc7)],'status':_0x46563a[_0x1663c5(0xc4)]};_0x6b3af5[_0x1663c5(0xde)][_0x1663c5(0xa2)]['messages']['push'](_0x2f6e02),_0x6b3af5['currentModel']&&_0x6b3af5['conversations'][_0x6b3af5['currentModel']]&&_0x6b3af5[_0x1663c5(0xde)][_0x6b3af5[_0x1663c5(0x8a)]][_0x1663c5(0x9f)][_0x1663c5(0xca)](_0x2f6e02);}_0x6b3af5[_0x1663c5(0xde)][_0x1663c5(0xa2)]['lastUpdated']=new Date()[_0x1663c5(0x81)](),_0x6b3af5[_0x1663c5(0x8a)]&&_0x6b3af5['conversations'][_0x6b3af5['currentModel']]&&(_0x6b3af5['conversations'][_0x6b3af5[_0x1663c5(0x8a)]][_0x1663c5(0xe7)]=new Date()[_0x1663c5(0x81)]()),await this['agentPool'][_0x1663c5(0xf1)](_0xfbd000);}[a0_0xfd677d(0x92)](_0x98e754){const _0x13df7d=a0_0xfd677d;if(_0x98e754[_0x13df7d(0xc4)]==='completed'){if(typeof _0x98e754[_0x13df7d(0xa3)]===_0x13df7d(0xae))return'Tool\x20'+_0x98e754[_0x13df7d(0xc7)]+'\x20completed\x20successfully:\x0a'+JSON[_0x13df7d(0xc0)](_0x98e754[_0x13df7d(0xa3)],null,0x2);return'Tool\x20'+_0x98e754[_0x13df7d(0xc7)]+_0x13df7d(0x90)+_0x98e754['result'];}else{if(_0x98e754['status']===_0x13df7d(0x86))return'Tool\x20'+_0x98e754['toolId']+'\x20failed:\x20'+(_0x98e754[_0x13df7d(0x9b)]||_0x13df7d(0xa1));else{if(_0x98e754['status']==='async-pending')return _0x13df7d(0x7d)+_0x98e754[_0x13df7d(0xc7)]+'\x20is\x20running\x20asynchronously\x20(Operation\x20ID:\x20'+_0x98e754['operationId']+')';}}return'Tool\x20'+_0x98e754[_0x13df7d(0xc7)]+_0x13df7d(0xd1)+_0x98e754['status'];}}export default MessageProcessor;
|