@loxia-labs/loxia-autopilot-one 1.0.1 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -54
- package/bin/cli.js +1 -115
- package/bin/loxia-terminal-v2.js +3 -0
- package/bin/loxia-terminal.js +3 -0
- package/bin/start-with-terminal.js +3 -0
- package/package.json +15 -15
- package/scripts/install-scanners.js +1 -235
- package/src/analyzers/CSSAnalyzer.js +1 -297
- package/src/analyzers/ConfigValidator.js +1 -690
- package/src/analyzers/ESLintAnalyzer.js +1 -320
- package/src/analyzers/JavaScriptAnalyzer.js +1 -261
- package/src/analyzers/PrettierFormatter.js +1 -247
- package/src/analyzers/PythonAnalyzer.js +1 -266
- package/src/analyzers/SecurityAnalyzer.js +1 -729
- package/src/analyzers/TypeScriptAnalyzer.js +1 -247
- package/src/analyzers/codeCloneDetector/analyzer.js +1 -344
- package/src/analyzers/codeCloneDetector/detector.js +1 -203
- package/src/analyzers/codeCloneDetector/index.js +1 -160
- package/src/analyzers/codeCloneDetector/parser.js +1 -199
- package/src/analyzers/codeCloneDetector/reporter.js +1 -148
- package/src/analyzers/codeCloneDetector/scanner.js +1 -59
- package/src/core/agentPool.js +1 -1474
- package/src/core/agentScheduler.js +1 -2147
- package/src/core/contextManager.js +1 -709
- package/src/core/messageProcessor.js +1 -732
- package/src/core/orchestrator.js +1 -548
- package/src/core/stateManager.js +1 -877
- package/src/index.js +1 -631
- package/src/interfaces/cli.js +1 -549
- package/src/interfaces/terminal/__tests__/smoke/advancedFeatures.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/agentControl.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/agents.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/components.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/connection.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/enhancements.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/imports.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/messages.test.js +1 -0
- package/src/interfaces/terminal/__tests__/smoke/tools.test.js +1 -0
- package/src/interfaces/terminal/api/apiClient.js +1 -0
- package/src/interfaces/terminal/api/messageRouter.js +1 -0
- package/src/interfaces/terminal/api/session.js +1 -0
- package/src/interfaces/terminal/api/websocket.js +1 -0
- package/src/interfaces/terminal/components/AgentCreator.js +1 -0
- package/src/interfaces/terminal/components/AgentEditor.js +1 -0
- package/src/interfaces/terminal/components/AgentSwitcher.js +1 -0
- package/src/interfaces/terminal/components/ErrorBoundary.js +1 -0
- package/src/interfaces/terminal/components/ErrorPanel.js +1 -0
- package/src/interfaces/terminal/components/Header.js +1 -0
- package/src/interfaces/terminal/components/HelpPanel.js +1 -0
- package/src/interfaces/terminal/components/InputBox.js +1 -0
- package/src/interfaces/terminal/components/Layout.js +1 -0
- package/src/interfaces/terminal/components/LoadingSpinner.js +1 -0
- package/src/interfaces/terminal/components/MessageList.js +1 -0
- package/src/interfaces/terminal/components/MultilineTextInput.js +1 -0
- package/src/interfaces/terminal/components/SearchPanel.js +1 -0
- package/src/interfaces/terminal/components/SettingsPanel.js +1 -0
- package/src/interfaces/terminal/components/StatusBar.js +1 -0
- package/src/interfaces/terminal/components/TextInput.js +1 -0
- package/src/interfaces/terminal/config/agentEditorConstants.js +1 -0
- package/src/interfaces/terminal/config/constants.js +1 -0
- package/src/interfaces/terminal/index.js +1 -0
- package/src/interfaces/terminal/state/useAgentControl.js +1 -0
- package/src/interfaces/terminal/state/useAgents.js +1 -0
- package/src/interfaces/terminal/state/useConnection.js +1 -0
- package/src/interfaces/terminal/state/useMessages.js +1 -0
- package/src/interfaces/terminal/state/useTools.js +1 -0
- package/src/interfaces/terminal/utils/debugLogger.js +1 -0
- package/src/interfaces/terminal/utils/settingsStorage.js +1 -0
- package/src/interfaces/terminal/utils/theme.js +1 -0
- package/src/interfaces/webServer.js +1 -2162
- package/src/modules/fileExplorer/controller.js +1 -280
- package/src/modules/fileExplorer/index.js +1 -37
- package/src/modules/fileExplorer/middleware.js +1 -92
- package/src/modules/fileExplorer/routes.js +1 -125
- package/src/modules/fileExplorer/types.js +1 -44
- package/src/services/aiService.js +1 -1232
- package/src/services/apiKeyManager.js +1 -164
- package/src/services/benchmarkService.js +1 -366
- package/src/services/budgetService.js +1 -539
- package/src/services/contextInjectionService.js +1 -247
- package/src/services/conversationCompactionService.js +1 -637
- package/src/services/errorHandler.js +1 -810
- package/src/services/fileAttachmentService.js +1 -544
- package/src/services/modelRouterService.js +1 -366
- package/src/services/modelsService.js +1 -322
- package/src/services/qualityInspector.js +1 -796
- package/src/services/tokenCountingService.js +1 -536
- package/src/tools/agentCommunicationTool.js +1 -1344
- package/src/tools/agentDelayTool.js +1 -485
- package/src/tools/asyncToolManager.js +1 -604
- package/src/tools/baseTool.js +1 -800
- package/src/tools/browserTool.js +1 -920
- package/src/tools/cloneDetectionTool.js +1 -621
- package/src/tools/dependencyResolverTool.js +1 -1215
- package/src/tools/fileContentReplaceTool.js +1 -875
- package/src/tools/fileSystemTool.js +1 -1107
- package/src/tools/fileTreeTool.js +1 -853
- package/src/tools/imageTool.js +1 -901
- package/src/tools/importAnalyzerTool.js +1 -1060
- package/src/tools/jobDoneTool.js +1 -248
- package/src/tools/seekTool.js +1 -956
- package/src/tools/staticAnalysisTool.js +1 -1778
- package/src/tools/taskManagerTool.js +1 -2873
- package/src/tools/terminalTool.js +1 -2304
- package/src/tools/webTool.js +1 -1430
- package/src/types/agent.js +1 -519
- package/src/types/contextReference.js +1 -972
- package/src/types/conversation.js +1 -730
- package/src/types/toolCommand.js +1 -747
- package/src/utilities/attachmentValidator.js +1 -292
- package/src/utilities/configManager.js +1 -582
- package/src/utilities/constants.js +1 -722
- package/src/utilities/directoryAccessManager.js +1 -535
- package/src/utilities/fileProcessor.js +1 -307
- package/src/utilities/logger.js +1 -436
- package/src/utilities/tagParser.js +1 -1246
- package/src/utilities/toolConstants.js +1 -317
- package/web-ui/build/index.html +2 -2
- package/web-ui/build/static/{index-Dy2bYbOa.css → index-CClD1090.css} +1 -1
- package/web-ui/build/static/{index-CjkkcnFA.js → index-lCBai6dX.js} +66 -67
package/src/core/agentPool.js
CHANGED
|
@@ -1,1474 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AgentPool - Manages the lifecycle, state, and communication of all active agents
|
|
3
|
-
*
|
|
4
|
-
* Purpose:
|
|
5
|
-
* - Agent creation and destruction
|
|
6
|
-
* - Agent notification and routing
|
|
7
|
-
* - Multi-agent conversation coordination
|
|
8
|
-
* - Agent state persistence and recovery
|
|
9
|
-
* - Agent activity management
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
AGENT_TYPES,
|
|
14
|
-
AGENT_STATUS,
|
|
15
|
-
AGENT_MODES,
|
|
16
|
-
AGENT_MODE_STATES,
|
|
17
|
-
MESSAGE_ROLES,
|
|
18
|
-
MESSAGE_TYPES,
|
|
19
|
-
INTER_AGENT_MESSAGE,
|
|
20
|
-
MODEL_FORMAT_VERSIONS,
|
|
21
|
-
SYSTEM_DEFAULTS
|
|
22
|
-
} from '../utilities/constants.js';
|
|
23
|
-
import DirectoryAccessManager from '../utilities/directoryAccessManager.js';
|
|
24
|
-
|
|
25
|
-
class AgentPool {
|
|
26
|
-
constructor(config, logger, stateManager, contextManager, toolsRegistry = null) {
|
|
27
|
-
this.config = config;
|
|
28
|
-
this.logger = logger;
|
|
29
|
-
this.stateManager = stateManager;
|
|
30
|
-
this.contextManager = contextManager;
|
|
31
|
-
this.toolsRegistry = toolsRegistry;
|
|
32
|
-
|
|
33
|
-
// Agent registry - maps agent ID to agent object
|
|
34
|
-
this.agents = new Map();
|
|
35
|
-
|
|
36
|
-
// Agent directory for discovery
|
|
37
|
-
this.agentDirectory = new Map();
|
|
38
|
-
|
|
39
|
-
// Paused agents tracking
|
|
40
|
-
this.pausedAgents = new Map();
|
|
41
|
-
|
|
42
|
-
// Agent notification queue
|
|
43
|
-
this.notificationQueue = new Map();
|
|
44
|
-
|
|
45
|
-
this.maxAgentsPerProject = config.system?.maxAgentsPerProject || SYSTEM_DEFAULTS.MAX_AGENTS_PER_PROJECT;
|
|
46
|
-
|
|
47
|
-
// MessageProcessor reference for triggering responses (set via setMessageProcessor)
|
|
48
|
-
this.messageProcessor = null;
|
|
49
|
-
|
|
50
|
-
// Initialize directory access manager
|
|
51
|
-
this.directoryAccessManager = new DirectoryAccessManager(config, logger);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Create a new agent with specified configuration
|
|
56
|
-
* @param {Object} config - Agent configuration
|
|
57
|
-
* @param {string} config.name - Agent name
|
|
58
|
-
* @param {string} config.type - Agent type ('user-created', 'system-agent', 'agent-engineer')
|
|
59
|
-
* @param {string} config.systemPrompt - Agent's system prompt
|
|
60
|
-
* @param {string} config.preferredModel - Preferred LLM model
|
|
61
|
-
* @param {Array} config.capabilities - Available tools/capabilities
|
|
62
|
-
* @param {Object} config.directoryAccess - Directory access configuration
|
|
63
|
-
* @param {string} config.projectDir - Project directory for default access setup
|
|
64
|
-
* @returns {Promise<Object>} Created agent object
|
|
65
|
-
*/
|
|
66
|
-
async createAgent(config) {
|
|
67
|
-
// Check agent limit
|
|
68
|
-
if (this.agents.size >= this.maxAgentsPerProject) {
|
|
69
|
-
throw new Error(`Maximum agents per project exceeded (${this.maxAgentsPerProject})`);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const agentId = this._generateAgentId(config.name);
|
|
73
|
-
const now = new Date().toISOString();
|
|
74
|
-
|
|
75
|
-
// Enhance system prompt with tool descriptions if available
|
|
76
|
-
let enhancedSystemPrompt = config.systemPrompt;
|
|
77
|
-
if (this.toolsRegistry && config.capabilities && config.capabilities.length > 0) {
|
|
78
|
-
try {
|
|
79
|
-
enhancedSystemPrompt = this.toolsRegistry.enhanceSystemPrompt(
|
|
80
|
-
config.systemPrompt,
|
|
81
|
-
config.capabilities,
|
|
82
|
-
{
|
|
83
|
-
compact: config.compactToolDescriptions || false,
|
|
84
|
-
includeExamples: config.includeToolExamples !== false,
|
|
85
|
-
includeUsageGuidelines: config.includeUsageGuidelines !== false,
|
|
86
|
-
includeSecurityNotes: config.includeSecurityNotes !== false
|
|
87
|
-
}
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
this.logger?.info(`System prompt enhanced with tool descriptions`, {
|
|
91
|
-
agentId,
|
|
92
|
-
capabilities: config.capabilities,
|
|
93
|
-
originalLength: config.systemPrompt?.length || 0,
|
|
94
|
-
enhancedLength: enhancedSystemPrompt?.length || 0
|
|
95
|
-
});
|
|
96
|
-
} catch (error) {
|
|
97
|
-
this.logger?.error(`Failed to enhance system prompt with tools`, {
|
|
98
|
-
agentId,
|
|
99
|
-
error: error.message,
|
|
100
|
-
capabilities: config.capabilities
|
|
101
|
-
});
|
|
102
|
-
// Fall back to original prompt
|
|
103
|
-
enhancedSystemPrompt = config.systemPrompt;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Setup directory access configuration
|
|
108
|
-
let directoryAccess;
|
|
109
|
-
|
|
110
|
-
console.log('AgentPool DEBUG: createAgent - config.directoryAccess:', config.directoryAccess ? 'EXISTS' : 'NULL/UNDEFINED');
|
|
111
|
-
if (config.directoryAccess) {
|
|
112
|
-
console.log('AgentPool DEBUG: createAgent - directoryAccess from config:', JSON.stringify(config.directoryAccess, null, 2));
|
|
113
|
-
}
|
|
114
|
-
console.log('AgentPool DEBUG: createAgent - config.projectDir:', config.projectDir);
|
|
115
|
-
|
|
116
|
-
if (config.directoryAccess) {
|
|
117
|
-
// Validate provided directory access configuration
|
|
118
|
-
const validation = this.directoryAccessManager.validateAccessConfiguration(config.directoryAccess);
|
|
119
|
-
console.log('AgentPool DEBUG: createAgent - validation result:', validation);
|
|
120
|
-
if (!validation.valid) {
|
|
121
|
-
throw new Error(`Invalid directory access configuration: ${validation.errors.join(', ')}`);
|
|
122
|
-
}
|
|
123
|
-
directoryAccess = config.directoryAccess;
|
|
124
|
-
console.log('AgentPool DEBUG: createAgent - Using provided directoryAccess');
|
|
125
|
-
} else {
|
|
126
|
-
// Create default directory access based on project directory
|
|
127
|
-
const projectDir = config.projectDir || process.cwd();
|
|
128
|
-
directoryAccess = DirectoryAccessManager.createProjectDefaults(projectDir);
|
|
129
|
-
console.log('AgentPool DEBUG: createAgent - Created default directoryAccess for projectDir:', projectDir);
|
|
130
|
-
console.log('AgentPool DEBUG: createAgent - Default directoryAccess:', JSON.stringify(directoryAccess, null, 2));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const agent = {
|
|
134
|
-
id: agentId,
|
|
135
|
-
type: config.type || AGENT_TYPES.USER_CREATED,
|
|
136
|
-
name: config.name || `Agent-${Date.now()}`,
|
|
137
|
-
systemPrompt: enhancedSystemPrompt,
|
|
138
|
-
originalSystemPrompt: config.systemPrompt, // Store original for reference
|
|
139
|
-
preferredModel: config.preferredModel,
|
|
140
|
-
status: AGENT_STATUS.ACTIVE,
|
|
141
|
-
capabilities: config.capabilities || [],
|
|
142
|
-
directoryAccess: directoryAccess, // Directory access configuration
|
|
143
|
-
conversations: {
|
|
144
|
-
full: {
|
|
145
|
-
messages: [],
|
|
146
|
-
lastUpdated: now
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
currentModel: config.preferredModel,
|
|
150
|
-
dynamicModelRouting: config.dynamicModelRouting || false, // New field for routing
|
|
151
|
-
platformProvided: config.platformProvided || false, // Platform vs direct access
|
|
152
|
-
|
|
153
|
-
// Agent Mode Configuration
|
|
154
|
-
mode: config.mode || AGENT_MODES.CHAT,
|
|
155
|
-
modeState: AGENT_MODE_STATES.IDLE,
|
|
156
|
-
currentTask: null, // Current autonomous task being executed
|
|
157
|
-
taskStartTime: null,
|
|
158
|
-
maxIterations: config.maxIterations || 10, // Safety limit for autonomous loops
|
|
159
|
-
iterationCount: 0,
|
|
160
|
-
stopRequested: false,
|
|
161
|
-
delayEndTime: null, // When agent delay expires (for agentDelay tool)
|
|
162
|
-
|
|
163
|
-
// Message Queues for scheduler processing
|
|
164
|
-
messageQueues: {
|
|
165
|
-
toolResults: [], // Tool execution results waiting to be processed
|
|
166
|
-
interAgentMessages: [], // Messages from other agents
|
|
167
|
-
userMessages: [] // Messages from users
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
createdAt: now,
|
|
171
|
-
lastActivity: now,
|
|
172
|
-
pausedUntil: null,
|
|
173
|
-
metadata: config.metadata || {},
|
|
174
|
-
|
|
175
|
-
// CRITICAL: Store sessionId for API key resolution
|
|
176
|
-
sessionId: config.sessionId,
|
|
177
|
-
|
|
178
|
-
// Inter-agent conversation tracking to prevent spam
|
|
179
|
-
interAgentTracking: new Map(), // recipientId -> { lastSent, lastReceived, lastType }
|
|
180
|
-
|
|
181
|
-
// Task Management System for agent-mode autonomous operation
|
|
182
|
-
taskList: {
|
|
183
|
-
tasks: [], // Array of task objects
|
|
184
|
-
lastUpdated: now
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
// Incoming messages tracking (for unprocessed messages)
|
|
188
|
-
incomingMessages: []
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
this.logger.info(`Agent created with routing config`, {
|
|
192
|
-
agentId,
|
|
193
|
-
dynamicModelRouting: agent.dynamicModelRouting,
|
|
194
|
-
platformProvided: agent.platformProvided,
|
|
195
|
-
preferredModel: agent.preferredModel
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
// Initialize model-specific conversation with dual storage structure
|
|
199
|
-
if (config.preferredModel) {
|
|
200
|
-
agent.conversations[config.preferredModel] = {
|
|
201
|
-
// Dual storage for compactization support
|
|
202
|
-
messages: [], // Original messages - never modified
|
|
203
|
-
compactizedMessages: null, // Working copy - null until first compaction
|
|
204
|
-
|
|
205
|
-
// Compactization metadata
|
|
206
|
-
lastCompactization: null, // Timestamp of last compaction
|
|
207
|
-
compactizationCount: 0, // Number of times compacted
|
|
208
|
-
compactizationStrategy: null, // 'summarization', 'truncation', 'aggressive'
|
|
209
|
-
originalTokenCount: 0, // Token count before last compaction
|
|
210
|
-
compactedTokenCount: 0, // Token count after last compaction
|
|
211
|
-
|
|
212
|
-
// Backward compatibility
|
|
213
|
-
tokenCount: 0, // Current effective token count
|
|
214
|
-
lastUpdated: now,
|
|
215
|
-
formatVersion: this._getModelFormatVersion(config.preferredModel)
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// Add to registry and directory
|
|
220
|
-
this.agents.set(agentId, agent);
|
|
221
|
-
this._updateAgentDirectory(agent);
|
|
222
|
-
|
|
223
|
-
// Persist agent state
|
|
224
|
-
await this.stateManager.persistAgentState(agentId);
|
|
225
|
-
|
|
226
|
-
this.logger.info(`Agent created: ${agentId}`, {
|
|
227
|
-
agentId,
|
|
228
|
-
name: agent.name,
|
|
229
|
-
type: agent.type,
|
|
230
|
-
model: agent.preferredModel
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
return agent;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Retrieve agent instance by ID
|
|
238
|
-
* @param {string} agentId - Agent identifier
|
|
239
|
-
* @returns {Promise<Object|null>} Agent object or null if not found
|
|
240
|
-
*/
|
|
241
|
-
async getAgent(agentId, enrichWithSchedulerStatus = false) {
|
|
242
|
-
const agent = this.agents.get(agentId);
|
|
243
|
-
if (!agent) return null;
|
|
244
|
-
|
|
245
|
-
// Optionally enrich with scheduler status for UI
|
|
246
|
-
if (enrichWithSchedulerStatus && this.scheduler) {
|
|
247
|
-
agent.inScheduler = this.scheduler.isAgentInScheduler(agentId);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
return agent;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Update an existing agent's configuration
|
|
255
|
-
* @param {string} agentId - Agent identifier
|
|
256
|
-
* @param {Object} updates - Updates to apply to the agent
|
|
257
|
-
* @returns {Promise<Object>} Updated agent object
|
|
258
|
-
*/
|
|
259
|
-
async updateAgent(agentId, updates) {
|
|
260
|
-
const agent = await this.getAgent(agentId);
|
|
261
|
-
if (!agent) {
|
|
262
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
this.logger.info(`Updating agent: ${agentId}`, {
|
|
266
|
-
updates,
|
|
267
|
-
currentName: agent.name
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
// Validate directory access configuration if being updated
|
|
271
|
-
if (updates.directoryAccess) {
|
|
272
|
-
const validation = this.directoryAccessManager.validateAccessConfiguration(updates.directoryAccess);
|
|
273
|
-
if (!validation.valid) {
|
|
274
|
-
throw new Error(`Invalid directory access configuration: ${validation.errors.join(', ')}`);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
this.logger.info(`Directory access validation passed for agent: ${agentId}`, {
|
|
278
|
-
workingDirectory: updates.directoryAccess.workingDirectory,
|
|
279
|
-
readOnlyDirs: updates.directoryAccess.readOnlyDirectories?.length || 0,
|
|
280
|
-
writeEnabledDirs: updates.directoryAccess.writeEnabledDirectories?.length || 0
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// If capabilities are being updated, regenerate the enhanced system prompt
|
|
285
|
-
if (updates.capabilities && this.toolsRegistry) {
|
|
286
|
-
try {
|
|
287
|
-
const baseSystemPrompt = agent.originalSystemPrompt || agent.systemPrompt;
|
|
288
|
-
const enhancedSystemPrompt = this.toolsRegistry.enhanceSystemPrompt(
|
|
289
|
-
baseSystemPrompt,
|
|
290
|
-
updates.capabilities,
|
|
291
|
-
{
|
|
292
|
-
compact: agent.compactToolDescriptions || false,
|
|
293
|
-
includeExamples: agent.includeToolExamples !== false,
|
|
294
|
-
includeUsageGuidelines: agent.includeUsageGuidelines !== false,
|
|
295
|
-
includeSecurityNotes: agent.includeSecurityNotes !== false
|
|
296
|
-
}
|
|
297
|
-
);
|
|
298
|
-
|
|
299
|
-
updates.systemPrompt = enhancedSystemPrompt;
|
|
300
|
-
|
|
301
|
-
this.logger.info(`System prompt regenerated with updated capabilities`, {
|
|
302
|
-
agentId,
|
|
303
|
-
oldCapabilities: agent.capabilities,
|
|
304
|
-
newCapabilities: updates.capabilities,
|
|
305
|
-
originalLength: baseSystemPrompt?.length || 0,
|
|
306
|
-
enhancedLength: enhancedSystemPrompt?.length || 0
|
|
307
|
-
});
|
|
308
|
-
} catch (error) {
|
|
309
|
-
this.logger.error(`Failed to regenerate system prompt with updated capabilities`, {
|
|
310
|
-
agentId,
|
|
311
|
-
error: error.message,
|
|
312
|
-
capabilities: updates.capabilities
|
|
313
|
-
});
|
|
314
|
-
// Continue with update even if enhancement fails
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// Create updated agent object with new values
|
|
319
|
-
const updatedAgent = {
|
|
320
|
-
...agent,
|
|
321
|
-
...updates,
|
|
322
|
-
id: agentId, // Ensure ID cannot be changed
|
|
323
|
-
lastModified: new Date().toISOString(),
|
|
324
|
-
lastActivity: new Date().toISOString()
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
// CRITICAL FIX: When preferredModel changes, also update currentModel
|
|
328
|
-
// This ensures the UI immediately reflects the model change
|
|
329
|
-
if (updates.preferredModel && updates.preferredModel !== agent.preferredModel) {
|
|
330
|
-
const oldModel = agent.preferredModel;
|
|
331
|
-
const newModel = updates.preferredModel;
|
|
332
|
-
|
|
333
|
-
updatedAgent.currentModel = newModel;
|
|
334
|
-
|
|
335
|
-
// CRITICAL FIX: Initialize conversation for new model if it doesn't exist
|
|
336
|
-
if (!updatedAgent.conversations[newModel]) {
|
|
337
|
-
updatedAgent.conversations[newModel] = this._createEmptyConversation(newModel);
|
|
338
|
-
this.logger.info(`Created conversation for new model: ${newModel}`, { agentId });
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// Copy conversation history from old model to new model
|
|
342
|
-
// This preserves context when switching models
|
|
343
|
-
if (oldModel && updatedAgent.conversations[oldModel]) {
|
|
344
|
-
const oldConversation = updatedAgent.conversations[oldModel];
|
|
345
|
-
const newConversation = updatedAgent.conversations[newModel];
|
|
346
|
-
|
|
347
|
-
// Copy messages if new conversation is empty
|
|
348
|
-
if (newConversation.messages.length === 0 && oldConversation.messages.length > 0) {
|
|
349
|
-
// Copy original messages
|
|
350
|
-
newConversation.messages = [...oldConversation.messages];
|
|
351
|
-
|
|
352
|
-
// Copy compacted messages if they exist
|
|
353
|
-
if (oldConversation.compactizedMessages) {
|
|
354
|
-
newConversation.compactizedMessages = [...oldConversation.compactizedMessages];
|
|
355
|
-
newConversation.lastCompactization = oldConversation.lastCompactization;
|
|
356
|
-
newConversation.compactizationCount = oldConversation.compactizationCount;
|
|
357
|
-
newConversation.compactizationStrategy = oldConversation.compactizationStrategy;
|
|
358
|
-
newConversation.originalTokenCount = oldConversation.originalTokenCount;
|
|
359
|
-
newConversation.compactedTokenCount = oldConversation.compactedTokenCount;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
newConversation.lastUpdated = new Date().toISOString();
|
|
363
|
-
|
|
364
|
-
this.logger.info(`Copied conversation history from ${oldModel} to ${newModel}`, {
|
|
365
|
-
agentId,
|
|
366
|
-
messageCount: newConversation.messages.length,
|
|
367
|
-
hasCompacted: !!newConversation.compactizedMessages
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
this.logger.info(`Model changed via UI - updating both preferredModel and currentModel`, {
|
|
373
|
-
agentId,
|
|
374
|
-
oldModel,
|
|
375
|
-
newModel,
|
|
376
|
-
conversationCopied: oldModel && updatedAgent.conversations[oldModel]?.messages.length > 0
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
// Update agent in registry
|
|
381
|
-
this.agents.set(agentId, updatedAgent);
|
|
382
|
-
|
|
383
|
-
// Log the actual update for debugging
|
|
384
|
-
this.logger.info(`Agent updated in registry with mode: ${updatedAgent.mode}`, {
|
|
385
|
-
agentId,
|
|
386
|
-
beforeMode: agent.mode,
|
|
387
|
-
afterMode: updatedAgent.mode,
|
|
388
|
-
allUpdates: Object.keys(updates)
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
// Update agent directory
|
|
392
|
-
this._updateAgentDirectory(updatedAgent);
|
|
393
|
-
|
|
394
|
-
// Persist the updated agent state
|
|
395
|
-
await this.stateManager.persistAgentState(updatedAgent);
|
|
396
|
-
|
|
397
|
-
// CRITICAL: If agent was switched to AGENT mode, add it to scheduler
|
|
398
|
-
if (updates.mode === AGENT_MODES.AGENT && this.scheduler) {
|
|
399
|
-
// CRITICAL FIX: Use the session ID from updates first, then agent's sessionId
|
|
400
|
-
const sessionId = updates.sessionId || updatedAgent.sessionId;
|
|
401
|
-
|
|
402
|
-
if (!sessionId) {
|
|
403
|
-
this.logger.warn(`Agent ${agentId} switching to AGENT mode but has no sessionId - this will cause API key resolution issues`);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
this.logger.info(`Adding agent to scheduler (switched to AGENT mode): ${agentId}`, {
|
|
407
|
-
agentName: updatedAgent.name,
|
|
408
|
-
sessionId: sessionId,
|
|
409
|
-
hasSessionId: !!sessionId
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
await this.scheduler.addAgent(agentId, {
|
|
413
|
-
sessionId: sessionId, // NO FALLBACK - let scheduler handle missing session ID appropriately
|
|
414
|
-
triggeredBy: 'mode-change',
|
|
415
|
-
reason: 'Agent switched to AGENT mode'
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
// If agent was switched from AGENT to CHAT mode, remove from scheduler
|
|
420
|
-
if (agent.mode === AGENT_MODES.AGENT && updates.mode === AGENT_MODES.CHAT && this.scheduler) {
|
|
421
|
-
this.logger.info(`Removing agent from scheduler (switched to CHAT mode): ${agentId}`);
|
|
422
|
-
this.scheduler.removeAgent(agentId, 'mode-change-to-chat');
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
this.logger.info(`Agent updated successfully: ${agentId}`, {
|
|
426
|
-
newName: updatedAgent.name,
|
|
427
|
-
changes: Object.keys(updates)
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
return updatedAgent;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
* Agent notification from Message Processor for inter-agent communication
|
|
435
|
-
* @param {string} agentId - Target agent ID
|
|
436
|
-
* @param {Object} message - Message object with agent redirect
|
|
437
|
-
* @returns {Promise<boolean>} Success status
|
|
438
|
-
*/
|
|
439
|
-
async notifyAgent(agentId, message) {
|
|
440
|
-
const agent = await this.getAgent(agentId);
|
|
441
|
-
if (!agent) {
|
|
442
|
-
this.logger.warn(`Agent notification failed - agent not found: ${agentId}`);
|
|
443
|
-
return false;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
// Check if agent is paused
|
|
447
|
-
if (this._isAgentPaused(agent)) {
|
|
448
|
-
this.logger.info(`Agent notification queued - agent is paused: ${agentId}`);
|
|
449
|
-
this._queueNotification(agentId, message);
|
|
450
|
-
return true;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
// Add notification to agent's conversation
|
|
454
|
-
const notificationMessage = {
|
|
455
|
-
id: `msg-${Date.now()}`,
|
|
456
|
-
conversationId: message.conversationId,
|
|
457
|
-
agentId: message.from, // sender agent ID
|
|
458
|
-
content: message.content,
|
|
459
|
-
role: MESSAGE_ROLES.SYSTEM,
|
|
460
|
-
timestamp: new Date().toISOString(),
|
|
461
|
-
type: MESSAGE_TYPES.AGENT_NOTIFICATION,
|
|
462
|
-
fromAgent: message.from,
|
|
463
|
-
context: message.context,
|
|
464
|
-
urgent: message.urgent || false,
|
|
465
|
-
requiresResponse: message.requiresResponse || false
|
|
466
|
-
};
|
|
467
|
-
|
|
468
|
-
// Add to full conversation
|
|
469
|
-
agent.conversations.full.messages.push(notificationMessage);
|
|
470
|
-
agent.conversations.full.lastUpdated = new Date().toISOString();
|
|
471
|
-
|
|
472
|
-
// Add to current model conversation
|
|
473
|
-
if (agent.currentModel && agent.conversations[agent.currentModel]) {
|
|
474
|
-
const formattedMessage = this._formatMessageForModel(notificationMessage, agent.currentModel);
|
|
475
|
-
agent.conversations[agent.currentModel].messages.push(formattedMessage);
|
|
476
|
-
agent.conversations[agent.currentModel].lastUpdated = new Date().toISOString();
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
// Update agent activity
|
|
480
|
-
agent.lastActivity = new Date().toISOString();
|
|
481
|
-
await this.persistAgentState(agentId);
|
|
482
|
-
|
|
483
|
-
this.logger.info(`Agent notified: ${agentId}`, {
|
|
484
|
-
fromAgent: message.from,
|
|
485
|
-
urgent: message.urgent,
|
|
486
|
-
requiresResponse: message.requiresResponse
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
return true;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
/**
|
|
493
|
-
* Get all agents (returns full agent objects)
|
|
494
|
-
* @returns {Promise<Array>} List of all agent objects
|
|
495
|
-
*/
|
|
496
|
-
async getAllAgents() {
|
|
497
|
-
const agents = Array.from(this.agents.values());
|
|
498
|
-
|
|
499
|
-
// Update pause status for all agents
|
|
500
|
-
for (const agent of agents) {
|
|
501
|
-
this._updateAgentPauseStatus(agent);
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
return agents;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
/**
|
|
508
|
-
* List all active agents with their current status
|
|
509
|
-
* @returns {Promise<Array>} Array of agent objects
|
|
510
|
-
*/
|
|
511
|
-
async listActiveAgents() {
|
|
512
|
-
const agents = Array.from(this.agents.values());
|
|
513
|
-
|
|
514
|
-
// Update pause status for all agents
|
|
515
|
-
for (const agent of agents) {
|
|
516
|
-
this._updateAgentPauseStatus(agent);
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
return agents.map(agent => ({
|
|
520
|
-
id: agent.id,
|
|
521
|
-
name: agent.name,
|
|
522
|
-
type: agent.type,
|
|
523
|
-
status: agent.status,
|
|
524
|
-
systemPrompt: agent.systemPrompt,
|
|
525
|
-
preferredModel: agent.preferredModel,
|
|
526
|
-
currentModel: agent.currentModel,
|
|
527
|
-
dynamicModelRouting: agent.dynamicModelRouting,
|
|
528
|
-
platformProvided: agent.platformProvided,
|
|
529
|
-
capabilities: agent.capabilities,
|
|
530
|
-
lastActivity: agent.lastActivity,
|
|
531
|
-
isPaused: this._isAgentPaused(agent),
|
|
532
|
-
pausedUntil: agent.pausedUntil,
|
|
533
|
-
messageCount: agent.conversations.full.messages.length,
|
|
534
|
-
createdAt: agent.createdAt
|
|
535
|
-
}));
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
/**
|
|
539
|
-
* Persist agent state to storage
|
|
540
|
-
* @param {string} agentId - Agent identifier
|
|
541
|
-
* @returns {Promise<void>}
|
|
542
|
-
*/
|
|
543
|
-
async persistAgentState(agentId) {
|
|
544
|
-
const agent = await this.getAgent(agentId);
|
|
545
|
-
if (!agent) {
|
|
546
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
await this.stateManager.persistAgentState(agent);
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
/**
|
|
553
|
-
* Resume agent from persisted state
|
|
554
|
-
* @param {Object} agentData - Persisted agent data
|
|
555
|
-
* @returns {Promise<Object>} Restored agent object
|
|
556
|
-
*/
|
|
557
|
-
async resumeAgent(agentData) {
|
|
558
|
-
const agent = {
|
|
559
|
-
...agentData,
|
|
560
|
-
status: agentData.status === 'paused' && this._isPauseExpired(agentData) ? 'active' : agentData.status
|
|
561
|
-
};
|
|
562
|
-
|
|
563
|
-
// Validate conversations structure
|
|
564
|
-
if (!agent.conversations || !agent.conversations.full) {
|
|
565
|
-
agent.conversations = {
|
|
566
|
-
full: {
|
|
567
|
-
messages: [],
|
|
568
|
-
lastUpdated: new Date().toISOString()
|
|
569
|
-
}
|
|
570
|
-
};
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
// Add to registry and directory
|
|
574
|
-
this.agents.set(agent.id, agent);
|
|
575
|
-
this._updateAgentDirectory(agent);
|
|
576
|
-
|
|
577
|
-
// Process any queued notifications
|
|
578
|
-
await this._processQueuedNotifications(agent.id);
|
|
579
|
-
|
|
580
|
-
this.logger.info(`Agent resumed: ${agent.id}`, {
|
|
581
|
-
name: agent.name,
|
|
582
|
-
status: agent.status,
|
|
583
|
-
messageCount: agent.conversations.full.messages.length
|
|
584
|
-
});
|
|
585
|
-
|
|
586
|
-
return agent;
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
/**
|
|
590
|
-
* Pause agent for specified duration
|
|
591
|
-
* @param {string} agentId - Agent identifier
|
|
592
|
-
* @param {number|Date} duration - Pause duration in seconds or Date object
|
|
593
|
-
* @param {string} reason - Reason for pause
|
|
594
|
-
* @returns {Promise<Object>} Pause confirmation
|
|
595
|
-
*/
|
|
596
|
-
async pauseAgent(agentId, duration, reason = 'Agent pause requested') {
|
|
597
|
-
const agent = await this.getAgent(agentId);
|
|
598
|
-
if (!agent) {
|
|
599
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
let pauseUntil;
|
|
603
|
-
if (duration instanceof Date) {
|
|
604
|
-
pauseUntil = duration;
|
|
605
|
-
} else {
|
|
606
|
-
// Duration in seconds
|
|
607
|
-
const maxPauseDuration = this.config.system?.maxPauseDuration || 300;
|
|
608
|
-
const pauseSeconds = Math.min(duration, maxPauseDuration);
|
|
609
|
-
pauseUntil = new Date(Date.now() + pauseSeconds * 1000);
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
agent.status = AGENT_STATUS.PAUSED;
|
|
613
|
-
agent.pausedUntil = pauseUntil.toISOString();
|
|
614
|
-
agent.lastActivity = new Date().toISOString();
|
|
615
|
-
|
|
616
|
-
// Add to paused agents tracking
|
|
617
|
-
this.pausedAgents.set(agentId, {
|
|
618
|
-
agentId,
|
|
619
|
-
pausedAt: new Date().toISOString(),
|
|
620
|
-
pausedUntil: pauseUntil.toISOString(),
|
|
621
|
-
reason,
|
|
622
|
-
originalStatus: AGENT_STATUS.ACTIVE
|
|
623
|
-
});
|
|
624
|
-
|
|
625
|
-
await this.persistAgentState(agentId);
|
|
626
|
-
|
|
627
|
-
this.logger.info(`Agent paused: ${agentId}`, {
|
|
628
|
-
pausedUntil: pauseUntil.toISOString(),
|
|
629
|
-
reason,
|
|
630
|
-
durationSeconds: Math.round((pauseUntil.getTime() - Date.now()) / 1000)
|
|
631
|
-
});
|
|
632
|
-
|
|
633
|
-
return {
|
|
634
|
-
success: true,
|
|
635
|
-
agentId,
|
|
636
|
-
pausedUntil: pauseUntil.toISOString(),
|
|
637
|
-
reason,
|
|
638
|
-
message: `Agent paused until ${pauseUntil.toISOString()}`
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
/**
|
|
643
|
-
* Resume paused agent
|
|
644
|
-
* @param {string} agentId - Agent identifier
|
|
645
|
-
* @returns {Promise<Object>} Resume confirmation
|
|
646
|
-
*/
|
|
647
|
-
async resumeAgent(agentId) {
|
|
648
|
-
const agent = await this.getAgent(agentId);
|
|
649
|
-
if (!agent) {
|
|
650
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
if (agent.status !== AGENT_STATUS.PAUSED) {
|
|
654
|
-
return {
|
|
655
|
-
success: true,
|
|
656
|
-
message: `Agent ${agentId} is not paused`
|
|
657
|
-
};
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
agent.status = AGENT_STATUS.ACTIVE;
|
|
661
|
-
agent.pausedUntil = null;
|
|
662
|
-
agent.lastActivity = new Date().toISOString();
|
|
663
|
-
|
|
664
|
-
// Remove from paused agents tracking
|
|
665
|
-
this.pausedAgents.delete(agentId);
|
|
666
|
-
|
|
667
|
-
// Process any queued notifications
|
|
668
|
-
await this._processQueuedNotifications(agentId);
|
|
669
|
-
|
|
670
|
-
await this.persistAgentState(agentId);
|
|
671
|
-
|
|
672
|
-
this.logger.info(`Agent resumed: ${agentId}`);
|
|
673
|
-
|
|
674
|
-
return {
|
|
675
|
-
success: true,
|
|
676
|
-
agentId,
|
|
677
|
-
message: `Agent ${agentId} resumed successfully`
|
|
678
|
-
};
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
/**
|
|
682
|
-
* Restore agent from saved state
|
|
683
|
-
* @param {Object} agentState - Saved agent state
|
|
684
|
-
* @returns {Promise<Object>} Restored agent
|
|
685
|
-
*/
|
|
686
|
-
async restoreAgent(agentState) {
|
|
687
|
-
return await this.resumeAgent(agentState);
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
/**
|
|
691
|
-
* Get agent discovery directory
|
|
692
|
-
* @returns {Array} Array of agent info for discovery
|
|
693
|
-
*/
|
|
694
|
-
getAgentDirectory() {
|
|
695
|
-
return Array.from(this.agentDirectory.values());
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
/**
|
|
699
|
-
* List all active agents
|
|
700
|
-
* @returns {Array} Array of active agents
|
|
701
|
-
*/
|
|
702
|
-
|
|
703
|
-
/**
|
|
704
|
-
* Delete an agent and clean up its resources
|
|
705
|
-
* @param {string} agentId - Agent identifier
|
|
706
|
-
* @returns {Promise<Object>} Deletion result
|
|
707
|
-
*/
|
|
708
|
-
async deleteAgent(agentId) {
|
|
709
|
-
const agent = await this.getAgent(agentId);
|
|
710
|
-
if (!agent) {
|
|
711
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
// Clean up file attachments with reference counting
|
|
715
|
-
if (this.fileAttachmentService) {
|
|
716
|
-
try {
|
|
717
|
-
await this.fileAttachmentService.deleteAgentAttachments(agentId);
|
|
718
|
-
this.logger.info(`File attachments cleaned up for agent: ${agentId}`);
|
|
719
|
-
} catch (error) {
|
|
720
|
-
this.logger.warn(`Failed to clean up file attachments for agent: ${error.message}`, { agentId });
|
|
721
|
-
// Continue with agent deletion even if attachment cleanup fails
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
// Clean up agent resources
|
|
726
|
-
this.agents.delete(agentId);
|
|
727
|
-
this.agentDirectory.delete(agentId);
|
|
728
|
-
this.pausedAgents.delete(agentId);
|
|
729
|
-
this.notificationQueue.delete(agentId);
|
|
730
|
-
|
|
731
|
-
// Clean up persistent state
|
|
732
|
-
try {
|
|
733
|
-
await this.stateManager.deleteAgentState(agentId);
|
|
734
|
-
} catch (error) {
|
|
735
|
-
this.logger.warn(`Failed to delete agent persistent state: ${error.message}`, { agentId });
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
this.logger.info(`Agent deleted: ${agentId}`, {
|
|
739
|
-
agentName: agent.name,
|
|
740
|
-
totalAgents: this.agents.size
|
|
741
|
-
});
|
|
742
|
-
|
|
743
|
-
return {
|
|
744
|
-
success: true,
|
|
745
|
-
agentId,
|
|
746
|
-
remainingAgents: this.agents.size
|
|
747
|
-
};
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
/**
|
|
751
|
-
* Generate unique agent ID
|
|
752
|
-
* @private
|
|
753
|
-
*/
|
|
754
|
-
_generateAgentId(name) {
|
|
755
|
-
const sanitizedName = name.toLowerCase().replace(/[^a-z0-9]/g, '-');
|
|
756
|
-
const timestamp = Date.now();
|
|
757
|
-
return `agent-${sanitizedName}-${timestamp}`;
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
/**
|
|
761
|
-
* Update agent directory for discovery
|
|
762
|
-
* @private
|
|
763
|
-
*/
|
|
764
|
-
_updateAgentDirectory(agent) {
|
|
765
|
-
this.agentDirectory.set(agent.id, {
|
|
766
|
-
id: agent.id,
|
|
767
|
-
name: agent.name,
|
|
768
|
-
type: agent.type,
|
|
769
|
-
capabilities: agent.capabilities,
|
|
770
|
-
status: agent.status,
|
|
771
|
-
description: this._generateAgentDescription(agent)
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
/**
|
|
776
|
-
* Generate agent description for directory
|
|
777
|
-
* @private
|
|
778
|
-
*/
|
|
779
|
-
_generateAgentDescription(agent) {
|
|
780
|
-
let description = `${agent.name} (${agent.type})`;
|
|
781
|
-
|
|
782
|
-
if (agent.capabilities.length > 0) {
|
|
783
|
-
description += ` - Capabilities: ${agent.capabilities.join(', ')}`;
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
return description;
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
/**
|
|
790
|
-
* Check if agent is currently paused
|
|
791
|
-
* @private
|
|
792
|
-
*/
|
|
793
|
-
_isAgentPaused(agent) {
|
|
794
|
-
if (agent.status !== AGENT_STATUS.PAUSED || !agent.pausedUntil) {
|
|
795
|
-
return false;
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
return new Date() < new Date(agent.pausedUntil);
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
/**
|
|
802
|
-
* Check if pause duration has expired
|
|
803
|
-
* @private
|
|
804
|
-
*/
|
|
805
|
-
_isPauseExpired(agent) {
|
|
806
|
-
if (!agent.pausedUntil) return true;
|
|
807
|
-
return new Date() >= new Date(agent.pausedUntil);
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
/**
|
|
811
|
-
* Update agent pause status
|
|
812
|
-
* @private
|
|
813
|
-
*/
|
|
814
|
-
_updateAgentPauseStatus(agent) {
|
|
815
|
-
if (agent.status === AGENT_STATUS.PAUSED && this._isPauseExpired(agent)) {
|
|
816
|
-
agent.status = AGENT_STATUS.ACTIVE;
|
|
817
|
-
agent.pausedUntil = null;
|
|
818
|
-
this.pausedAgents.delete(agent.id);
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
/**
|
|
823
|
-
* Queue notification for paused agent
|
|
824
|
-
* @private
|
|
825
|
-
*/
|
|
826
|
-
_queueNotification(agentId, message) {
|
|
827
|
-
if (!this.notificationQueue.has(agentId)) {
|
|
828
|
-
this.notificationQueue.set(agentId, []);
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
this.notificationQueue.get(agentId).push({
|
|
832
|
-
...message,
|
|
833
|
-
queuedAt: new Date().toISOString()
|
|
834
|
-
});
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
/**
|
|
838
|
-
* Process queued notifications for agent
|
|
839
|
-
* @private
|
|
840
|
-
*/
|
|
841
|
-
async _processQueuedNotifications(agentId) {
|
|
842
|
-
const notifications = this.notificationQueue.get(agentId);
|
|
843
|
-
if (!notifications || notifications.length === 0) {
|
|
844
|
-
return;
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
this.logger.info(`Processing ${notifications.length} queued notifications for agent: ${agentId}`);
|
|
848
|
-
|
|
849
|
-
for (const notification of notifications) {
|
|
850
|
-
await this.notifyAgent(agentId, notification);
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
// Clear queue
|
|
854
|
-
this.notificationQueue.delete(agentId);
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
/**
|
|
858
|
-
* Format message for specific model
|
|
859
|
-
* @private
|
|
860
|
-
*/
|
|
861
|
-
_formatMessageForModel(message, targetModel) {
|
|
862
|
-
// This would be implemented with model-specific formatting logic
|
|
863
|
-
// For now, return the message as-is
|
|
864
|
-
return { ...message };
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
/**
|
|
868
|
-
* Get model format version
|
|
869
|
-
* @private
|
|
870
|
-
*/
|
|
871
|
-
_getModelFormatVersion(model) {
|
|
872
|
-
return MODEL_FORMAT_VERSIONS[model] || MODEL_FORMAT_VERSIONS.DEFAULT;
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
/**
|
|
876
|
-
* Refresh tool descriptions for an existing agent
|
|
877
|
-
* @param {string} agentId - Agent identifier
|
|
878
|
-
* @param {Object} options - Refresh options
|
|
879
|
-
* @returns {Promise<boolean>} Success status
|
|
880
|
-
*/
|
|
881
|
-
async refreshAgentToolDescriptions(agentId, options = {}) {
|
|
882
|
-
const agent = await this.getAgent(agentId);
|
|
883
|
-
if (!agent || !this.toolsRegistry) {
|
|
884
|
-
return false;
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
try {
|
|
888
|
-
// Use original prompt if available, otherwise current prompt
|
|
889
|
-
const basePrompt = agent.originalSystemPrompt || agent.systemPrompt;
|
|
890
|
-
|
|
891
|
-
// Enhance with current tool capabilities
|
|
892
|
-
const enhancedPrompt = this.toolsRegistry.enhanceSystemPrompt(
|
|
893
|
-
basePrompt,
|
|
894
|
-
agent.capabilities,
|
|
895
|
-
{
|
|
896
|
-
compact: options.compact || false,
|
|
897
|
-
includeExamples: options.includeExamples !== false,
|
|
898
|
-
includeUsageGuidelines: options.includeUsageGuidelines !== false,
|
|
899
|
-
includeSecurityNotes: options.includeSecurityNotes !== false
|
|
900
|
-
}
|
|
901
|
-
);
|
|
902
|
-
|
|
903
|
-
// Update agent's system prompt
|
|
904
|
-
agent.systemPrompt = enhancedPrompt;
|
|
905
|
-
agent.lastActivity = new Date().toISOString();
|
|
906
|
-
|
|
907
|
-
// Persist changes
|
|
908
|
-
await this.stateManager.persistAgentState(agentId);
|
|
909
|
-
|
|
910
|
-
this.logger?.info(`Agent tool descriptions refreshed: ${agentId}`, {
|
|
911
|
-
capabilities: agent.capabilities,
|
|
912
|
-
promptLength: enhancedPrompt.length
|
|
913
|
-
});
|
|
914
|
-
|
|
915
|
-
return true;
|
|
916
|
-
|
|
917
|
-
} catch (error) {
|
|
918
|
-
this.logger?.error(`Failed to refresh tool descriptions for agent: ${agentId}`, {
|
|
919
|
-
error: error.message
|
|
920
|
-
});
|
|
921
|
-
return false;
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
/**
|
|
926
|
-
* Set or update tools registry for the agent pool
|
|
927
|
-
* @param {ToolsRegistry} toolsRegistry - Tools registry instance
|
|
928
|
-
*/
|
|
929
|
-
setToolsRegistry(toolsRegistry) {
|
|
930
|
-
this.toolsRegistry = toolsRegistry;
|
|
931
|
-
|
|
932
|
-
this.logger?.info('Tools registry updated for agent pool', {
|
|
933
|
-
hasRegistry: !!toolsRegistry
|
|
934
|
-
});
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
/**
|
|
938
|
-
* Bulk refresh tool descriptions for all agents
|
|
939
|
-
* @param {Object} options - Refresh options
|
|
940
|
-
* @returns {Promise<Object>} Results summary
|
|
941
|
-
*/
|
|
942
|
-
async bulkRefreshToolDescriptions(options = {}) {
|
|
943
|
-
const results = {
|
|
944
|
-
total: this.agents.size,
|
|
945
|
-
successful: 0,
|
|
946
|
-
failed: 0,
|
|
947
|
-
skipped: 0
|
|
948
|
-
};
|
|
949
|
-
|
|
950
|
-
for (const [agentId, agent] of this.agents.entries()) {
|
|
951
|
-
if (!agent.capabilities || agent.capabilities.length === 0) {
|
|
952
|
-
results.skipped++;
|
|
953
|
-
continue;
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
const success = await this.refreshAgentToolDescriptions(agentId, options);
|
|
957
|
-
if (success) {
|
|
958
|
-
results.successful++;
|
|
959
|
-
} else {
|
|
960
|
-
results.failed++;
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
this.logger?.info('Bulk tool descriptions refresh completed', results);
|
|
965
|
-
return results;
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
/**
|
|
969
|
-
* Set MessageProcessor reference for triggering responses
|
|
970
|
-
* @param {MessageProcessor} messageProcessor - MessageProcessor instance
|
|
971
|
-
*/
|
|
972
|
-
setMessageProcessor(messageProcessor) {
|
|
973
|
-
this.messageProcessor = messageProcessor;
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
/**
|
|
977
|
-
* Set AgentScheduler reference for managing agent modes
|
|
978
|
-
* @param {AgentScheduler} scheduler - AgentScheduler instance
|
|
979
|
-
*/
|
|
980
|
-
setScheduler(scheduler) {
|
|
981
|
-
this.scheduler = scheduler;
|
|
982
|
-
|
|
983
|
-
this.logger?.info('AgentScheduler reference set for agent pool', {
|
|
984
|
-
hasScheduler: !!scheduler
|
|
985
|
-
});
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
/**
|
|
989
|
-
* Set FileAttachmentService reference for cleaning up attachments
|
|
990
|
-
* @param {FileAttachmentService} fileAttachmentService - FileAttachmentService instance
|
|
991
|
-
*/
|
|
992
|
-
setFileAttachmentService(fileAttachmentService) {
|
|
993
|
-
this.fileAttachmentService = fileAttachmentService;
|
|
994
|
-
|
|
995
|
-
this.logger?.info('FileAttachmentService reference set for agent pool', {
|
|
996
|
-
hasService: !!fileAttachmentService
|
|
997
|
-
});
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
// OLD INTER-AGENT MESSAGE QUEUE SYSTEM REMOVED
|
|
1001
|
-
// Now using the new messageQueues system with AgentScheduler
|
|
1002
|
-
// Inter-agent messages are queued via addInterAgentMessage() method
|
|
1003
|
-
|
|
1004
|
-
/**
|
|
1005
|
-
* Add message to agent's user message queue
|
|
1006
|
-
* @param {string} agentId - Agent ID
|
|
1007
|
-
* @param {Object} message - User message to queue
|
|
1008
|
-
* @returns {Promise<void>}
|
|
1009
|
-
*/
|
|
1010
|
-
async addUserMessage(agentId, message) {
|
|
1011
|
-
const agent = await this.getAgent(agentId);
|
|
1012
|
-
if (!agent) {
|
|
1013
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1016
|
-
const queuedMessage = {
|
|
1017
|
-
...message,
|
|
1018
|
-
id: message.id || `user-msg-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
1019
|
-
queuedAt: new Date().toISOString(),
|
|
1020
|
-
timestamp: message.timestamp || new Date().toISOString()
|
|
1021
|
-
};
|
|
1022
|
-
|
|
1023
|
-
agent.messageQueues.userMessages.push(queuedMessage);
|
|
1024
|
-
await this.persistAgentState(agentId);
|
|
1025
|
-
|
|
1026
|
-
this.logger.info(`User message queued for agent: ${agentId}`, {
|
|
1027
|
-
messageId: queuedMessage.id,
|
|
1028
|
-
queueSize: agent.messageQueues.userMessages.length
|
|
1029
|
-
});
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
/**
|
|
1033
|
-
* Add message to agent's inter-agent message queue
|
|
1034
|
-
* @param {string} agentId - Agent ID
|
|
1035
|
-
* @param {Object} message - Inter-agent message to queue
|
|
1036
|
-
* @returns {Promise<void>}
|
|
1037
|
-
*/
|
|
1038
|
-
async addInterAgentMessage(agentId, message) {
|
|
1039
|
-
const agent = await this.getAgent(agentId);
|
|
1040
|
-
if (!agent) {
|
|
1041
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
const queuedMessage = {
|
|
1045
|
-
...message,
|
|
1046
|
-
id: message.id || message.messageId || `inter-agent-msg-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
1047
|
-
queuedAt: new Date().toISOString(),
|
|
1048
|
-
timestamp: message.timestamp || new Date().toISOString()
|
|
1049
|
-
};
|
|
1050
|
-
|
|
1051
|
-
agent.messageQueues.interAgentMessages.push(queuedMessage);
|
|
1052
|
-
await this.persistAgentState(agentId);
|
|
1053
|
-
|
|
1054
|
-
this.logger.info(`Inter-agent message queued for agent: ${agentId}`, {
|
|
1055
|
-
messageId: queuedMessage.id,
|
|
1056
|
-
sender: message.sender || message.senderName,
|
|
1057
|
-
queueSize: agent.messageQueues.interAgentMessages.length
|
|
1058
|
-
});
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
/**
|
|
1062
|
-
* Add tool result to agent's tool results queue
|
|
1063
|
-
* @param {string} agentId - Agent ID
|
|
1064
|
-
* @param {Object} toolResult - Tool result to queue
|
|
1065
|
-
* @returns {Promise<void>}
|
|
1066
|
-
*/
|
|
1067
|
-
async addToolResult(agentId, toolResult) {
|
|
1068
|
-
const agent = await this.getAgent(agentId);
|
|
1069
|
-
if (!agent) {
|
|
1070
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
const queuedResult = {
|
|
1074
|
-
...toolResult,
|
|
1075
|
-
id: toolResult.id || `tool-result-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
1076
|
-
queuedAt: new Date().toISOString(),
|
|
1077
|
-
timestamp: toolResult.timestamp || new Date().toISOString()
|
|
1078
|
-
};
|
|
1079
|
-
|
|
1080
|
-
agent.messageQueues.toolResults.push(queuedResult);
|
|
1081
|
-
await this.persistAgentState(agentId);
|
|
1082
|
-
|
|
1083
|
-
this.logger.debug(`Tool result queued for agent: ${agentId}`, {
|
|
1084
|
-
toolId: toolResult.toolId,
|
|
1085
|
-
status: toolResult.status,
|
|
1086
|
-
queueSize: agent.messageQueues.toolResults.length
|
|
1087
|
-
});
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
/**
|
|
1091
|
-
* Clear all message queues for an agent
|
|
1092
|
-
* @param {string} agentId - Agent ID
|
|
1093
|
-
* @returns {Promise<void>}
|
|
1094
|
-
*/
|
|
1095
|
-
async clearAgentQueues(agentId) {
|
|
1096
|
-
const agent = await this.getAgent(agentId);
|
|
1097
|
-
if (!agent) {
|
|
1098
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
agent.messageQueues.toolResults = [];
|
|
1102
|
-
agent.messageQueues.interAgentMessages = [];
|
|
1103
|
-
agent.messageQueues.userMessages = [];
|
|
1104
|
-
|
|
1105
|
-
await this.persistAgentState(agentId);
|
|
1106
|
-
|
|
1107
|
-
this.logger.info(`Message queues cleared for agent: ${agentId}`);
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
/**
|
|
1111
|
-
* Get total queued messages count for an agent
|
|
1112
|
-
* @param {string} agentId - Agent ID
|
|
1113
|
-
* @returns {Promise<Object>} Queue counts by type
|
|
1114
|
-
*/
|
|
1115
|
-
async getQueueCounts(agentId) {
|
|
1116
|
-
const agent = await this.getAgent(agentId);
|
|
1117
|
-
if (!agent) {
|
|
1118
|
-
return { toolResults: 0, interAgentMessages: 0, userMessages: 0, total: 0 };
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
const counts = {
|
|
1122
|
-
toolResults: agent.messageQueues.toolResults.length,
|
|
1123
|
-
interAgentMessages: agent.messageQueues.interAgentMessages.length,
|
|
1124
|
-
userMessages: agent.messageQueues.userMessages.length
|
|
1125
|
-
};
|
|
1126
|
-
|
|
1127
|
-
counts.total = counts.toolResults + counts.interAgentMessages + counts.userMessages;
|
|
1128
|
-
|
|
1129
|
-
return counts;
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
/**
|
|
1133
|
-
* Get messages for AI request - returns compacted if available, otherwise original
|
|
1134
|
-
* CRITICAL FIX: Ensures compacted messages stay in sync with new messages after compaction
|
|
1135
|
-
* This is the primary method that should be used when preparing messages for AI service
|
|
1136
|
-
* @param {string} agentId - Agent ID
|
|
1137
|
-
* @param {string} modelId - Model ID
|
|
1138
|
-
* @returns {Promise<Array>} Messages array to send to AI
|
|
1139
|
-
*/
|
|
1140
|
-
async getMessagesForAI(agentId, modelId) {
|
|
1141
|
-
const ENABLE_COMPACT_DEBUG = process.env.COMPACT_DEBUG === 'true';
|
|
1142
|
-
|
|
1143
|
-
const agent = await this.getAgent(agentId);
|
|
1144
|
-
if (!agent) {
|
|
1145
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
const conversation = agent.conversations[modelId];
|
|
1149
|
-
if (!conversation) {
|
|
1150
|
-
this.logger.warn(`No conversation found for model: ${modelId}`, { agentId });
|
|
1151
|
-
return [];
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
// If no compacted messages exist, return original
|
|
1155
|
-
if (!conversation.compactizedMessages) {
|
|
1156
|
-
this.logger.debug('Retrieved messages for AI (no compaction)', {
|
|
1157
|
-
agentId,
|
|
1158
|
-
modelId,
|
|
1159
|
-
messageCount: conversation.messages.length
|
|
1160
|
-
});
|
|
1161
|
-
|
|
1162
|
-
if (ENABLE_COMPACT_DEBUG) {
|
|
1163
|
-
console.log('[GET-MESSAGES-FOR-AI]', {
|
|
1164
|
-
agentId,
|
|
1165
|
-
modelId,
|
|
1166
|
-
returnedArray: 'originalMessages',
|
|
1167
|
-
messageCount: conversation.messages.length,
|
|
1168
|
-
reason: 'No compacted messages exist'
|
|
1169
|
-
});
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
return conversation.messages;
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
// CRITICAL FIX: Check if new messages were added after compaction
|
|
1176
|
-
// This fixes the bug where user input was ignored after compaction
|
|
1177
|
-
const compactedLength = conversation.compactizedMessages.length;
|
|
1178
|
-
const originalLength = conversation.messages.length;
|
|
1179
|
-
|
|
1180
|
-
if (originalLength > compactedLength) {
|
|
1181
|
-
// New messages exist in original that aren't in compacted
|
|
1182
|
-
const missingMessages = conversation.messages.slice(compactedLength);
|
|
1183
|
-
|
|
1184
|
-
this.logger.info('Syncing compacted messages with new messages', {
|
|
1185
|
-
agentId,
|
|
1186
|
-
modelId,
|
|
1187
|
-
compactedLength,
|
|
1188
|
-
originalLength,
|
|
1189
|
-
missingCount: missingMessages.length
|
|
1190
|
-
});
|
|
1191
|
-
|
|
1192
|
-
// Append missing messages to compacted array
|
|
1193
|
-
conversation.compactizedMessages.push(...missingMessages);
|
|
1194
|
-
|
|
1195
|
-
// Persist the update
|
|
1196
|
-
await this.persistAgentState(agentId);
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
|
-
this.logger.debug('Retrieved messages for AI (compacted + synced)', {
|
|
1200
|
-
agentId,
|
|
1201
|
-
modelId,
|
|
1202
|
-
messageCount: conversation.compactizedMessages.length,
|
|
1203
|
-
wasResynced: originalLength > compactedLength
|
|
1204
|
-
});
|
|
1205
|
-
|
|
1206
|
-
if (ENABLE_COMPACT_DEBUG) {
|
|
1207
|
-
console.log('[GET-MESSAGES-FOR-AI]', {
|
|
1208
|
-
agentId,
|
|
1209
|
-
modelId,
|
|
1210
|
-
returnedArray: 'compactizedMessages',
|
|
1211
|
-
messageCount: conversation.compactizedMessages.length,
|
|
1212
|
-
originalMessageCount: conversation.messages.length,
|
|
1213
|
-
wasSynced: originalLength > compactedLength,
|
|
1214
|
-
syncedMessageCount: originalLength > compactedLength ? originalLength - compactedLength : 0,
|
|
1215
|
-
reason: 'Compacted messages exist, returning compacted version'
|
|
1216
|
-
});
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
|
-
return conversation.compactizedMessages;
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
/**
|
|
1223
|
-
* Add message to conversation (stores in original messages array)
|
|
1224
|
-
* @param {string} agentId - Agent ID
|
|
1225
|
-
* @param {string} modelId - Model ID
|
|
1226
|
-
* @param {Object} message - Message object to add
|
|
1227
|
-
* @returns {Promise<void>}
|
|
1228
|
-
*/
|
|
1229
|
-
async addMessageToConversation(agentId, modelId, message) {
|
|
1230
|
-
const ENABLE_COMPACT_DEBUG = process.env.COMPACT_DEBUG === 'true';
|
|
1231
|
-
|
|
1232
|
-
const agent = await this.getAgent(agentId);
|
|
1233
|
-
if (!agent) {
|
|
1234
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
// Ensure model conversation exists
|
|
1238
|
-
if (!agent.conversations[modelId]) {
|
|
1239
|
-
agent.conversations[modelId] = this._createEmptyConversation(modelId);
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
const conversation = agent.conversations[modelId];
|
|
1243
|
-
|
|
1244
|
-
const originalLengthBefore = conversation.messages.length;
|
|
1245
|
-
const compactedLengthBefore = conversation.compactizedMessages?.length || 0;
|
|
1246
|
-
|
|
1247
|
-
// Always add to original messages (never modify original)
|
|
1248
|
-
conversation.messages.push({
|
|
1249
|
-
...message,
|
|
1250
|
-
timestamp: message.timestamp || new Date().toISOString()
|
|
1251
|
-
});
|
|
1252
|
-
|
|
1253
|
-
// If compacted version exists, also add to it (append new messages after compaction)
|
|
1254
|
-
if (conversation.compactizedMessages) {
|
|
1255
|
-
conversation.compactizedMessages.push({
|
|
1256
|
-
...message,
|
|
1257
|
-
timestamp: message.timestamp || new Date().toISOString()
|
|
1258
|
-
});
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
conversation.lastUpdated = new Date().toISOString();
|
|
1262
|
-
|
|
1263
|
-
if (ENABLE_COMPACT_DEBUG) {
|
|
1264
|
-
console.log('[ADD-MESSAGE-TO-CONVERSATION]', {
|
|
1265
|
-
agentId,
|
|
1266
|
-
modelId,
|
|
1267
|
-
role: message.role,
|
|
1268
|
-
hasCompactedVersion: !!conversation.compactizedMessages,
|
|
1269
|
-
originalMessages: {
|
|
1270
|
-
before: originalLengthBefore,
|
|
1271
|
-
after: conversation.messages.length,
|
|
1272
|
-
added: 1
|
|
1273
|
-
},
|
|
1274
|
-
compactizedMessages: conversation.compactizedMessages ? {
|
|
1275
|
-
before: compactedLengthBefore,
|
|
1276
|
-
after: conversation.compactizedMessages.length,
|
|
1277
|
-
added: 1
|
|
1278
|
-
} : null,
|
|
1279
|
-
behavior: conversation.compactizedMessages ? 'Added to BOTH arrays' : 'Added to original only'
|
|
1280
|
-
});
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
await this.persistAgentState(agentId);
|
|
1284
|
-
|
|
1285
|
-
this.logger.debug('Message added to conversation', {
|
|
1286
|
-
agentId,
|
|
1287
|
-
modelId,
|
|
1288
|
-
role: message.role,
|
|
1289
|
-
hasCompacted: !!conversation.compactizedMessages
|
|
1290
|
-
});
|
|
1291
|
-
}
|
|
1292
|
-
|
|
1293
|
-
/**
|
|
1294
|
-
* Update compacted messages after compactization
|
|
1295
|
-
* @param {string} agentId - Agent ID
|
|
1296
|
-
* @param {string} modelId - Model ID
|
|
1297
|
-
* @param {Object} compactionResult - Compaction result with messages and metadata
|
|
1298
|
-
* @returns {Promise<void>}
|
|
1299
|
-
*/
|
|
1300
|
-
async updateCompactedMessages(agentId, modelId, compactionResult) {
|
|
1301
|
-
const agent = await this.getAgent(agentId);
|
|
1302
|
-
if (!agent) {
|
|
1303
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
// Ensure model conversation exists (important for model switching scenarios)
|
|
1307
|
-
if (!agent.conversations[modelId]) {
|
|
1308
|
-
agent.conversations[modelId] = this._createEmptyConversation(modelId);
|
|
1309
|
-
this.logger.debug(`Created conversation for model switching: ${modelId}`);
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1312
|
-
const conversation = agent.conversations[modelId];
|
|
1313
|
-
|
|
1314
|
-
// Update compacted messages
|
|
1315
|
-
conversation.compactizedMessages = compactionResult.compactedMessages;
|
|
1316
|
-
|
|
1317
|
-
// Update metadata
|
|
1318
|
-
conversation.lastCompactization = new Date().toISOString();
|
|
1319
|
-
conversation.compactizationCount += 1;
|
|
1320
|
-
conversation.compactizationStrategy = compactionResult.strategy;
|
|
1321
|
-
conversation.originalTokenCount = compactionResult.originalTokenCount;
|
|
1322
|
-
conversation.compactedTokenCount = compactionResult.compactedTokenCount;
|
|
1323
|
-
conversation.tokenCount = compactionResult.compactedTokenCount;
|
|
1324
|
-
conversation.lastUpdated = new Date().toISOString();
|
|
1325
|
-
|
|
1326
|
-
await this.persistAgentState(agentId);
|
|
1327
|
-
|
|
1328
|
-
this.logger.info('Compacted messages updated', {
|
|
1329
|
-
agentId,
|
|
1330
|
-
modelId,
|
|
1331
|
-
strategy: compactionResult.strategy,
|
|
1332
|
-
originalTokens: compactionResult.originalTokenCount,
|
|
1333
|
-
compactedTokens: compactionResult.compactedTokenCount,
|
|
1334
|
-
reductionPercent: compactionResult.reductionPercent,
|
|
1335
|
-
compactizationCount: conversation.compactizationCount
|
|
1336
|
-
});
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
/**
|
|
1340
|
-
* Clear compacted messages and revert to original
|
|
1341
|
-
* Useful for debugging or if compaction needs to be redone
|
|
1342
|
-
* @param {string} agentId - Agent ID
|
|
1343
|
-
* @param {string} modelId - Model ID
|
|
1344
|
-
* @returns {Promise<void>}
|
|
1345
|
-
*/
|
|
1346
|
-
async clearCompactedMessages(agentId, modelId) {
|
|
1347
|
-
const agent = await this.getAgent(agentId);
|
|
1348
|
-
if (!agent) {
|
|
1349
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
const conversation = agent.conversations[modelId];
|
|
1353
|
-
if (!conversation) {
|
|
1354
|
-
return;
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
conversation.compactizedMessages = null;
|
|
1358
|
-
conversation.lastCompactization = null;
|
|
1359
|
-
conversation.compactizationCount = 0;
|
|
1360
|
-
conversation.compactizationStrategy = null;
|
|
1361
|
-
conversation.originalTokenCount = 0;
|
|
1362
|
-
conversation.compactedTokenCount = 0;
|
|
1363
|
-
conversation.tokenCount = 0;
|
|
1364
|
-
|
|
1365
|
-
await this.persistAgentState(agentId);
|
|
1366
|
-
|
|
1367
|
-
this.logger.info('Compacted messages cleared', { agentId, modelId });
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
/**
|
|
1371
|
-
* Get compaction metadata for a conversation
|
|
1372
|
-
* @param {string} agentId - Agent ID
|
|
1373
|
-
* @param {string} modelId - Model ID
|
|
1374
|
-
* @returns {Promise<Object|null>} Compaction metadata or null if no compaction
|
|
1375
|
-
*/
|
|
1376
|
-
async getCompactionMetadata(agentId, modelId) {
|
|
1377
|
-
const agent = await this.getAgent(agentId);
|
|
1378
|
-
if (!agent) {
|
|
1379
|
-
return null;
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
const conversation = agent.conversations[modelId];
|
|
1383
|
-
if (!conversation) {
|
|
1384
|
-
return null;
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
// Return metadata whether compacted or not
|
|
1388
|
-
const isCompacted = !!conversation.compactizedMessages;
|
|
1389
|
-
|
|
1390
|
-
return {
|
|
1391
|
-
isCompacted,
|
|
1392
|
-
lastCompactization: conversation.lastCompactization || null,
|
|
1393
|
-
compactizationCount: conversation.compactizationCount || 0,
|
|
1394
|
-
strategy: conversation.compactizationStrategy || null,
|
|
1395
|
-
originalTokenCount: conversation.originalTokenCount || 0,
|
|
1396
|
-
compactedTokenCount: conversation.compactedTokenCount || 0,
|
|
1397
|
-
reductionPercent: conversation.originalTokenCount > 0
|
|
1398
|
-
? ((conversation.originalTokenCount - conversation.compactedTokenCount) / conversation.originalTokenCount) * 100
|
|
1399
|
-
: 0,
|
|
1400
|
-
originalMessages: conversation.messages || [],
|
|
1401
|
-
compactedMessages: conversation.compactizedMessages || null,
|
|
1402
|
-
originalMessageCount: conversation.messages?.length || 0,
|
|
1403
|
-
compactedMessageCount: conversation.compactizedMessages?.length || 0
|
|
1404
|
-
};
|
|
1405
|
-
}
|
|
1406
|
-
|
|
1407
|
-
/**
|
|
1408
|
-
* Migrate existing agent conversations to dual storage structure
|
|
1409
|
-
* Ensures backward compatibility with existing agents
|
|
1410
|
-
* @param {string} agentId - Agent ID
|
|
1411
|
-
* @returns {Promise<boolean>} True if migration was needed and performed
|
|
1412
|
-
*/
|
|
1413
|
-
async migrateConversationStructure(agentId) {
|
|
1414
|
-
const agent = await this.getAgent(agentId);
|
|
1415
|
-
if (!agent) {
|
|
1416
|
-
return false;
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
let migrated = false;
|
|
1420
|
-
|
|
1421
|
-
// Check each conversation for migration needs
|
|
1422
|
-
for (const [modelId, conversation] of Object.entries(agent.conversations)) {
|
|
1423
|
-
if (modelId === 'full') continue; // Skip full conversation
|
|
1424
|
-
|
|
1425
|
-
// Check if conversation needs migration (missing new fields)
|
|
1426
|
-
if (conversation.compactizedMessages === undefined) {
|
|
1427
|
-
// Add new fields
|
|
1428
|
-
conversation.compactizedMessages = null;
|
|
1429
|
-
conversation.lastCompactization = null;
|
|
1430
|
-
conversation.compactizationCount = 0;
|
|
1431
|
-
conversation.compactizationStrategy = null;
|
|
1432
|
-
conversation.originalTokenCount = 0;
|
|
1433
|
-
conversation.compactedTokenCount = 0;
|
|
1434
|
-
|
|
1435
|
-
migrated = true;
|
|
1436
|
-
|
|
1437
|
-
this.logger.info('Migrated conversation structure', {
|
|
1438
|
-
agentId,
|
|
1439
|
-
modelId,
|
|
1440
|
-
messageCount: conversation.messages?.length || 0
|
|
1441
|
-
});
|
|
1442
|
-
}
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
if (migrated) {
|
|
1446
|
-
await this.persistAgentState(agentId);
|
|
1447
|
-
}
|
|
1448
|
-
|
|
1449
|
-
return migrated;
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
|
-
/**
|
|
1453
|
-
* Create empty conversation structure with all required fields
|
|
1454
|
-
* @private
|
|
1455
|
-
* @param {string} modelId - Model ID
|
|
1456
|
-
* @returns {Object} Empty conversation structure
|
|
1457
|
-
*/
|
|
1458
|
-
_createEmptyConversation(modelId) {
|
|
1459
|
-
return {
|
|
1460
|
-
messages: [],
|
|
1461
|
-
compactizedMessages: null,
|
|
1462
|
-
lastCompactization: null,
|
|
1463
|
-
compactizationCount: 0,
|
|
1464
|
-
compactizationStrategy: null,
|
|
1465
|
-
originalTokenCount: 0,
|
|
1466
|
-
compactedTokenCount: 0,
|
|
1467
|
-
tokenCount: 0,
|
|
1468
|
-
lastUpdated: new Date().toISOString(),
|
|
1469
|
-
formatVersion: this._getModelFormatVersion(modelId)
|
|
1470
|
-
};
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
|
-
export default AgentPool;
|
|
1
|
+
const a0_0x2b39ae=a0_0x31e1;function a0_0x31e1(_0x2f59af,_0x4a1e0d){_0x2f59af=_0x2f59af-0x15a;const _0x336f7e=a0_0x336f();let _0x31e11a=_0x336f7e[_0x2f59af];if(a0_0x31e1['MjMQeP']===undefined){var _0x459c9c=function(_0x22c844){const _0x19d1ba='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x34de67='',_0x300ee0='';for(let _0x2dbbdb=0x0,_0x9a052f,_0x1100fb,_0x4fff6f=0x0;_0x1100fb=_0x22c844['charAt'](_0x4fff6f++);~_0x1100fb&&(_0x9a052f=_0x2dbbdb%0x4?_0x9a052f*0x40+_0x1100fb:_0x1100fb,_0x2dbbdb++%0x4)?_0x34de67+=String['fromCharCode'](0xff&_0x9a052f>>(-0x2*_0x2dbbdb&0x6)):0x0){_0x1100fb=_0x19d1ba['indexOf'](_0x1100fb);}for(let _0x459ab0=0x0,_0x578c39=_0x34de67['length'];_0x459ab0<_0x578c39;_0x459ab0++){_0x300ee0+='%'+('00'+_0x34de67['charCodeAt'](_0x459ab0)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x300ee0);};a0_0x31e1['ECcjbJ']=_0x459c9c,a0_0x31e1['tqBysh']={},a0_0x31e1['MjMQeP']=!![];}const _0x43f0aa=_0x336f7e[0x0],_0xf11e07=_0x2f59af+_0x43f0aa,_0x21888b=a0_0x31e1['tqBysh'][_0xf11e07];return!_0x21888b?(_0x31e11a=a0_0x31e1['ECcjbJ'](_0x31e11a),a0_0x31e1['tqBysh'][_0xf11e07]=_0x31e11a):_0x31e11a=_0x21888b,_0x31e11a;}(function(_0x1de884,_0x50d327){const _0xfaed57=a0_0x31e1,_0x544e4d=_0x1de884();while(!![]){try{const _0x385602=parseInt(_0xfaed57(0x208))/0x1+-parseInt(_0xfaed57(0x17d))/0x2*(parseInt(_0xfaed57(0x164))/0x3)+parseInt(_0xfaed57(0x16f))/0x4*(-parseInt(_0xfaed57(0x18f))/0x5)+parseInt(_0xfaed57(0x1f2))/0x6*(-parseInt(_0xfaed57(0x1ef))/0x7)+-parseInt(_0xfaed57(0x19d))/0x8+-parseInt(_0xfaed57(0x1c9))/0x9*(-parseInt(_0xfaed57(0x190))/0xa)+parseInt(_0xfaed57(0x172))/0xb;if(_0x385602===_0x50d327)break;else _0x544e4d['push'](_0x544e4d['shift']());}catch(_0x2ff066){_0x544e4d['push'](_0x544e4d['shift']());}}}(a0_0x336f,0xb132f));import{AGENT_TYPES,AGENT_STATUS,AGENT_MODES,AGENT_MODE_STATES,MESSAGE_ROLES,MESSAGE_TYPES,INTER_AGENT_MESSAGE,MODEL_FORMAT_VERSIONS,SYSTEM_DEFAULTS}from'../utilities/constants.js';import a0_0x34de67 from'../utilities/directoryAccessManager.js';class AgentPool{constructor(_0x300ee0,_0x2dbbdb,_0x9a052f,_0x1100fb,_0x4fff6f=null){const _0x1accee=a0_0x31e1;this['config']=_0x300ee0,this[_0x1accee(0x167)]=_0x2dbbdb,this['stateManager']=_0x9a052f,this[_0x1accee(0x199)]=_0x1100fb,this['toolsRegistry']=_0x4fff6f,this[_0x1accee(0x19e)]=new Map(),this[_0x1accee(0x186)]=new Map(),this[_0x1accee(0x193)]=new Map(),this['notificationQueue']=new Map(),this[_0x1accee(0x161)]=_0x300ee0['system']?.['maxAgentsPerProject']||SYSTEM_DEFAULTS['MAX_AGENTS_PER_PROJECT'],this['messageProcessor']=null,this[_0x1accee(0x17a)]=new a0_0x34de67(_0x300ee0,_0x2dbbdb);}async[a0_0x2b39ae(0x1bd)](_0x459ab0){const _0x4d5a7c=a0_0x2b39ae;if(this[_0x4d5a7c(0x19e)]['size']>=this['maxAgentsPerProject'])throw new Error('Maximum\x20agents\x20per\x20project\x20exceeded\x20('+this['maxAgentsPerProject']+')');const _0x578c39=this[_0x4d5a7c(0x18e)](_0x459ab0[_0x4d5a7c(0x182)]),_0x5a77d3=new Date()[_0x4d5a7c(0x1a5)]();let _0x458e33=_0x459ab0['systemPrompt'];if(this[_0x4d5a7c(0x185)]&&_0x459ab0[_0x4d5a7c(0x17c)]&&_0x459ab0['capabilities'][_0x4d5a7c(0x1d5)]>0x0)try{_0x458e33=this[_0x4d5a7c(0x185)][_0x4d5a7c(0x1dd)](_0x459ab0[_0x4d5a7c(0x201)],_0x459ab0[_0x4d5a7c(0x17c)],{'compact':_0x459ab0[_0x4d5a7c(0x1f1)]||![],'includeExamples':_0x459ab0['includeToolExamples']!==![],'includeUsageGuidelines':_0x459ab0[_0x4d5a7c(0x16d)]!==![],'includeSecurityNotes':_0x459ab0[_0x4d5a7c(0x1c8)]!==![]}),this[_0x4d5a7c(0x167)]?.['info'](_0x4d5a7c(0x196),{'agentId':_0x578c39,'capabilities':_0x459ab0[_0x4d5a7c(0x17c)],'originalLength':_0x459ab0[_0x4d5a7c(0x201)]?.['length']||0x0,'enhancedLength':_0x458e33?.['length']||0x0});}catch(_0x17662f){this['logger']?.[_0x4d5a7c(0x1b7)]('Failed\x20to\x20enhance\x20system\x20prompt\x20with\x20tools',{'agentId':_0x578c39,'error':_0x17662f['message'],'capabilities':_0x459ab0[_0x4d5a7c(0x17c)]}),_0x458e33=_0x459ab0['systemPrompt'];}let _0x5ad820;console['log'](_0x4d5a7c(0x1c2),_0x459ab0[_0x4d5a7c(0x1b2)]?_0x4d5a7c(0x1ff):'NULL/UNDEFINED');_0x459ab0['directoryAccess']&&console[_0x4d5a7c(0x1c7)]('AgentPool DEBUG: createAgent - directoryAccess from config:',JSON['stringify'](_0x459ab0[_0x4d5a7c(0x1b2)],null,0x2));console[_0x4d5a7c(0x1c7)]('AgentPool\x20DEBUG:\x20createAgent\x20-\x20config.projectDir:',_0x459ab0[_0x4d5a7c(0x189)]);if(_0x459ab0['directoryAccess']){const _0xeeb1b9=this['directoryAccessManager'][_0x4d5a7c(0x19b)](_0x459ab0['directoryAccess']);console['log']('AgentPool\x20DEBUG:\x20createAgent\x20-\x20validation\x20result:',_0xeeb1b9);if(!_0xeeb1b9[_0x4d5a7c(0x1d6)])throw new Error('Invalid\x20directory\x20access\x20configuration:\x20'+_0xeeb1b9['errors']['join'](',\x20'));_0x5ad820=_0x459ab0['directoryAccess'],console['log']('AgentPool\x20DEBUG:\x20createAgent\x20-\x20Using\x20provided\x20directoryAccess');}else{const _0x4662ca=_0x459ab0[_0x4d5a7c(0x189)]||process['cwd']();_0x5ad820=a0_0x34de67[_0x4d5a7c(0x1d9)](_0x4662ca),console[_0x4d5a7c(0x1c7)]('AgentPool DEBUG: createAgent - Created default directoryAccess for projectDir:',_0x4662ca),console['log']('AgentPool\x20DEBUG:\x20createAgent\x20-\x20Default\x20directoryAccess:',JSON['stringify'](_0x5ad820,null,0x2));}const _0xab0da4={'id':_0x578c39,'type':_0x459ab0[_0x4d5a7c(0x18d)]||AGENT_TYPES[_0x4d5a7c(0x198)],'name':_0x459ab0['name']||'Agent-'+Date[_0x4d5a7c(0x206)](),'systemPrompt':_0x458e33,'originalSystemPrompt':_0x459ab0[_0x4d5a7c(0x201)],'preferredModel':_0x459ab0[_0x4d5a7c(0x1f7)],'status':AGENT_STATUS[_0x4d5a7c(0x1c5)],'capabilities':_0x459ab0['capabilities']||[],'directoryAccess':_0x5ad820,'conversations':{'full':{'messages':[],'lastUpdated':_0x5a77d3}},'currentModel':_0x459ab0[_0x4d5a7c(0x1f7)],'dynamicModelRouting':_0x459ab0[_0x4d5a7c(0x20a)]||![],'platformProvided':_0x459ab0['platformProvided']||![],'mode':_0x459ab0['mode']||AGENT_MODES[_0x4d5a7c(0x1fb)],'modeState':AGENT_MODE_STATES[_0x4d5a7c(0x180)],'currentTask':null,'taskStartTime':null,'maxIterations':_0x459ab0[_0x4d5a7c(0x1bf)]||0xa,'iterationCount':0x0,'stopRequested':![],'delayEndTime':null,'messageQueues':{'toolResults':[],'interAgentMessages':[],'userMessages':[]},'createdAt':_0x5a77d3,'lastActivity':_0x5a77d3,'pausedUntil':null,'metadata':_0x459ab0[_0x4d5a7c(0x18a)]||{},'sessionId':_0x459ab0[_0x4d5a7c(0x1d2)],'interAgentTracking':new Map(),'taskList':{'tasks':[],'lastUpdated':_0x5a77d3},'incomingMessages':[]};return this[_0x4d5a7c(0x167)][_0x4d5a7c(0x168)]('Agent\x20created\x20with\x20routing\x20config',{'agentId':_0x578c39,'dynamicModelRouting':_0xab0da4['dynamicModelRouting'],'platformProvided':_0xab0da4[_0x4d5a7c(0x203)],'preferredModel':_0xab0da4[_0x4d5a7c(0x1f7)]}),_0x459ab0['preferredModel']&&(_0xab0da4['conversations'][_0x459ab0[_0x4d5a7c(0x1f7)]]={'messages':[],'compactizedMessages':null,'lastCompactization':null,'compactizationCount':0x0,'compactizationStrategy':null,'originalTokenCount':0x0,'compactedTokenCount':0x0,'tokenCount':0x0,'lastUpdated':_0x5a77d3,'formatVersion':this['_getModelFormatVersion'](_0x459ab0[_0x4d5a7c(0x1f7)])}),this[_0x4d5a7c(0x19e)][_0x4d5a7c(0x17f)](_0x578c39,_0xab0da4),this[_0x4d5a7c(0x1cf)](_0xab0da4),await this['stateManager']['persistAgentState'](_0x578c39),this[_0x4d5a7c(0x167)][_0x4d5a7c(0x168)](_0x4d5a7c(0x16e)+_0x578c39,{'agentId':_0x578c39,'name':_0xab0da4[_0x4d5a7c(0x182)],'type':_0xab0da4[_0x4d5a7c(0x18d)],'model':_0xab0da4[_0x4d5a7c(0x1f7)]}),_0xab0da4;}async[a0_0x2b39ae(0x1d1)](_0x3f0377,_0x1512ba=![]){const _0x7d67f7=a0_0x2b39ae,_0x4f0536=this['agents'][_0x7d67f7(0x188)](_0x3f0377);if(!_0x4f0536)return null;return _0x1512ba&&this[_0x7d67f7(0x1df)]&&(_0x4f0536['inScheduler']=this['scheduler'][_0x7d67f7(0x205)](_0x3f0377)),_0x4f0536;}async[a0_0x2b39ae(0x1eb)](_0xb1f0bd,_0x325f88){const _0x437779=a0_0x2b39ae,_0x2c3274=await this[_0x437779(0x1d1)](_0xb1f0bd);if(!_0x2c3274)throw new Error(_0x437779(0x1e6)+_0xb1f0bd);this['logger']['info'](_0x437779(0x184)+_0xb1f0bd,{'updates':_0x325f88,'currentName':_0x2c3274[_0x437779(0x182)]});if(_0x325f88[_0x437779(0x1b2)]){const _0x11d620=this['directoryAccessManager']['validateAccessConfiguration'](_0x325f88['directoryAccess']);if(!_0x11d620['valid'])throw new Error(_0x437779(0x16b)+_0x11d620[_0x437779(0x1f9)]['join'](',\x20'));this[_0x437779(0x167)]['info']('Directory\x20access\x20validation\x20passed\x20for\x20agent:\x20'+_0xb1f0bd,{'workingDirectory':_0x325f88[_0x437779(0x1b2)][_0x437779(0x1c1)],'readOnlyDirs':_0x325f88['directoryAccess'][_0x437779(0x166)]?.[_0x437779(0x1d5)]||0x0,'writeEnabledDirs':_0x325f88[_0x437779(0x1b2)][_0x437779(0x1ca)]?.['length']||0x0});}if(_0x325f88['capabilities']&&this[_0x437779(0x185)])try{const _0x3c0053=_0x2c3274[_0x437779(0x1c4)]||_0x2c3274['systemPrompt'],_0x1de375=this['toolsRegistry']['enhanceSystemPrompt'](_0x3c0053,_0x325f88[_0x437779(0x17c)],{'compact':_0x2c3274['compactToolDescriptions']||![],'includeExamples':_0x2c3274['includeToolExamples']!==![],'includeUsageGuidelines':_0x2c3274[_0x437779(0x16d)]!==![],'includeSecurityNotes':_0x2c3274['includeSecurityNotes']!==![]});_0x325f88['systemPrompt']=_0x1de375,this['logger'][_0x437779(0x168)](_0x437779(0x192),{'agentId':_0xb1f0bd,'oldCapabilities':_0x2c3274['capabilities'],'newCapabilities':_0x325f88[_0x437779(0x17c)],'originalLength':_0x3c0053?.['length']||0x0,'enhancedLength':_0x1de375?.[_0x437779(0x1d5)]||0x0});}catch(_0x5bceeb){this[_0x437779(0x167)]['error'](_0x437779(0x1b4),{'agentId':_0xb1f0bd,'error':_0x5bceeb[_0x437779(0x19c)],'capabilities':_0x325f88[_0x437779(0x17c)]});}const _0x5e9df7={..._0x2c3274,..._0x325f88,'id':_0xb1f0bd,'lastModified':new Date()['toISOString'](),'lastActivity':new Date()['toISOString']()};if(_0x325f88['preferredModel']&&_0x325f88[_0x437779(0x1f7)]!==_0x2c3274[_0x437779(0x1f7)]){const _0x57eff7=_0x2c3274[_0x437779(0x1f7)],_0x568dd2=_0x325f88[_0x437779(0x1f7)];_0x5e9df7['currentModel']=_0x568dd2;!_0x5e9df7['conversations'][_0x568dd2]&&(_0x5e9df7[_0x437779(0x1de)][_0x568dd2]=this[_0x437779(0x1c0)](_0x568dd2),this['logger'][_0x437779(0x168)]('Created\x20conversation\x20for\x20new\x20model:\x20'+_0x568dd2,{'agentId':_0xb1f0bd}));if(_0x57eff7&&_0x5e9df7['conversations'][_0x57eff7]){const _0x17496a=_0x5e9df7['conversations'][_0x57eff7],_0x319906=_0x5e9df7['conversations'][_0x568dd2];_0x319906[_0x437779(0x178)][_0x437779(0x1d5)]===0x0&&_0x17496a['messages'][_0x437779(0x1d5)]>0x0&&(_0x319906[_0x437779(0x178)]=[..._0x17496a['messages']],_0x17496a[_0x437779(0x197)]&&(_0x319906['compactizedMessages']=[..._0x17496a[_0x437779(0x197)]],_0x319906[_0x437779(0x1ee)]=_0x17496a['lastCompactization'],_0x319906['compactizationCount']=_0x17496a[_0x437779(0x15a)],_0x319906[_0x437779(0x1c6)]=_0x17496a['compactizationStrategy'],_0x319906[_0x437779(0x1ec)]=_0x17496a['originalTokenCount'],_0x319906[_0x437779(0x1d4)]=_0x17496a['compactedTokenCount']),_0x319906[_0x437779(0x1b1)]=new Date()[_0x437779(0x1a5)](),this['logger'][_0x437779(0x168)]('Copied\x20conversation\x20history\x20from\x20'+_0x57eff7+'\x20to\x20'+_0x568dd2,{'agentId':_0xb1f0bd,'messageCount':_0x319906[_0x437779(0x178)]['length'],'hasCompacted':!!_0x319906[_0x437779(0x197)]}));}this['logger'][_0x437779(0x168)]('Model\x20changed\x20via\x20UI\x20-\x20updating\x20both\x20preferredModel\x20and\x20currentModel',{'agentId':_0xb1f0bd,'oldModel':_0x57eff7,'newModel':_0x568dd2,'conversationCopied':_0x57eff7&&_0x5e9df7['conversations'][_0x57eff7]?.[_0x437779(0x178)]['length']>0x0});}this['agents'][_0x437779(0x17f)](_0xb1f0bd,_0x5e9df7),this[_0x437779(0x167)]['info']('Agent\x20updated\x20in\x20registry\x20with\x20mode:\x20'+_0x5e9df7[_0x437779(0x1ba)],{'agentId':_0xb1f0bd,'beforeMode':_0x2c3274['mode'],'afterMode':_0x5e9df7['mode'],'allUpdates':Object['keys'](_0x325f88)}),this['_updateAgentDirectory'](_0x5e9df7),await this[_0x437779(0x1a6)][_0x437779(0x1a0)](_0x5e9df7);if(_0x325f88[_0x437779(0x1ba)]===AGENT_MODES['AGENT']&&this[_0x437779(0x1df)]){const _0x2bb2c4=_0x325f88['sessionId']||_0x5e9df7[_0x437779(0x1d2)];!_0x2bb2c4&&this[_0x437779(0x167)][_0x437779(0x1a4)](_0x437779(0x160)+_0xb1f0bd+_0x437779(0x1a8)),this['logger']['info']('Adding\x20agent\x20to\x20scheduler\x20(switched\x20to\x20AGENT\x20mode):\x20'+_0xb1f0bd,{'agentName':_0x5e9df7[_0x437779(0x182)],'sessionId':_0x2bb2c4,'hasSessionId':!!_0x2bb2c4}),await this[_0x437779(0x1df)][_0x437779(0x15b)](_0xb1f0bd,{'sessionId':_0x2bb2c4,'triggeredBy':'mode-change','reason':_0x437779(0x1aa)});}return _0x2c3274[_0x437779(0x1ba)]===AGENT_MODES[_0x437779(0x20c)]&&_0x325f88['mode']===AGENT_MODES[_0x437779(0x1fb)]&&this['scheduler']&&(this[_0x437779(0x167)]['info'](_0x437779(0x191)+_0xb1f0bd),this[_0x437779(0x1df)][_0x437779(0x1c3)](_0xb1f0bd,'mode-change-to-chat')),this[_0x437779(0x167)]['info']('Agent\x20updated\x20successfully:\x20'+_0xb1f0bd,{'newName':_0x5e9df7['name'],'changes':Object[_0x437779(0x17b)](_0x325f88)}),_0x5e9df7;}async[a0_0x2b39ae(0x195)](_0x961fe8,_0x185fd6){const _0x470a5d=a0_0x2b39ae,_0x594e4b=await this[_0x470a5d(0x1d1)](_0x961fe8);if(!_0x594e4b)return this[_0x470a5d(0x167)]['warn']('Agent\x20notification\x20failed\x20-\x20agent\x20not\x20found:\x20'+_0x961fe8),![];if(this[_0x470a5d(0x1b3)](_0x594e4b))return this['logger']['info'](_0x470a5d(0x19f)+_0x961fe8),this['_queueNotification'](_0x961fe8,_0x185fd6),!![];const _0x26e611={'id':'msg-'+Date['now'](),'conversationId':_0x185fd6['conversationId'],'agentId':_0x185fd6['from'],'content':_0x185fd6[_0x470a5d(0x16c)],'role':MESSAGE_ROLES['SYSTEM'],'timestamp':new Date()['toISOString'](),'type':MESSAGE_TYPES['AGENT_NOTIFICATION'],'fromAgent':_0x185fd6[_0x470a5d(0x170)],'context':_0x185fd6['context'],'urgent':_0x185fd6['urgent']||![],'requiresResponse':_0x185fd6[_0x470a5d(0x175)]||![]};_0x594e4b['conversations']['full']['messages']['push'](_0x26e611),_0x594e4b[_0x470a5d(0x1de)][_0x470a5d(0x163)]['lastUpdated']=new Date()['toISOString']();if(_0x594e4b['currentModel']&&_0x594e4b[_0x470a5d(0x1de)][_0x594e4b[_0x470a5d(0x1b9)]]){const _0x345475=this[_0x470a5d(0x1db)](_0x26e611,_0x594e4b['currentModel']);_0x594e4b['conversations'][_0x594e4b['currentModel']]['messages'][_0x470a5d(0x1a7)](_0x345475),_0x594e4b['conversations'][_0x594e4b[_0x470a5d(0x1b9)]]['lastUpdated']=new Date()['toISOString']();}return _0x594e4b['lastActivity']=new Date()[_0x470a5d(0x1a5)](),await this[_0x470a5d(0x1a0)](_0x961fe8),this[_0x470a5d(0x167)][_0x470a5d(0x168)]('Agent\x20notified:\x20'+_0x961fe8,{'fromAgent':_0x185fd6['from'],'urgent':_0x185fd6[_0x470a5d(0x18c)],'requiresResponse':_0x185fd6[_0x470a5d(0x175)]}),!![];}async['getAllAgents'](){const _0x28eb5d=a0_0x2b39ae,_0x4e1549=Array['from'](this['agents']['values']());for(const _0x24e025 of _0x4e1549){this[_0x28eb5d(0x1ab)](_0x24e025);}return _0x4e1549;}async[a0_0x2b39ae(0x176)](){const _0x545870=a0_0x2b39ae,_0x3e7c0d=Array['from'](this['agents']['values']());for(const _0x2845af of _0x3e7c0d){this['_updateAgentPauseStatus'](_0x2845af);}return _0x3e7c0d[_0x545870(0x15c)](_0x37eba3=>({'id':_0x37eba3['id'],'name':_0x37eba3['name'],'type':_0x37eba3[_0x545870(0x18d)],'status':_0x37eba3[_0x545870(0x1da)],'systemPrompt':_0x37eba3['systemPrompt'],'preferredModel':_0x37eba3[_0x545870(0x1f7)],'currentModel':_0x37eba3[_0x545870(0x1b9)],'dynamicModelRouting':_0x37eba3['dynamicModelRouting'],'platformProvided':_0x37eba3['platformProvided'],'capabilities':_0x37eba3['capabilities'],'lastActivity':_0x37eba3['lastActivity'],'isPaused':this['_isAgentPaused'](_0x37eba3),'pausedUntil':_0x37eba3[_0x545870(0x1ae)],'messageCount':_0x37eba3['conversations']['full']['messages'][_0x545870(0x1d5)],'createdAt':_0x37eba3[_0x545870(0x179)]}));}async[a0_0x2b39ae(0x1a0)](_0x29f1cf){const _0x2970e2=await this['getAgent'](_0x29f1cf);if(!_0x2970e2)throw new Error('Agent\x20not\x20found:\x20'+_0x29f1cf);await this['stateManager']['persistAgentState'](_0x2970e2);}async[a0_0x2b39ae(0x1ac)](_0x13930a){const _0x5103d6=a0_0x2b39ae,_0x3ffb64={..._0x13930a,'status':_0x13930a[_0x5103d6(0x1da)]==='paused'&&this[_0x5103d6(0x194)](_0x13930a)?'active':_0x13930a['status']};return(!_0x3ffb64['conversations']||!_0x3ffb64[_0x5103d6(0x1de)]['full'])&&(_0x3ffb64['conversations']={'full':{'messages':[],'lastUpdated':new Date()[_0x5103d6(0x1a5)]()}}),this[_0x5103d6(0x19e)]['set'](_0x3ffb64['id'],_0x3ffb64),this['_updateAgentDirectory'](_0x3ffb64),await this['_processQueuedNotifications'](_0x3ffb64['id']),this[_0x5103d6(0x167)]['info'](_0x5103d6(0x1e4)+_0x3ffb64['id'],{'name':_0x3ffb64['name'],'status':_0x3ffb64[_0x5103d6(0x1da)],'messageCount':_0x3ffb64['conversations'][_0x5103d6(0x163)][_0x5103d6(0x178)][_0x5103d6(0x1d5)]}),_0x3ffb64;}async['pauseAgent'](_0x56e653,_0x2f899f,_0x4e4044=a0_0x2b39ae(0x20d)){const _0x2c8242=a0_0x2b39ae,_0x56dd69=await this[_0x2c8242(0x1d1)](_0x56e653);if(!_0x56dd69)throw new Error(_0x2c8242(0x1e6)+_0x56e653);let _0x3a01e7;if(_0x2f899f instanceof Date)_0x3a01e7=_0x2f899f;else{const _0x5cc539=this['config']['system']?.[_0x2c8242(0x162)]||0x12c,_0x2ff9e8=Math['min'](_0x2f899f,_0x5cc539);_0x3a01e7=new Date(Date['now']()+_0x2ff9e8*0x3e8);}return _0x56dd69['status']=AGENT_STATUS['PAUSED'],_0x56dd69['pausedUntil']=_0x3a01e7[_0x2c8242(0x1a5)](),_0x56dd69['lastActivity']=new Date()[_0x2c8242(0x1a5)](),this['pausedAgents'][_0x2c8242(0x17f)](_0x56e653,{'agentId':_0x56e653,'pausedAt':new Date()['toISOString'](),'pausedUntil':_0x3a01e7['toISOString'](),'reason':_0x4e4044,'originalStatus':AGENT_STATUS[_0x2c8242(0x1c5)]}),await this[_0x2c8242(0x1a0)](_0x56e653),this[_0x2c8242(0x167)]['info']('Agent\x20paused:\x20'+_0x56e653,{'pausedUntil':_0x3a01e7[_0x2c8242(0x1a5)](),'reason':_0x4e4044,'durationSeconds':Math[_0x2c8242(0x1e2)]((_0x3a01e7[_0x2c8242(0x15d)]()-Date[_0x2c8242(0x206)]())/0x3e8)}),{'success':!![],'agentId':_0x56e653,'pausedUntil':_0x3a01e7['toISOString'](),'reason':_0x4e4044,'message':_0x2c8242(0x187)+_0x3a01e7[_0x2c8242(0x1a5)]()};}async[a0_0x2b39ae(0x1ac)](_0xb2830f){const _0x36e663=a0_0x2b39ae,_0x5ad312=await this[_0x36e663(0x1d1)](_0xb2830f);if(!_0x5ad312)throw new Error(_0x36e663(0x1e6)+_0xb2830f);if(_0x5ad312['status']!==AGENT_STATUS[_0x36e663(0x1f5)])return{'success':!![],'message':_0x36e663(0x160)+_0xb2830f+'\x20is\x20not\x20paused'};return _0x5ad312[_0x36e663(0x1da)]=AGENT_STATUS['ACTIVE'],_0x5ad312[_0x36e663(0x1ae)]=null,_0x5ad312['lastActivity']=new Date()[_0x36e663(0x1a5)](),this[_0x36e663(0x193)]['delete'](_0xb2830f),await this[_0x36e663(0x181)](_0xb2830f),await this['persistAgentState'](_0xb2830f),this['logger']['info']('Agent\x20resumed:\x20'+_0xb2830f),{'success':!![],'agentId':_0xb2830f,'message':_0x36e663(0x160)+_0xb2830f+'\x20resumed\x20successfully'};}async[a0_0x2b39ae(0x1a9)](_0xbb46a7){const _0x5a75f8=a0_0x2b39ae;return await this[_0x5a75f8(0x1ac)](_0xbb46a7);}[a0_0x2b39ae(0x165)](){const _0x511e06=a0_0x2b39ae;return Array[_0x511e06(0x170)](this['agentDirectory']['values']());}async[a0_0x2b39ae(0x1ce)](_0x3224c6){const _0x49c0d5=a0_0x2b39ae,_0xd0d4b5=await this[_0x49c0d5(0x1d1)](_0x3224c6);if(!_0xd0d4b5)throw new Error(_0x49c0d5(0x1e6)+_0x3224c6);if(this[_0x49c0d5(0x1a3)])try{await this['fileAttachmentService']['deleteAgentAttachments'](_0x3224c6),this['logger'][_0x49c0d5(0x168)](_0x49c0d5(0x1e3)+_0x3224c6);}catch(_0x1f5f88){this[_0x49c0d5(0x167)]['warn']('Failed\x20to\x20clean\x20up\x20file\x20attachments\x20for\x20agent:\x20'+_0x1f5f88[_0x49c0d5(0x19c)],{'agentId':_0x3224c6});}this['agents'][_0x49c0d5(0x173)](_0x3224c6),this[_0x49c0d5(0x186)]['delete'](_0x3224c6),this['pausedAgents']['delete'](_0x3224c6),this['notificationQueue']['delete'](_0x3224c6);try{await this['stateManager'][_0x49c0d5(0x1cc)](_0x3224c6);}catch(_0x3b0062){this['logger']['warn'](_0x49c0d5(0x1b5)+_0x3b0062['message'],{'agentId':_0x3224c6});}return this['logger']['info']('Agent\x20deleted:\x20'+_0x3224c6,{'agentName':_0xd0d4b5[_0x49c0d5(0x182)],'totalAgents':this[_0x49c0d5(0x19e)]['size']}),{'success':!![],'agentId':_0x3224c6,'remainingAgents':this['agents'][_0x49c0d5(0x1be)]};}['_generateAgentId'](_0x10e8d9){const _0x1867d0=a0_0x2b39ae,_0xd93597=_0x10e8d9['toLowerCase']()[_0x1867d0(0x16a)](/[^a-z0-9]/g,'-'),_0x27766a=Date['now']();return'agent-'+_0xd93597+'-'+_0x27766a;}['_updateAgentDirectory'](_0x1130df){const _0x4afb28=a0_0x2b39ae;this[_0x4afb28(0x186)]['set'](_0x1130df['id'],{'id':_0x1130df['id'],'name':_0x1130df['name'],'type':_0x1130df[_0x4afb28(0x18d)],'capabilities':_0x1130df[_0x4afb28(0x17c)],'status':_0x1130df['status'],'description':this['_generateAgentDescription'](_0x1130df)});}[a0_0x2b39ae(0x1f4)](_0x5657af){const _0x517e9f=a0_0x2b39ae;let _0x241078=_0x5657af['name']+'\x20('+_0x5657af['type']+')';return _0x5657af['capabilities']['length']>0x0&&(_0x241078+=_0x517e9f(0x19a)+_0x5657af[_0x517e9f(0x17c)][_0x517e9f(0x1bc)](',\x20')),_0x241078;}[a0_0x2b39ae(0x1b3)](_0x2ff2cb){const _0xb1cb41=a0_0x2b39ae;if(_0x2ff2cb['status']!==AGENT_STATUS['PAUSED']||!_0x2ff2cb['pausedUntil'])return![];return new Date()<new Date(_0x2ff2cb[_0xb1cb41(0x1ae)]);}[a0_0x2b39ae(0x194)](_0x205d1e){const _0x250a38=a0_0x2b39ae;if(!_0x205d1e[_0x250a38(0x1ae)])return!![];return new Date()>=new Date(_0x205d1e['pausedUntil']);}['_updateAgentPauseStatus'](_0x92113a){const _0x554133=a0_0x2b39ae;_0x92113a['status']===AGENT_STATUS[_0x554133(0x1f5)]&&this['_isPauseExpired'](_0x92113a)&&(_0x92113a[_0x554133(0x1da)]=AGENT_STATUS[_0x554133(0x1c5)],_0x92113a[_0x554133(0x1ae)]=null,this['pausedAgents'][_0x554133(0x173)](_0x92113a['id']));}['_queueNotification'](_0x3c77bd,_0x5da695){const _0x476069=a0_0x2b39ae;!this[_0x476069(0x15f)]['has'](_0x3c77bd)&&this['notificationQueue']['set'](_0x3c77bd,[]),this[_0x476069(0x15f)][_0x476069(0x188)](_0x3c77bd)[_0x476069(0x1a7)]({..._0x5da695,'queuedAt':new Date()['toISOString']()});}async['_processQueuedNotifications'](_0x30e589){const _0x2948c8=a0_0x2b39ae,_0x183470=this['notificationQueue'][_0x2948c8(0x188)](_0x30e589);if(!_0x183470||_0x183470[_0x2948c8(0x1d5)]===0x0)return;this[_0x2948c8(0x167)]['info']('Processing\x20'+_0x183470['length']+_0x2948c8(0x1cb)+_0x30e589);for(const _0x32cfba of _0x183470){await this[_0x2948c8(0x195)](_0x30e589,_0x32cfba);}this['notificationQueue'][_0x2948c8(0x173)](_0x30e589);}[a0_0x2b39ae(0x1db)](_0x23ec6c,_0xccf57b){return{..._0x23ec6c};}['_getModelFormatVersion'](_0x1e3e92){const _0x29056a=a0_0x2b39ae;return MODEL_FORMAT_VERSIONS[_0x1e3e92]||MODEL_FORMAT_VERSIONS[_0x29056a(0x1b6)];}async[a0_0x2b39ae(0x20b)](_0x5cdd62,_0x570512={}){const _0x2d3618=a0_0x2b39ae,_0x56bf2a=await this[_0x2d3618(0x1d1)](_0x5cdd62);if(!_0x56bf2a||!this[_0x2d3618(0x185)])return![];try{const _0x13a818=_0x56bf2a[_0x2d3618(0x1c4)]||_0x56bf2a['systemPrompt'],_0x5cdb91=this['toolsRegistry']['enhanceSystemPrompt'](_0x13a818,_0x56bf2a[_0x2d3618(0x17c)],{'compact':_0x570512[_0x2d3618(0x1d3)]||![],'includeExamples':_0x570512[_0x2d3618(0x1f0)]!==![],'includeUsageGuidelines':_0x570512[_0x2d3618(0x16d)]!==![],'includeSecurityNotes':_0x570512['includeSecurityNotes']!==![]});return _0x56bf2a['systemPrompt']=_0x5cdb91,_0x56bf2a[_0x2d3618(0x1fa)]=new Date()[_0x2d3618(0x1a5)](),await this['stateManager'][_0x2d3618(0x1a0)](_0x5cdd62),this[_0x2d3618(0x167)]?.[_0x2d3618(0x168)]('Agent\x20tool\x20descriptions\x20refreshed:\x20'+_0x5cdd62,{'capabilities':_0x56bf2a['capabilities'],'promptLength':_0x5cdb91[_0x2d3618(0x1d5)]}),!![];}catch(_0x3f4e99){return this[_0x2d3618(0x167)]?.[_0x2d3618(0x1b7)]('Failed\x20to\x20refresh\x20tool\x20descriptions\x20for\x20agent:\x20'+_0x5cdd62,{'error':_0x3f4e99['message']}),![];}}['setToolsRegistry'](_0x3e563a){const _0x5ad3ee=a0_0x2b39ae;this['toolsRegistry']=_0x3e563a,this['logger']?.['info'](_0x5ad3ee(0x20f),{'hasRegistry':!!_0x3e563a});}async[a0_0x2b39ae(0x15e)](_0x518a85={}){const _0x1e82f0=a0_0x2b39ae,_0x291622={'total':this['agents']['size'],'successful':0x0,'failed':0x0,'skipped':0x0};for(const [_0x577921,_0x108210]of this[_0x1e82f0(0x19e)]['entries']()){if(!_0x108210['capabilities']||_0x108210[_0x1e82f0(0x17c)]['length']===0x0){_0x291622['skipped']++;continue;}const _0x4f9c35=await this['refreshAgentToolDescriptions'](_0x577921,_0x518a85);_0x4f9c35?_0x291622['successful']++:_0x291622['failed']++;}return this['logger']?.['info']('Bulk\x20tool\x20descriptions\x20refresh\x20completed',_0x291622),_0x291622;}[a0_0x2b39ae(0x1fd)](_0x4f47b1){this['messageProcessor']=_0x4f47b1;}[a0_0x2b39ae(0x210)](_0x57c9a9){this['scheduler']=_0x57c9a9,this['logger']?.['info']('AgentScheduler\x20reference\x20set\x20for\x20agent\x20pool',{'hasScheduler':!!_0x57c9a9});}[a0_0x2b39ae(0x202)](_0x845a35){const _0x1a9b9e=a0_0x2b39ae;this[_0x1a9b9e(0x1a3)]=_0x845a35,this['logger']?.['info'](_0x1a9b9e(0x1d8),{'hasService':!!_0x845a35});}async[a0_0x2b39ae(0x1af)](_0x54bc2d,_0x573e40){const _0x3cce35=a0_0x2b39ae,_0xb80e94=await this[_0x3cce35(0x1d1)](_0x54bc2d);if(!_0xb80e94)throw new Error('Agent\x20not\x20found:\x20'+_0x54bc2d);const _0x396a04={..._0x573e40,'id':_0x573e40['id']||_0x3cce35(0x1cd)+Date[_0x3cce35(0x206)]()+'-'+Math['random']()['toString'](0x24)['substr'](0x2,0x9),'queuedAt':new Date()['toISOString'](),'timestamp':_0x573e40['timestamp']||new Date()[_0x3cce35(0x1a5)]()};_0xb80e94['messageQueues'][_0x3cce35(0x200)]['push'](_0x396a04),await this['persistAgentState'](_0x54bc2d),this['logger'][_0x3cce35(0x168)]('User\x20message\x20queued\x20for\x20agent:\x20'+_0x54bc2d,{'messageId':_0x396a04['id'],'queueSize':_0xb80e94['messageQueues']['userMessages']['length']});}async['addInterAgentMessage'](_0x127b2b,_0x273b22){const _0x456b86=a0_0x2b39ae,_0x438cb2=await this[_0x456b86(0x1d1)](_0x127b2b);if(!_0x438cb2)throw new Error('Agent\x20not\x20found:\x20'+_0x127b2b);const _0x53a6fb={..._0x273b22,'id':_0x273b22['id']||_0x273b22['messageId']||_0x456b86(0x1ad)+Date['now']()+'-'+Math['random']()['toString'](0x24)[_0x456b86(0x1a1)](0x2,0x9),'queuedAt':new Date()[_0x456b86(0x1a5)](),'timestamp':_0x273b22['timestamp']||new Date()[_0x456b86(0x1a5)]()};_0x438cb2[_0x456b86(0x1a2)][_0x456b86(0x1fc)][_0x456b86(0x1a7)](_0x53a6fb),await this['persistAgentState'](_0x127b2b),this[_0x456b86(0x167)][_0x456b86(0x168)]('Inter-agent\x20message\x20queued\x20for\x20agent:\x20'+_0x127b2b,{'messageId':_0x53a6fb['id'],'sender':_0x273b22[_0x456b86(0x1b0)]||_0x273b22['senderName'],'queueSize':_0x438cb2[_0x456b86(0x1a2)]['interAgentMessages']['length']});}async[a0_0x2b39ae(0x209)](_0x4b492a,_0x594f2c){const _0x5723cc=a0_0x2b39ae,_0x1d9680=await this['getAgent'](_0x4b492a);if(!_0x1d9680)throw new Error('Agent\x20not\x20found:\x20'+_0x4b492a);const _0x140458={..._0x594f2c,'id':_0x594f2c['id']||'tool-result-'+Date[_0x5723cc(0x206)]()+'-'+Math[_0x5723cc(0x1d0)]()[_0x5723cc(0x183)](0x24)['substr'](0x2,0x9),'queuedAt':new Date()[_0x5723cc(0x1a5)](),'timestamp':_0x594f2c[_0x5723cc(0x1e8)]||new Date()[_0x5723cc(0x1a5)]()};_0x1d9680['messageQueues']['toolResults'][_0x5723cc(0x1a7)](_0x140458),await this[_0x5723cc(0x1a0)](_0x4b492a),this[_0x5723cc(0x167)][_0x5723cc(0x1d7)]('Tool\x20result\x20queued\x20for\x20agent:\x20'+_0x4b492a,{'toolId':_0x594f2c['toolId'],'status':_0x594f2c['status'],'queueSize':_0x1d9680[_0x5723cc(0x1a2)][_0x5723cc(0x1ea)][_0x5723cc(0x1d5)]});}async['clearAgentQueues'](_0x126bdb){const _0x456a76=a0_0x2b39ae,_0x462994=await this['getAgent'](_0x126bdb);if(!_0x462994)throw new Error(_0x456a76(0x1e6)+_0x126bdb);_0x462994['messageQueues'][_0x456a76(0x1ea)]=[],_0x462994['messageQueues']['interAgentMessages']=[],_0x462994[_0x456a76(0x1a2)][_0x456a76(0x200)]=[],await this['persistAgentState'](_0x126bdb),this['logger'][_0x456a76(0x168)]('Message\x20queues\x20cleared\x20for\x20agent:\x20'+_0x126bdb);}async[a0_0x2b39ae(0x1f8)](_0x5d4814){const _0x236cb9=a0_0x2b39ae,_0x2356e8=await this[_0x236cb9(0x1d1)](_0x5d4814);if(!_0x2356e8)return{'toolResults':0x0,'interAgentMessages':0x0,'userMessages':0x0,'total':0x0};const _0x46e37e={'toolResults':_0x2356e8['messageQueues']['toolResults']['length'],'interAgentMessages':_0x2356e8[_0x236cb9(0x1a2)]['interAgentMessages'][_0x236cb9(0x1d5)],'userMessages':_0x2356e8['messageQueues'][_0x236cb9(0x200)][_0x236cb9(0x1d5)]};return _0x46e37e[_0x236cb9(0x1b8)]=_0x46e37e['toolResults']+_0x46e37e[_0x236cb9(0x1fc)]+_0x46e37e['userMessages'],_0x46e37e;}async['getMessagesForAI'](_0x3d16ea,_0x2c883d){const _0x993def=a0_0x2b39ae,_0x284eea=process[_0x993def(0x177)][_0x993def(0x174)]==='true',_0x44a003=await this['getAgent'](_0x3d16ea);if(!_0x44a003)throw new Error(_0x993def(0x1e6)+_0x3d16ea);const _0x5afe9b=_0x44a003[_0x993def(0x1de)][_0x2c883d];if(!_0x5afe9b)return this[_0x993def(0x167)][_0x993def(0x1a4)]('No\x20conversation\x20found\x20for\x20model:\x20'+_0x2c883d,{'agentId':_0x3d16ea}),[];if(!_0x5afe9b['compactizedMessages'])return this[_0x993def(0x167)]['debug']('Retrieved\x20messages\x20for\x20AI\x20(no\x20compaction)',{'agentId':_0x3d16ea,'modelId':_0x2c883d,'messageCount':_0x5afe9b['messages']['length']}),_0x284eea&&console[_0x993def(0x1c7)]('[GET-MESSAGES-FOR-AI]',{'agentId':_0x3d16ea,'modelId':_0x2c883d,'returnedArray':'originalMessages','messageCount':_0x5afe9b['messages']['length'],'reason':_0x993def(0x1ed)}),_0x5afe9b[_0x993def(0x178)];const _0x15105f=_0x5afe9b[_0x993def(0x197)][_0x993def(0x1d5)],_0x3b64a5=_0x5afe9b['messages']['length'];if(_0x3b64a5>_0x15105f){const _0x1271e6=_0x5afe9b['messages'][_0x993def(0x204)](_0x15105f);this['logger'][_0x993def(0x168)](_0x993def(0x1bb),{'agentId':_0x3d16ea,'modelId':_0x2c883d,'compactedLength':_0x15105f,'originalLength':_0x3b64a5,'missingCount':_0x1271e6['length']}),_0x5afe9b[_0x993def(0x197)][_0x993def(0x1a7)](..._0x1271e6),await this[_0x993def(0x1a0)](_0x3d16ea);}return this[_0x993def(0x167)][_0x993def(0x1d7)](_0x993def(0x1e5),{'agentId':_0x3d16ea,'modelId':_0x2c883d,'messageCount':_0x5afe9b['compactizedMessages']['length'],'wasResynced':_0x3b64a5>_0x15105f}),_0x284eea&&console[_0x993def(0x1c7)]('[GET-MESSAGES-FOR-AI]',{'agentId':_0x3d16ea,'modelId':_0x2c883d,'returnedArray':'compactizedMessages','messageCount':_0x5afe9b['compactizedMessages']['length'],'originalMessageCount':_0x5afe9b['messages'][_0x993def(0x1d5)],'wasSynced':_0x3b64a5>_0x15105f,'syncedMessageCount':_0x3b64a5>_0x15105f?_0x3b64a5-_0x15105f:0x0,'reason':_0x993def(0x1fe)}),_0x5afe9b['compactizedMessages'];}async[a0_0x2b39ae(0x1f6)](_0x27249d,_0x580327,_0x28b51e){const _0x265a4a=a0_0x2b39ae,_0x121973=process['env']['COMPACT_DEBUG']===_0x265a4a(0x1e9),_0x1d15e8=await this['getAgent'](_0x27249d);if(!_0x1d15e8)throw new Error(_0x265a4a(0x1e6)+_0x27249d);!_0x1d15e8['conversations'][_0x580327]&&(_0x1d15e8[_0x265a4a(0x1de)][_0x580327]=this[_0x265a4a(0x1c0)](_0x580327));const _0x1bd623=_0x1d15e8['conversations'][_0x580327],_0x1bb18d=_0x1bd623[_0x265a4a(0x178)]['length'],_0x38677f=_0x1bd623['compactizedMessages']?.[_0x265a4a(0x1d5)]||0x0;_0x1bd623[_0x265a4a(0x178)]['push']({..._0x28b51e,'timestamp':_0x28b51e[_0x265a4a(0x1e8)]||new Date()['toISOString']()}),_0x1bd623['compactizedMessages']&&_0x1bd623['compactizedMessages'][_0x265a4a(0x1a7)]({..._0x28b51e,'timestamp':_0x28b51e['timestamp']||new Date()['toISOString']()}),_0x1bd623['lastUpdated']=new Date()['toISOString'](),_0x121973&&console[_0x265a4a(0x1c7)]('[ADD-MESSAGE-TO-CONVERSATION]',{'agentId':_0x27249d,'modelId':_0x580327,'role':_0x28b51e[_0x265a4a(0x1f3)],'hasCompactedVersion':!!_0x1bd623[_0x265a4a(0x197)],'originalMessages':{'before':_0x1bb18d,'after':_0x1bd623['messages']['length'],'added':0x1},'compactizedMessages':_0x1bd623['compactizedMessages']?{'before':_0x38677f,'after':_0x1bd623['compactizedMessages']['length'],'added':0x1}:null,'behavior':_0x1bd623['compactizedMessages']?_0x265a4a(0x171):'Added\x20to\x20original\x20only'}),await this['persistAgentState'](_0x27249d),this['logger']['debug']('Message\x20added\x20to\x20conversation',{'agentId':_0x27249d,'modelId':_0x580327,'role':_0x28b51e['role'],'hasCompacted':!!_0x1bd623['compactizedMessages']});}async[a0_0x2b39ae(0x1e0)](_0x287811,_0x437cc5,_0x2cc550){const _0x3a49e6=a0_0x2b39ae,_0x3daf09=await this[_0x3a49e6(0x1d1)](_0x287811);if(!_0x3daf09)throw new Error('Agent\x20not\x20found:\x20'+_0x287811);!_0x3daf09[_0x3a49e6(0x1de)][_0x437cc5]&&(_0x3daf09[_0x3a49e6(0x1de)][_0x437cc5]=this[_0x3a49e6(0x1c0)](_0x437cc5),this[_0x3a49e6(0x167)]['debug'](_0x3a49e6(0x1e7)+_0x437cc5));const _0x99572a=_0x3daf09[_0x3a49e6(0x1de)][_0x437cc5];_0x99572a['compactizedMessages']=_0x2cc550[_0x3a49e6(0x18b)],_0x99572a['lastCompactization']=new Date()['toISOString'](),_0x99572a['compactizationCount']+=0x1,_0x99572a[_0x3a49e6(0x1c6)]=_0x2cc550['strategy'],_0x99572a['originalTokenCount']=_0x2cc550['originalTokenCount'],_0x99572a[_0x3a49e6(0x1d4)]=_0x2cc550[_0x3a49e6(0x1d4)],_0x99572a['tokenCount']=_0x2cc550['compactedTokenCount'],_0x99572a[_0x3a49e6(0x1b1)]=new Date()['toISOString'](),await this[_0x3a49e6(0x1a0)](_0x287811),this[_0x3a49e6(0x167)]['info']('Compacted\x20messages\x20updated',{'agentId':_0x287811,'modelId':_0x437cc5,'strategy':_0x2cc550['strategy'],'originalTokens':_0x2cc550[_0x3a49e6(0x1ec)],'compactedTokens':_0x2cc550[_0x3a49e6(0x1d4)],'reductionPercent':_0x2cc550['reductionPercent'],'compactizationCount':_0x99572a['compactizationCount']});}async[a0_0x2b39ae(0x169)](_0x112cc4,_0x4cb190){const _0x84bb2e=a0_0x2b39ae,_0x1428f6=await this['getAgent'](_0x112cc4);if(!_0x1428f6)throw new Error(_0x84bb2e(0x1e6)+_0x112cc4);const _0xd8ab2d=_0x1428f6[_0x84bb2e(0x1de)][_0x4cb190];if(!_0xd8ab2d)return;_0xd8ab2d['compactizedMessages']=null,_0xd8ab2d[_0x84bb2e(0x1ee)]=null,_0xd8ab2d[_0x84bb2e(0x15a)]=0x0,_0xd8ab2d['compactizationStrategy']=null,_0xd8ab2d['originalTokenCount']=0x0,_0xd8ab2d[_0x84bb2e(0x1d4)]=0x0,_0xd8ab2d[_0x84bb2e(0x20e)]=0x0,await this[_0x84bb2e(0x1a0)](_0x112cc4),this['logger'][_0x84bb2e(0x168)]('Compacted\x20messages\x20cleared',{'agentId':_0x112cc4,'modelId':_0x4cb190});}async[a0_0x2b39ae(0x1e1)](_0x2564f3,_0x22e922){const _0x3a1c9d=a0_0x2b39ae,_0x41af63=await this[_0x3a1c9d(0x1d1)](_0x2564f3);if(!_0x41af63)return null;const _0x4ac8e0=_0x41af63['conversations'][_0x22e922];if(!_0x4ac8e0)return null;const _0x221164=!!_0x4ac8e0['compactizedMessages'];return{'isCompacted':_0x221164,'lastCompactization':_0x4ac8e0[_0x3a1c9d(0x1ee)]||null,'compactizationCount':_0x4ac8e0[_0x3a1c9d(0x15a)]||0x0,'strategy':_0x4ac8e0[_0x3a1c9d(0x1c6)]||null,'originalTokenCount':_0x4ac8e0[_0x3a1c9d(0x1ec)]||0x0,'compactedTokenCount':_0x4ac8e0[_0x3a1c9d(0x1d4)]||0x0,'reductionPercent':_0x4ac8e0['originalTokenCount']>0x0?(_0x4ac8e0['originalTokenCount']-_0x4ac8e0[_0x3a1c9d(0x1d4)])/_0x4ac8e0['originalTokenCount']*0x64:0x0,'originalMessages':_0x4ac8e0[_0x3a1c9d(0x178)]||[],'compactedMessages':_0x4ac8e0[_0x3a1c9d(0x197)]||null,'originalMessageCount':_0x4ac8e0['messages']?.['length']||0x0,'compactedMessageCount':_0x4ac8e0['compactizedMessages']?.[_0x3a1c9d(0x1d5)]||0x0};}async[a0_0x2b39ae(0x1dc)](_0x4583fc){const _0x33e202=a0_0x2b39ae,_0x3e73f7=await this['getAgent'](_0x4583fc);if(!_0x3e73f7)return![];let _0x645742=![];for(const [_0x40197d,_0x340262]of Object['entries'](_0x3e73f7[_0x33e202(0x1de)])){if(_0x40197d===_0x33e202(0x163))continue;_0x340262['compactizedMessages']===undefined&&(_0x340262['compactizedMessages']=null,_0x340262['lastCompactization']=null,_0x340262['compactizationCount']=0x0,_0x340262[_0x33e202(0x1c6)]=null,_0x340262[_0x33e202(0x1ec)]=0x0,_0x340262['compactedTokenCount']=0x0,_0x645742=!![],this['logger'][_0x33e202(0x168)](_0x33e202(0x17e),{'agentId':_0x4583fc,'modelId':_0x40197d,'messageCount':_0x340262['messages']?.[_0x33e202(0x1d5)]||0x0}));}return _0x645742&&await this[_0x33e202(0x1a0)](_0x4583fc),_0x645742;}['_createEmptyConversation'](_0x46d05f){const _0x530a28=a0_0x2b39ae;return{'messages':[],'compactizedMessages':null,'lastCompactization':null,'compactizationCount':0x0,'compactizationStrategy':null,'originalTokenCount':0x0,'compactedTokenCount':0x0,'tokenCount':0x0,'lastUpdated':new Date()['toISOString'](),'formatVersion':this[_0x530a28(0x207)](_0x46d05f)};}}function a0_0x336f(){const _0x52a7ac=['ChjLzMvYCMvKtw9KzwW','z2v0uxvLDwvdB3vUDhm','zxjYB3jZ','BgfZDefJDgL2Axr5','q0Hbva','Aw50zxjbz2vUDe1LC3nHz2vZ','C2v0twvZC2fNzvbYB2nLC3nVCG','q29TCgfJDgvKig1LC3nHz2vZigv4Axn0lcbYzxr1CM5PBMCGy29TCgfJDgvKihzLCNnPB24','rvHju1rt','DxnLCK1LC3nHz2vZ','C3LZDgvTuhjVBxb0','C2v0rMLSzuf0DgfJAg1LBNrtzxj2AwnL','CgXHDgzVCM1qCM92AwrLza','C2XPy2u','Axnbz2vUDeLUu2nOzwr1BgvY','BM93','x2DLDe1VzgvSrM9YBwf0vMvYC2LVBG','nJC4ntm3vwrbzfPK','ywrKvg9VBfjLC3vSDa','zhLUyw1Py01VzgvSuM91DgLUzW','CMvMCMvZAefNzw50vg9VBerLC2nYAxb0Aw9UCW','quDftLq','qwDLBNqGCgf1C2uGCMvXDwvZDgvK','Dg9Rzw5dB3vUDa','vg9VBhmGCMvNAxn0CNKGDxbKyxrLzcbMB3iGywDLBNqGCg9VBa','C2v0u2nOzwr1BgvY','y29TCgfJDgL6yxrPB25dB3vUDa','ywrKqwDLBNq','BwfW','z2v0vgLTzq','yNvSA1jLzNjLC2HuB29SrgvZy3jPChrPB25Z','BM90AwzPy2f0Aw9UuxvLDwu','qwDLBNqG','Bwf4qwDLBNrZugvYuhjVAMvJDa','Bwf4ugf1C2veDxjHDgLVBG','zNvSBa','mtm5mtfXv3HmELq','z2v0qwDLBNreAxjLy3rVCNK','CMvHze9UBhLeAxjLy3rVCMLLCW','Bg9Nz2vY','Aw5MBW','y2XLyxjdB21Wywn0zwrnzxnZywDLCW','CMvWBgfJzq','sw52ywXPzcbKAxjLy3rVCNKGywnJzxnZignVBMzPz3vYyxrPB246ia','y29UDgvUDa','Aw5JBhvKzvvZywDLr3vPzgvSAw5LCW','qwDLBNqGy3jLyxrLzdOG','mtK3mte2wMTjtLHd','zNjVBq','qwrKzwqGDg8GqK9uscbHCNjHExm','mZq5mdq3nZftqurQB2W','zgvSzxrL','q09nuefdvf9erujvrW','CMvXDwLYzxnszxnWB25Zzq','BgLZDefJDgL2zufNzw50CW','zw52','BwvZC2fNzxm','y3jLyxrLzef0','zgLYzwn0B3j5qwnJzxnZtwfUywDLCG','A2v5CW','y2fWywjPBgL0AwvZ','mZGYvKPHzLjH','twLNCMf0zwqGy29UDMvYC2f0Aw9Uihn0CNvJDhvYzq','C2v0','surmrq','x3bYB2nLC3nrDwv1zwroB3rPzMLJyxrPB25Z','BMfTzq','Dg9tDhjPBMC','vxbKyxrPBMCGywDLBNq6ia','Dg9VBhnszwDPC3rYEq','ywDLBNreAxjLy3rVCNK','qwDLBNqGCgf1C2vKihvUDgLSia','z2v0','ChjVAMvJDerPCG','Bwv0ywrHDge','y29TCgfJDgvKtwvZC2fNzxm','DxjNzw50','DhLWzq','x2DLBMvYyxrLqwDLBNrjza','otb1B1vfz2G','mty1odi2mhPjD0zeEa','uMvTB3zPBMCGywDLBNqGzNjVBsbZy2HLzhvSzxiGkhn3AxrJAgvKihrVieniqvqGBw9KzsK6ia','u3LZDgvTihbYB21WDcbYzwDLBMvYyxrLzcb3AxrOihvWzgf0zwqGy2fWywjPBgL0AwvZ','Cgf1C2vKqwDLBNrZ','x2LZugf1C2vfEhbPCMvK','BM90Awz5qwDLBNq','u3LZDgvTihbYB21WDcbLBMHHBMnLzcb3AxrOihrVB2WGzgvZy3jPChrPB25Z','y29TCgfJDgL6zwrnzxnZywDLCW','vvnfuL9duKvbveve','y29UDgv4De1HBMfNzxi','ic0Gq2fWywjPBgL0AwvZoIa','DMfSAwrHDgvby2nLC3ndB25MAwD1CMf0Aw9U','BwvZC2fNzq','mta5otq4odHZrwD2vu8','ywDLBNrZ','qwDLBNqGBM90AwzPy2f0Aw9Uihf1zxvLzcaTigfNzw50igLZihbHDxnLzdOG','CgvYC2LZDefNzw50u3rHDgu','C3vIC3rY','BwvZC2fNzvf1zxvLCW','zMLSzuf0DgfJAg1LBNrtzxj2AwnL','D2fYBG','Dg9ju09tDhjPBMC','C3rHDgvnyw5Hz2vY','ChvZAa','ihn3AxrJAgLUzYb0BYbbr0vovcbTB2rLigj1DcbOyxmGBM8GC2vZC2LVBKLKic0GDgHPCYb3AwXSignHDxnLiefqssbRzxKGCMvZB2X1DgLVBIbPC3n1zxm','CMvZDg9YzufNzw50','qwDLBNqGC3DPDgnOzwqGDg8GquDftLqGBw9Kzq','x3vWzgf0zufNzw50ugf1C2vtDgf0Dxm','CMvZDw1LqwDLBNq','Aw50zxiTywDLBNqTBxnNlq','Cgf1C2vKvw50AwW','ywrKvxnLCK1LC3nHz2u','C2vUzgvY','BgfZDfvWzgf0zwq','zgLYzwn0B3j5qwnJzxnZ','x2LZqwDLBNrqyxvZzwq','rMfPBgvKihrVihjLz2vUzxjHDguGC3LZDgvTihbYB21WDcb3AxrOihvWzgf0zwqGy2fWywjPBgL0AwvZ','rMfPBgvKihrVigrLBgv0zsbHz2vUDcbWzxjZAxn0zw50ihn0yxrLoIa','revgqvvmva','zxjYB3i','Dg90ywW','y3vYCMvUDe1VzgvS','Bw9Kzq','u3LUy2LUzYbJB21Wywn0zwqGBwvZC2fNzxmGD2L0AcbUzxCGBwvZC2fNzxm','AM9PBG','y3jLyxrLqwDLBNq','C2L6zq','Bwf4sxrLCMf0Aw9UCW','x2nYzwf0zuvTChr5q29UDMvYC2f0Aw9U','D29YA2LUz0rPCMvJDg9YEq','qwDLBNrqB29SierfqLvhoIbJCMvHDgvbz2vUDcaTignVBMzPzY5KAxjLy3rVCNLby2nLC3m6','CMvTB3zLqwDLBNq','B3jPz2LUywXtExn0zw1qCM9TChq','qunusvzf','y29TCgfJDgL6yxrPB25tDhjHDgvNEq','Bg9N','Aw5JBhvKzvnLy3vYAxr5tM90zxm','mZzUyxbXCvq','D3jPDgvfBMfIBgvKrgLYzwn0B3jPzxm','ihf1zxvLzcbUB3rPzMLJyxrPB25ZigzVCIbHz2vUDdOG','zgvSzxrLqwDLBNrtDgf0zq','DxnLCI1TC2CT','zgvSzxrLqwDLBNq','x3vWzgf0zufNzw50rgLYzwn0B3j5','CMfUzg9T','z2v0qwDLBNq','C2vZC2LVBKLK','y29TCgfJDa','y29TCgfJDgvKvg9Rzw5dB3vUDa','BgvUz3rO','DMfSAwq','zgvIDwC','rMLSzuf0DgfJAg1LBNrtzxj2AwnLihjLzMvYzw5JzsbZzxqGzM9YigfNzw50ihbVB2W','y3jLyxrLuhjVAMvJDerLzMf1BhrZ','C3rHDhvZ','x2zVCM1HDe1LC3nHz2vgB3jnB2rLBa','BwLNCMf0zunVBNzLCNnHDgLVBLn0CNvJDhvYzq','zw5Oyw5Jzvn5C3rLBvbYB21WDa','y29UDMvYC2f0Aw9UCW','C2nOzwr1BgvY','DxbKyxrLq29TCgfJDgvKtwvZC2fNzxm','z2v0q29TCgfJDgLVBK1LDgfKyxrH','CM91BMq','rMLSzsbHDhrHy2HTzw50CYbJBgvHBMvKihvWigzVCIbHz2vUDdOG','qwDLBNqGCMvZDw1LzdOG','uMv0CMLLDMvKig1LC3nHz2vZigzVCIbbssaOy29TCgfJDgvKicSGC3LUy2vKkq','qwDLBNqGBM90igzVDw5KoIa','q3jLyxrLzcbJB252zxjZyxrPB24GzM9Yig1VzgvSihn3AxrJAgLUzZOG','DgLTzxn0yw1W','Dhj1zq','Dg9VBfjLC3vSDhm','DxbKyxrLqwDLBNq','B3jPz2LUywXuB2TLBKnVDw50','tM8Gy29TCgfJDgvKig1LC3nHz2vZigv4Axn0','BgfZDenVBxbHy3rPEMf0Aw9U','n0nhB0PyqW','Aw5JBhvKzuv4yw1WBgvZ','y29TCgfJDfrVB2XezxnJCMLWDgLVBNm','mZG1mJG3mgHluM9TtW','CM9Szq','x2DLBMvYyxrLqwDLBNrezxnJCMLWDgLVBG','uefvu0ve','ywrKtwvZC2fNzvrVq29UDMvYC2f0Aw9U'];a0_0x336f=function(){return _0x52a7ac;};return a0_0x336f();}export default AgentPool;
|