@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/types/agent.js
CHANGED
|
@@ -1,519 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent Data Model - Type definitions and validation for AI agents
|
|
3
|
-
*
|
|
4
|
-
* Purpose:
|
|
5
|
-
* - Define the structure and properties of AI agents
|
|
6
|
-
* - Provide validation functions for agent data
|
|
7
|
-
* - Ensure data integrity and consistency
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { AGENT_STATUS, AGENT_TYPES, MODELS } from '../utilities/constants.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Agent data model
|
|
14
|
-
* @typedef {Object} Agent
|
|
15
|
-
* @property {string} id - Unique agent identifier
|
|
16
|
-
* @property {string} name - Human-readable agent name
|
|
17
|
-
* @property {string} type - Agent type (user-created, system-agent, agent-engineer)
|
|
18
|
-
* @property {string} status - Current agent status (active, idle, busy, suspended, paused)
|
|
19
|
-
* @property {string} currentModel - AI model being used
|
|
20
|
-
* @property {string} systemPrompt - System prompt defining agent behavior
|
|
21
|
-
* @property {AgentConfiguration} configuration - Agent configuration settings
|
|
22
|
-
* @property {AgentMetrics} metrics - Performance and usage metrics
|
|
23
|
-
* @property {AgentState} state - Current agent state information
|
|
24
|
-
* @property {string} createdAt - ISO timestamp of creation
|
|
25
|
-
* @property {string} updatedAt - ISO timestamp of last update
|
|
26
|
-
* @property {string} lastActivity - ISO timestamp of last activity
|
|
27
|
-
* @property {string|null} pausedUntil - ISO timestamp when pause expires (null if not paused)
|
|
28
|
-
* @property {string|null} pauseReason - Reason for current pause (null if not paused)
|
|
29
|
-
* @property {Object} metadata - Additional metadata and tags
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Agent configuration settings
|
|
34
|
-
* @typedef {Object} AgentConfiguration
|
|
35
|
-
* @property {number} maxContextLength - Maximum context length in tokens
|
|
36
|
-
* @property {number} temperature - Sampling temperature (0.0-1.0)
|
|
37
|
-
* @property {number} maxTokens - Maximum tokens per response
|
|
38
|
-
* @property {number} timeout - Request timeout in milliseconds
|
|
39
|
-
* @property {boolean} persistConversations - Whether to persist conversation history
|
|
40
|
-
* @property {string[]} enabledTools - List of enabled tool names
|
|
41
|
-
* @property {Object} toolConfigurations - Tool-specific configurations
|
|
42
|
-
* @property {boolean} autoRetry - Whether to automatically retry failed requests
|
|
43
|
-
* @property {number} maxRetries - Maximum number of retry attempts
|
|
44
|
-
* @property {Object} customSettings - Custom configuration properties
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Agent performance and usage metrics
|
|
49
|
-
* @typedef {Object} AgentMetrics
|
|
50
|
-
* @property {number} totalMessages - Total messages processed
|
|
51
|
-
* @property {number} totalTokensUsed - Total tokens consumed
|
|
52
|
-
* @property {number} totalCost - Total cost incurred (USD)
|
|
53
|
-
* @property {number} averageResponseTime - Average response time in milliseconds
|
|
54
|
-
* @property {number} successRate - Success rate (0.0-1.0)
|
|
55
|
-
* @property {number} errorCount - Total number of errors
|
|
56
|
-
* @property {number} toolExecutions - Number of tool executions
|
|
57
|
-
* @property {number} conversationsStarted - Number of conversations initiated
|
|
58
|
-
* @property {Object} dailyUsage - Daily usage statistics
|
|
59
|
-
* @property {Object} weeklyUsage - Weekly usage statistics
|
|
60
|
-
* @property {Object} monthlyUsage - Monthly usage statistics
|
|
61
|
-
* @property {string} lastMetricsUpdate - ISO timestamp of last metrics update
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Agent state information
|
|
66
|
-
* @typedef {Object} AgentState
|
|
67
|
-
* @property {string} currentConversationId - ID of current active conversation
|
|
68
|
-
* @property {number} messageCount - Number of messages in current conversation
|
|
69
|
-
* @property {Object} context - Current conversation context
|
|
70
|
-
* @property {string[]} activeTools - Currently executing tools
|
|
71
|
-
* @property {Object} pendingOperations - Pending asynchronous operations
|
|
72
|
-
* @property {Object} cache - Cached data and responses
|
|
73
|
-
* @property {boolean} isProcessing - Whether agent is currently processing
|
|
74
|
-
* @property {string|null} lastError - Last error encountered (null if none)
|
|
75
|
-
* @property {Object} sessionData - Session-specific data
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Agent creation parameters
|
|
80
|
-
* @typedef {Object} AgentCreationParams
|
|
81
|
-
* @property {string} name - Agent name (required)
|
|
82
|
-
* @property {string} [type=user-created] - Agent type
|
|
83
|
-
* @property {string} [model=anthropic-sonnet] - AI model to use
|
|
84
|
-
* @property {string} [systemPrompt=''] - System prompt
|
|
85
|
-
* @property {Partial<AgentConfiguration>} [configuration] - Initial configuration
|
|
86
|
-
* @property {Object} [metadata] - Initial metadata
|
|
87
|
-
* @property {string[]} [enabledTools] - Initial enabled tools
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Agent update parameters
|
|
92
|
-
* @typedef {Object} AgentUpdateParams
|
|
93
|
-
* @property {string} [name] - New agent name
|
|
94
|
-
* @property {string} [systemPrompt] - New system prompt
|
|
95
|
-
* @property {string} [currentModel] - New AI model
|
|
96
|
-
* @property {Partial<AgentConfiguration>} [configuration] - Configuration updates
|
|
97
|
-
* @property {Object} [metadata] - Metadata updates
|
|
98
|
-
* @property {string[]} [enabledTools] - Updated enabled tools list
|
|
99
|
-
*/
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Agent validation functions
|
|
103
|
-
*/
|
|
104
|
-
export class AgentValidator {
|
|
105
|
-
/**
|
|
106
|
-
* Validate agent data structure
|
|
107
|
-
* @param {Object} agent - Agent data to validate
|
|
108
|
-
* @returns {Object} Validation result
|
|
109
|
-
*/
|
|
110
|
-
static validate(agent) {
|
|
111
|
-
const errors = [];
|
|
112
|
-
const warnings = [];
|
|
113
|
-
|
|
114
|
-
// Required fields
|
|
115
|
-
if (!agent.id || typeof agent.id !== 'string') {
|
|
116
|
-
errors.push('Agent ID is required and must be a string');
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (!agent.name || typeof agent.name !== 'string') {
|
|
120
|
-
errors.push('Agent name is required and must be a string');
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (agent.name && agent.name.length < 2) {
|
|
124
|
-
errors.push('Agent name must be at least 2 characters long');
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (agent.name && agent.name.length > 100) {
|
|
128
|
-
errors.push('Agent name must be less than 100 characters');
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Type validation
|
|
132
|
-
if (agent.type && !Object.values(AGENT_TYPES).includes(agent.type)) {
|
|
133
|
-
errors.push(`Invalid agent type: ${agent.type}`);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Status validation
|
|
137
|
-
if (agent.status && !Object.values(AGENT_STATUS).includes(agent.status)) {
|
|
138
|
-
errors.push(`Invalid agent status: ${agent.status}`);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Model validation
|
|
142
|
-
if (agent.currentModel && !Object.values(MODELS).includes(agent.currentModel)) {
|
|
143
|
-
warnings.push(`Unknown AI model: ${agent.currentModel}`);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// System prompt validation
|
|
147
|
-
if (agent.systemPrompt && typeof agent.systemPrompt !== 'string') {
|
|
148
|
-
errors.push('System prompt must be a string');
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (agent.systemPrompt && agent.systemPrompt.length > 10000) {
|
|
152
|
-
warnings.push('System prompt is very long (>10000 characters)');
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// Configuration validation
|
|
156
|
-
if (agent.configuration) {
|
|
157
|
-
const configValidation = this.validateConfiguration(agent.configuration);
|
|
158
|
-
errors.push(...configValidation.errors);
|
|
159
|
-
warnings.push(...configValidation.warnings);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Timestamp validation
|
|
163
|
-
const timestampFields = ['createdAt', 'updatedAt', 'lastActivity', 'pausedUntil'];
|
|
164
|
-
timestampFields.forEach(field => {
|
|
165
|
-
if (agent[field] && !this.isValidTimestamp(agent[field])) {
|
|
166
|
-
errors.push(`Invalid timestamp for ${field}: ${agent[field]}`);
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
return {
|
|
171
|
-
isValid: errors.length === 0,
|
|
172
|
-
errors,
|
|
173
|
-
warnings
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Validate agent configuration
|
|
179
|
-
* @param {Object} configuration - Configuration to validate
|
|
180
|
-
* @returns {Object} Validation result
|
|
181
|
-
*/
|
|
182
|
-
static validateConfiguration(configuration) {
|
|
183
|
-
const errors = [];
|
|
184
|
-
const warnings = [];
|
|
185
|
-
|
|
186
|
-
if (configuration.maxContextLength && typeof configuration.maxContextLength !== 'number') {
|
|
187
|
-
errors.push('maxContextLength must be a number');
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (configuration.maxContextLength && configuration.maxContextLength < 1000) {
|
|
191
|
-
warnings.push('maxContextLength is very low (<1000)');
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (configuration.temperature !== undefined) {
|
|
195
|
-
if (typeof configuration.temperature !== 'number') {
|
|
196
|
-
errors.push('temperature must be a number');
|
|
197
|
-
} else if (configuration.temperature < 0 || configuration.temperature > 2) {
|
|
198
|
-
errors.push('temperature must be between 0 and 2');
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (configuration.maxTokens && typeof configuration.maxTokens !== 'number') {
|
|
203
|
-
errors.push('maxTokens must be a number');
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (configuration.timeout && typeof configuration.timeout !== 'number') {
|
|
207
|
-
errors.push('timeout must be a number');
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (configuration.timeout && configuration.timeout < 1000) {
|
|
211
|
-
warnings.push('timeout is very low (<1000ms)');
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
if (configuration.maxRetries && typeof configuration.maxRetries !== 'number') {
|
|
215
|
-
errors.push('maxRetries must be a number');
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (configuration.enabledTools && !Array.isArray(configuration.enabledTools)) {
|
|
219
|
-
errors.push('enabledTools must be an array');
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return { errors, warnings };
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Validate agent creation parameters
|
|
227
|
-
* @param {Object} params - Creation parameters to validate
|
|
228
|
-
* @returns {Object} Validation result
|
|
229
|
-
*/
|
|
230
|
-
static validateCreationParams(params) {
|
|
231
|
-
const errors = [];
|
|
232
|
-
const warnings = [];
|
|
233
|
-
|
|
234
|
-
if (!params.name || typeof params.name !== 'string') {
|
|
235
|
-
errors.push('Agent name is required and must be a string');
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
if (params.name && params.name.length < 2) {
|
|
239
|
-
errors.push('Agent name must be at least 2 characters long');
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if (params.type && !Object.values(AGENT_TYPES).includes(params.type)) {
|
|
243
|
-
errors.push(`Invalid agent type: ${params.type}`);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (params.model && !Object.values(MODELS).includes(params.model)) {
|
|
247
|
-
warnings.push(`Unknown AI model: ${params.model}`);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (params.systemPrompt && typeof params.systemPrompt !== 'string') {
|
|
251
|
-
errors.push('System prompt must be a string');
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (params.enabledTools && !Array.isArray(params.enabledTools)) {
|
|
255
|
-
errors.push('enabledTools must be an array');
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
return {
|
|
259
|
-
isValid: errors.length === 0,
|
|
260
|
-
errors,
|
|
261
|
-
warnings
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Check if a timestamp is valid ISO string
|
|
267
|
-
* @param {string} timestamp - Timestamp to validate
|
|
268
|
-
* @returns {boolean} True if valid
|
|
269
|
-
*/
|
|
270
|
-
static isValidTimestamp(timestamp) {
|
|
271
|
-
if (typeof timestamp !== 'string') return false;
|
|
272
|
-
const date = new Date(timestamp);
|
|
273
|
-
return date instanceof Date && !isNaN(date.getTime());
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Agent factory functions
|
|
279
|
-
*/
|
|
280
|
-
export class AgentFactory {
|
|
281
|
-
/**
|
|
282
|
-
* Create a new agent with default values
|
|
283
|
-
* @param {AgentCreationParams} params - Creation parameters
|
|
284
|
-
* @returns {Agent} New agent object
|
|
285
|
-
*/
|
|
286
|
-
static create(params) {
|
|
287
|
-
// Validate parameters
|
|
288
|
-
const validation = AgentValidator.validateCreationParams(params);
|
|
289
|
-
if (!validation.isValid) {
|
|
290
|
-
throw new Error(`Invalid agent parameters: ${validation.errors.join(', ')}`);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
const now = new Date().toISOString();
|
|
294
|
-
const agentId = this.generateAgentId();
|
|
295
|
-
|
|
296
|
-
return {
|
|
297
|
-
id: agentId,
|
|
298
|
-
name: params.name,
|
|
299
|
-
type: params.type || AGENT_TYPES.USER_CREATED,
|
|
300
|
-
status: AGENT_STATUS.IDLE,
|
|
301
|
-
currentModel: params.model || MODELS.ANTHROPIC_SONNET,
|
|
302
|
-
systemPrompt: params.systemPrompt || '',
|
|
303
|
-
configuration: this.createDefaultConfiguration(params.configuration),
|
|
304
|
-
metrics: this.createDefaultMetrics(),
|
|
305
|
-
state: this.createDefaultState(),
|
|
306
|
-
createdAt: now,
|
|
307
|
-
updatedAt: now,
|
|
308
|
-
lastActivity: now,
|
|
309
|
-
pausedUntil: null,
|
|
310
|
-
pauseReason: null,
|
|
311
|
-
metadata: params.metadata || {}
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* Create default agent configuration
|
|
317
|
-
* @param {Partial<AgentConfiguration>} overrides - Configuration overrides
|
|
318
|
-
* @returns {AgentConfiguration} Default configuration
|
|
319
|
-
*/
|
|
320
|
-
static createDefaultConfiguration(overrides = {}) {
|
|
321
|
-
return {
|
|
322
|
-
maxContextLength: 50000,
|
|
323
|
-
temperature: 0.7,
|
|
324
|
-
maxTokens: 4096,
|
|
325
|
-
timeout: 30000,
|
|
326
|
-
persistConversations: true,
|
|
327
|
-
enabledTools: ['terminal', 'filesys', 'editor'],
|
|
328
|
-
toolConfigurations: {},
|
|
329
|
-
autoRetry: true,
|
|
330
|
-
maxRetries: 3,
|
|
331
|
-
customSettings: {},
|
|
332
|
-
...overrides
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Create default agent metrics
|
|
338
|
-
* @returns {AgentMetrics} Default metrics
|
|
339
|
-
*/
|
|
340
|
-
static createDefaultMetrics() {
|
|
341
|
-
const now = new Date().toISOString();
|
|
342
|
-
|
|
343
|
-
return {
|
|
344
|
-
totalMessages: 0,
|
|
345
|
-
totalTokensUsed: 0,
|
|
346
|
-
totalCost: 0,
|
|
347
|
-
averageResponseTime: 0,
|
|
348
|
-
successRate: 1.0,
|
|
349
|
-
errorCount: 0,
|
|
350
|
-
toolExecutions: 0,
|
|
351
|
-
conversationsStarted: 0,
|
|
352
|
-
dailyUsage: { tokens: 0, cost: 0, messages: 0 },
|
|
353
|
-
weeklyUsage: { tokens: 0, cost: 0, messages: 0 },
|
|
354
|
-
monthlyUsage: { tokens: 0, cost: 0, messages: 0 },
|
|
355
|
-
lastMetricsUpdate: now
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Create default agent state
|
|
361
|
-
* @returns {AgentState} Default state
|
|
362
|
-
*/
|
|
363
|
-
static createDefaultState() {
|
|
364
|
-
return {
|
|
365
|
-
currentConversationId: null,
|
|
366
|
-
messageCount: 0,
|
|
367
|
-
context: {},
|
|
368
|
-
activeTools: [],
|
|
369
|
-
pendingOperations: {},
|
|
370
|
-
cache: {},
|
|
371
|
-
isProcessing: false,
|
|
372
|
-
lastError: null,
|
|
373
|
-
sessionData: {}
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Generate unique agent ID
|
|
379
|
-
* @returns {string} Unique agent ID
|
|
380
|
-
*/
|
|
381
|
-
static generateAgentId() {
|
|
382
|
-
const timestamp = Date.now().toString(36);
|
|
383
|
-
const random = Math.random().toString(36).substr(2, 9);
|
|
384
|
-
return `agent_${timestamp}_${random}`;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Clone an existing agent with new ID
|
|
389
|
-
* @param {Agent} agent - Agent to clone
|
|
390
|
-
* @param {string} newName - Name for cloned agent
|
|
391
|
-
* @returns {Agent} Cloned agent
|
|
392
|
-
*/
|
|
393
|
-
static clone(agent, newName) {
|
|
394
|
-
const cloned = { ...agent };
|
|
395
|
-
const now = new Date().toISOString();
|
|
396
|
-
|
|
397
|
-
cloned.id = this.generateAgentId();
|
|
398
|
-
cloned.name = newName;
|
|
399
|
-
cloned.status = AGENT_STATUS.IDLE;
|
|
400
|
-
cloned.createdAt = now;
|
|
401
|
-
cloned.updatedAt = now;
|
|
402
|
-
cloned.lastActivity = now;
|
|
403
|
-
cloned.pausedUntil = null;
|
|
404
|
-
cloned.pauseReason = null;
|
|
405
|
-
|
|
406
|
-
// Reset metrics and state
|
|
407
|
-
cloned.metrics = this.createDefaultMetrics();
|
|
408
|
-
cloned.state = this.createDefaultState();
|
|
409
|
-
|
|
410
|
-
return cloned;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Agent utility functions
|
|
416
|
-
*/
|
|
417
|
-
export class AgentUtils {
|
|
418
|
-
/**
|
|
419
|
-
* Check if agent is currently active
|
|
420
|
-
* @param {Agent} agent - Agent to check
|
|
421
|
-
* @returns {boolean} True if active
|
|
422
|
-
*/
|
|
423
|
-
static isActive(agent) {
|
|
424
|
-
return agent.status === AGENT_STATUS.ACTIVE || agent.status === AGENT_STATUS.BUSY;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* Check if agent is paused
|
|
429
|
-
* @param {Agent} agent - Agent to check
|
|
430
|
-
* @returns {boolean} True if paused
|
|
431
|
-
*/
|
|
432
|
-
static isPaused(agent) {
|
|
433
|
-
if (agent.status !== AGENT_STATUS.PAUSED) return false;
|
|
434
|
-
|
|
435
|
-
if (agent.pausedUntil) {
|
|
436
|
-
const pauseExpiry = new Date(agent.pausedUntil);
|
|
437
|
-
return new Date() < pauseExpiry;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
return true;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Get agent's effective status considering pause expiry
|
|
445
|
-
* @param {Agent} agent - Agent to check
|
|
446
|
-
* @returns {string} Effective status
|
|
447
|
-
*/
|
|
448
|
-
static getEffectiveStatus(agent) {
|
|
449
|
-
if (agent.status === AGENT_STATUS.PAUSED && agent.pausedUntil) {
|
|
450
|
-
const pauseExpiry = new Date(agent.pausedUntil);
|
|
451
|
-
if (new Date() >= pauseExpiry) {
|
|
452
|
-
return AGENT_STATUS.IDLE; // Pause has expired
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
return agent.status;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
/**
|
|
460
|
-
* Calculate time until pause expires
|
|
461
|
-
* @param {Agent} agent - Agent to check
|
|
462
|
-
* @returns {number|null} Milliseconds until pause expires, null if not paused
|
|
463
|
-
*/
|
|
464
|
-
static getTimeUntilPauseExpiry(agent) {
|
|
465
|
-
if (!this.isPaused(agent) || !agent.pausedUntil) {
|
|
466
|
-
return null;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
const pauseExpiry = new Date(agent.pausedUntil);
|
|
470
|
-
const now = new Date();
|
|
471
|
-
|
|
472
|
-
return Math.max(0, pauseExpiry.getTime() - now.getTime());
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* Format agent for display
|
|
477
|
-
* @param {Agent} agent - Agent to format
|
|
478
|
-
* @returns {Object} Formatted agent data
|
|
479
|
-
*/
|
|
480
|
-
static formatForDisplay(agent) {
|
|
481
|
-
return {
|
|
482
|
-
id: agent.id,
|
|
483
|
-
name: agent.name,
|
|
484
|
-
type: agent.type,
|
|
485
|
-
status: this.getEffectiveStatus(agent),
|
|
486
|
-
model: agent.currentModel,
|
|
487
|
-
messageCount: agent.metrics.totalMessages,
|
|
488
|
-
lastActivity: agent.lastActivity,
|
|
489
|
-
isPaused: this.isPaused(agent),
|
|
490
|
-
timeUntilPauseExpiry: this.getTimeUntilPauseExpiry(agent)
|
|
491
|
-
};
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* Sanitize agent data for API responses
|
|
496
|
-
* @param {Agent} agent - Agent to sanitize
|
|
497
|
-
* @returns {Object} Sanitized agent data
|
|
498
|
-
*/
|
|
499
|
-
static sanitize(agent) {
|
|
500
|
-
const sanitized = { ...agent };
|
|
501
|
-
|
|
502
|
-
// Remove sensitive or internal data
|
|
503
|
-
delete sanitized.state.cache;
|
|
504
|
-
delete sanitized.state.sessionData;
|
|
505
|
-
|
|
506
|
-
// Truncate long system prompt for API responses
|
|
507
|
-
if (sanitized.systemPrompt && sanitized.systemPrompt.length > 500) {
|
|
508
|
-
sanitized.systemPrompt = sanitized.systemPrompt.substring(0, 500) + '...';
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
return sanitized;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
export default {
|
|
516
|
-
AgentValidator,
|
|
517
|
-
AgentFactory,
|
|
518
|
-
AgentUtils
|
|
519
|
-
};
|
|
1
|
+
const a0_0x546181=a0_0x534f;(function(_0x1c7058,_0x18bade){const _0x4fd3b7=a0_0x534f,_0x194e1b=_0x1c7058();while(!![]){try{const _0x599cbd=-parseInt(_0x4fd3b7(0x1b2))/0x1+parseInt(_0x4fd3b7(0x1b1))/0x2*(-parseInt(_0x4fd3b7(0x1cd))/0x3)+parseInt(_0x4fd3b7(0x195))/0x4+parseInt(_0x4fd3b7(0x1c6))/0x5*(-parseInt(_0x4fd3b7(0x1be))/0x6)+-parseInt(_0x4fd3b7(0x1b0))/0x7+-parseInt(_0x4fd3b7(0x1b7))/0x8+-parseInt(_0x4fd3b7(0x1d9))/0x9*(-parseInt(_0x4fd3b7(0x1a2))/0xa);if(_0x599cbd===_0x18bade)break;else _0x194e1b['push'](_0x194e1b['shift']());}catch(_0x590db9){_0x194e1b['push'](_0x194e1b['shift']());}}}(a0_0x281b,0x24f04));import{AGENT_STATUS,AGENT_TYPES,MODELS}from'../utilities/constants.js';function a0_0x281b(){const _0x4f9f1c=['ChvZAa','DgLTzw91Da','Bwf4uMv0CMLLCYbTDxn0igjLigeGBNvTyMvY','C3rYAw5N','DMfSAwrHDgvdCMvHDgLVBLbHCMfTCW','mti2mteZngjuDvz4zG','ntK3ogrWrM5tqG','mtyYnJyWr1vRvNrd','zw5HyMXLzfrVB2XZ','BgvUz3rO','y3vYCMvUDe1VzgvS','DMfSAwrHDgvdB25MAwD1CMf0Aw9U','otK2odGWwNjPzgPi','DgvTCgvYyxr1CMuGBxvZDcbIzsbHig51BwjLCG','zM9YrwfJAa','Bwv0ywrHDge','Axnby3rPDMu','y3jLyxrL','BMfTzq','otC0ntjPA0rxuKK','qu5usfjpueLdx1nptK5fva','Bwf4q29UDgv4DeXLBMD0Aa','lI4U','Dg9ju09tDhjPBMC','Dg9tDhjPBMC','y3jLyxrLzef0','Bwf4uMv0CMLLCW','mtbfD2Txu0W','zwrPDg9Y','C3vIC3rY','C3rHDhvZ','surmrq','sw52ywXPzcbHz2vUDcb0ExbLoIa','DgvTCgvYyxr1CMu','m1HgCw9bra','u3LZDgvTihbYB21WDcbPCYb2zxj5igXVBMCGkd4XmdaWmcbJAgfYywn0zxjZkq','sw52ywXPzcbHz2vUDcbWyxjHBwv0zxjZoIa','y3jLyxrLrgvMyxvSDfn0yxrL','C3LZDgvTuhjVBxb0','C2fUAxrPEMu','Cgf1C2vKvw50AwW','y29UzMLNDxjHDgLVBG','DMfSDwvZ','zxjYB3jZ','DgLTzw91DcbPCYb2zxj5igXVDYaOpdeWmdbTCYK','BNvTyMvY','mZaXnuv3qwPxqW','sw52ywXPzcbHz2vUDcbZDgf0Dxm6ia','Bwv0CMLJCW','u3LZDgvTihbYB21WDcbTDxn0igjLigeGC3rYAw5N','Bwf4q29UDgv4DeXLBMD0AcbPCYb2zxj5igXVDYaOpdeWmdaP','Bw9KzwW','Dg90ywXnzxnZywDLCW','AxnwywXPzfrPBwvZDgfTCa','qLvtwq','y3jLyxrLrgvMyxvSDenVBMzPz3vYyxrPB24','BgfZDefJDgL2Axr5','C3rHDgu','ntKZndiWAeLcvMzS','uefvu0ve','sw52ywXPzcb0Aw1LC3rHBxaGzM9Yia','vw5RBM93BIbbssbTB2rLBdOG','z2vUzxjHDgvbz2vUDeLK','zMLSzxn5CW','D2fYBMLUz3m','y3jLyxrLrgvMyxvSDe1LDhjPy3m','z2v0rwzMzwn0AxzLu3rHDhvZ','z2v0vgLTzvvUDgLSugf1C2vfEhbPCNK','zM9YBwf0rM9YrgLZCgXHEq','CMfUzg9T','BM93','mtuXmdblsNbnAxK','DhLWzq','z2v0vgLTzq','Bwf4','vvnfuL9duKvbveve','Aw5JBhvKzxm','AxnbCNjHEq','AxnqyxvZzwq','qwDLBNqGsuqGAxmGCMvXDwLYzwqGyw5Kig11C3qGyMuGysbZDhjPBMC'];a0_0x281b=function(){return _0x4f9f1c;};return a0_0x281b();}function a0_0x534f(_0x5726ff,_0x550aed){_0x5726ff=_0x5726ff-0x18a;const _0x281b3f=a0_0x281b();let _0x534f7f=_0x281b3f[_0x5726ff];if(a0_0x534f['SvGIkg']===undefined){var _0x476178=function(_0x4cb07e){const _0x3ba245='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x147090='',_0x1f66b2='';for(let _0x2c7769=0x0,_0x22e982,_0x1b1181,_0x4af6ae=0x0;_0x1b1181=_0x4cb07e['charAt'](_0x4af6ae++);~_0x1b1181&&(_0x22e982=_0x2c7769%0x4?_0x22e982*0x40+_0x1b1181:_0x1b1181,_0x2c7769++%0x4)?_0x147090+=String['fromCharCode'](0xff&_0x22e982>>(-0x2*_0x2c7769&0x6)):0x0){_0x1b1181=_0x3ba245['indexOf'](_0x1b1181);}for(let _0x3d244e=0x0,_0x26ab77=_0x147090['length'];_0x3d244e<_0x26ab77;_0x3d244e++){_0x1f66b2+='%'+('00'+_0x147090['charCodeAt'](_0x3d244e)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x1f66b2);};a0_0x534f['tMvahP']=_0x476178,a0_0x534f['SdWiLo']={},a0_0x534f['SvGIkg']=!![];}const _0x463dd3=_0x281b3f[0x0],_0x13ed59=_0x5726ff+_0x463dd3,_0x5a5d6c=a0_0x534f['SdWiLo'][_0x13ed59];return!_0x5a5d6c?(_0x534f7f=a0_0x534f['tMvahP'](_0x534f7f),a0_0x534f['SdWiLo'][_0x13ed59]=_0x534f7f):_0x534f7f=_0x5a5d6c,_0x534f7f;}export class AgentValidator{static['validate'](_0x147090){const _0x54e433=a0_0x534f,_0x1f66b2=[],_0x2c7769=[];(!_0x147090['id']||typeof _0x147090['id']!==_0x54e433(0x1ae))&&_0x1f66b2['push'](_0x54e433(0x1aa));(!_0x147090[_0x54e433(0x1bd)]||typeof _0x147090[_0x54e433(0x1bd)]!==_0x54e433(0x1ae))&&_0x1f66b2['push']('Agent\x20name\x20is\x20required\x20and\x20must\x20be\x20a\x20string');_0x147090[_0x54e433(0x1bd)]&&_0x147090['name']['length']<0x2&&_0x1f66b2[_0x54e433(0x1ab)]('Agent\x20name\x20must\x20be\x20at\x20least\x202\x20characters\x20long');_0x147090['name']&&_0x147090['name'][_0x54e433(0x1b4)]>0x64&&_0x1f66b2[_0x54e433(0x1ab)]('Agent\x20name\x20must\x20be\x20less\x20than\x20100\x20characters');_0x147090[_0x54e433(0x1a3)]&&!Object['values'](AGENT_TYPES)[_0x54e433(0x1a7)](_0x147090['type'])&&_0x1f66b2[_0x54e433(0x1ab)](_0x54e433(0x1cb)+_0x147090['type']);_0x147090[_0x54e433(0x1c9)]&&!Object[_0x54e433(0x1d5)](AGENT_STATUS)['includes'](_0x147090[_0x54e433(0x1c9)])&&_0x1f66b2[_0x54e433(0x1ab)](_0x54e433(0x18a)+_0x147090[_0x54e433(0x1c9)]);_0x147090['currentModel']&&!Object[_0x54e433(0x1d5)](MODELS)['includes'](_0x147090[_0x54e433(0x1b5)])&&_0x2c7769['push'](_0x54e433(0x198)+_0x147090['currentModel']);_0x147090[_0x54e433(0x1d1)]&&typeof _0x147090['systemPrompt']!=='string'&&_0x1f66b2[_0x54e433(0x1ab)]('System\x20prompt\x20must\x20be\x20a\x20string');_0x147090[_0x54e433(0x1d1)]&&_0x147090['systemPrompt']['length']>0x2710&&_0x2c7769['push'](_0x54e433(0x1ce));if(_0x147090[_0x54e433(0x1d4)]){const _0x1b1181=this['validateConfiguration'](_0x147090['configuration']);_0x1f66b2['push'](..._0x1b1181[_0x54e433(0x1d6)]),_0x2c7769[_0x54e433(0x1ab)](..._0x1b1181[_0x54e433(0x19b)]);}const _0x22e982=[_0x54e433(0x1c4),'updatedAt','lastActivity','pausedUntil'];return _0x22e982[_0x54e433(0x1b9)](_0x4af6ae=>{const _0x20b7cc=_0x54e433;_0x147090[_0x4af6ae]&&!this[_0x20b7cc(0x190)](_0x147090[_0x4af6ae])&&_0x1f66b2[_0x20b7cc(0x1ab)](_0x20b7cc(0x197)+_0x4af6ae+':\x20'+_0x147090[_0x4af6ae]);}),{'isValid':_0x1f66b2['length']===0x0,'errors':_0x1f66b2,'warnings':_0x2c7769};}static[a0_0x546181(0x1b6)](_0x3d244e){const _0x56fd3c=a0_0x546181,_0x26ab77=[],_0x352b1d=[];_0x3d244e[_0x56fd3c(0x1c0)]&&typeof _0x3d244e['maxContextLength']!==_0x56fd3c(0x1d8)&&_0x26ab77[_0x56fd3c(0x1ab)]('maxContextLength\x20must\x20be\x20a\x20number');_0x3d244e[_0x56fd3c(0x1c0)]&&_0x3d244e['maxContextLength']<0x3e8&&_0x352b1d[_0x56fd3c(0x1ab)](_0x56fd3c(0x18d));if(_0x3d244e['temperature']!==undefined){if(typeof _0x3d244e[_0x56fd3c(0x1cc)]!=='number')_0x26ab77[_0x56fd3c(0x1ab)](_0x56fd3c(0x1b8));else(_0x3d244e[_0x56fd3c(0x1cc)]<0x0||_0x3d244e[_0x56fd3c(0x1cc)]>0x2)&&_0x26ab77[_0x56fd3c(0x1ab)]('temperature\x20must\x20be\x20between\x200\x20and\x202');}return _0x3d244e['maxTokens']&&typeof _0x3d244e['maxTokens']!=='number'&&_0x26ab77['push']('maxTokens\x20must\x20be\x20a\x20number'),_0x3d244e['timeout']&&typeof _0x3d244e[_0x56fd3c(0x1ac)]!=='number'&&_0x26ab77['push']('timeout\x20must\x20be\x20a\x20number'),_0x3d244e['timeout']&&_0x3d244e[_0x56fd3c(0x1ac)]<0x3e8&&_0x352b1d['push'](_0x56fd3c(0x1d7)),_0x3d244e['maxRetries']&&typeof _0x3d244e[_0x56fd3c(0x1c5)]!==_0x56fd3c(0x1d8)&&_0x26ab77[_0x56fd3c(0x1ab)](_0x56fd3c(0x1ad)),_0x3d244e['enabledTools']&&!Array[_0x56fd3c(0x1a8)](_0x3d244e['enabledTools'])&&_0x26ab77['push']('enabledTools\x20must\x20be\x20an\x20array'),{'errors':_0x26ab77,'warnings':_0x352b1d};}static['validateCreationParams'](_0x2dca38){const _0x2f8a34=a0_0x546181,_0x418438=[],_0x4f94b8=[];return(!_0x2dca38[_0x2f8a34(0x1bd)]||typeof _0x2dca38['name']!=='string')&&_0x418438['push']('Agent\x20name\x20is\x20required\x20and\x20must\x20be\x20a\x20string'),_0x2dca38[_0x2f8a34(0x1bd)]&&_0x2dca38[_0x2f8a34(0x1bd)][_0x2f8a34(0x1b4)]<0x2&&_0x418438[_0x2f8a34(0x1ab)]('Agent\x20name\x20must\x20be\x20at\x20least\x202\x20characters\x20long'),_0x2dca38[_0x2f8a34(0x1a3)]&&!Object[_0x2f8a34(0x1d5)](AGENT_TYPES)['includes'](_0x2dca38['type'])&&_0x418438['push'](_0x2f8a34(0x1cb)+_0x2dca38[_0x2f8a34(0x1a3)]),_0x2dca38['model']&&!Object['values'](MODELS)['includes'](_0x2dca38['model'])&&_0x4f94b8[_0x2f8a34(0x1ab)](_0x2f8a34(0x198)+_0x2dca38['model']),_0x2dca38[_0x2f8a34(0x1d1)]&&typeof _0x2dca38['systemPrompt']!==_0x2f8a34(0x1ae)&&_0x418438['push'](_0x2f8a34(0x18c)),_0x2dca38[_0x2f8a34(0x1b3)]&&!Array[_0x2f8a34(0x1a8)](_0x2dca38['enabledTools'])&&_0x418438[_0x2f8a34(0x1ab)]('enabledTools\x20must\x20be\x20an\x20array'),{'isValid':_0x418438['length']===0x0,'errors':_0x418438,'warnings':_0x4f94b8};}static[a0_0x546181(0x190)](_0x6e6cc4){const _0x51aeac=a0_0x546181;if(typeof _0x6e6cc4!==_0x51aeac(0x1ae))return![];const _0x3724ab=new Date(_0x6e6cc4);return _0x3724ab instanceof Date&&!isNaN(_0x3724ab[_0x51aeac(0x1a4)]());}}export class AgentFactory{static[a0_0x546181(0x1bc)](_0x203c42){const _0x469dcf=a0_0x546181,_0x28bbe0=AgentValidator[_0x469dcf(0x1af)](_0x203c42);if(!_0x28bbe0['isValid'])throw new Error(_0x469dcf(0x1cf)+_0x28bbe0[_0x469dcf(0x1d6)]['join'](',\x20'));const _0xd8ac90=new Date()['toISOString'](),_0x35904e=this['generateAgentId']();return{'id':_0x35904e,'name':_0x203c42['name'],'type':_0x203c42[_0x469dcf(0x1a3)]||AGENT_TYPES[_0x469dcf(0x1a6)],'status':AGENT_STATUS['IDLE'],'currentModel':_0x203c42[_0x469dcf(0x18e)]||MODELS[_0x469dcf(0x1bf)],'systemPrompt':_0x203c42[_0x469dcf(0x1d1)]||'','configuration':this['createDefaultConfiguration'](_0x203c42[_0x469dcf(0x1d4)]),'metrics':this[_0x469dcf(0x19c)](),'state':this['createDefaultState'](),'createdAt':_0xd8ac90,'updatedAt':_0xd8ac90,'lastActivity':_0xd8ac90,'pausedUntil':null,'pauseReason':null,'metadata':_0x203c42[_0x469dcf(0x1ba)]||{}};}static[a0_0x546181(0x192)](_0x7eeeea={}){const _0x23406f=a0_0x546181;return{'maxContextLength':0xc350,'temperature':0.7,'maxTokens':0x1000,'timeout':0x7530,'persistConversations':!![],'enabledTools':['terminal',_0x23406f(0x19a),_0x23406f(0x1c7)],'toolConfigurations':{},'autoRetry':!![],'maxRetries':0x3,'customSettings':{},..._0x7eeeea};}static['createDefaultMetrics'](){const _0x736b75=a0_0x546181,_0x281f59=new Date()[_0x736b75(0x1c2)]();return{'totalMessages':0x0,'totalTokensUsed':0x0,'totalCost':0x0,'averageResponseTime':0x0,'successRate':0x1,'errorCount':0x0,'toolExecutions':0x0,'conversationsStarted':0x0,'dailyUsage':{'tokens':0x0,'cost':0x0,'messages':0x0},'weeklyUsage':{'tokens':0x0,'cost':0x0,'messages':0x0},'monthlyUsage':{'tokens':0x0,'cost':0x0,'messages':0x0},'lastMetricsUpdate':_0x281f59};}static['createDefaultState'](){return{'currentConversationId':null,'messageCount':0x0,'context':{},'activeTools':[],'pendingOperations':{},'cache':{},'isProcessing':![],'lastError':null,'sessionData':{}};}static['generateAgentId'](){const _0xb96493=a0_0x546181,_0x2527f2=Date[_0xb96493(0x1a1)]()[_0xb96493(0x1c3)](0x24),_0x4bb57b=Math[_0xb96493(0x1a0)]()[_0xb96493(0x1c3)](0x24)[_0xb96493(0x1c8)](0x2,0x9);return'agent_'+_0x2527f2+'_'+_0x4bb57b;}static['clone'](_0xcb67f,_0x13f263){const _0x12cb97=a0_0x546181,_0x330b65={..._0xcb67f},_0x3f284b=new Date()['toISOString']();return _0x330b65['id']=this[_0x12cb97(0x199)](),_0x330b65[_0x12cb97(0x1bd)]=_0x13f263,_0x330b65['status']=AGENT_STATUS[_0x12cb97(0x1ca)],_0x330b65[_0x12cb97(0x1c4)]=_0x3f284b,_0x330b65['updatedAt']=_0x3f284b,_0x330b65[_0x12cb97(0x193)]=_0x3f284b,_0x330b65[_0x12cb97(0x1d3)]=null,_0x330b65['pauseReason']=null,_0x330b65['metrics']=this['createDefaultMetrics'](),_0x330b65['state']=this[_0x12cb97(0x1d0)](),_0x330b65;}}export class AgentUtils{static[a0_0x546181(0x1bb)](_0x103f91){const _0x1db56b=a0_0x546181;return _0x103f91['status']===AGENT_STATUS['ACTIVE']||_0x103f91['status']===AGENT_STATUS[_0x1db56b(0x191)];}static['isPaused'](_0x3139b2){const _0x4b17de=a0_0x546181;if(_0x3139b2[_0x4b17de(0x1c9)]!==AGENT_STATUS[_0x4b17de(0x196)])return![];if(_0x3139b2[_0x4b17de(0x1d3)]){const _0x3bf67c=new Date(_0x3139b2[_0x4b17de(0x1d3)]);return new Date()<_0x3bf67c;}return!![];}static['getEffectiveStatus'](_0x2dcc80){const _0x45ec2b=a0_0x546181;if(_0x2dcc80['status']===AGENT_STATUS['PAUSED']&&_0x2dcc80['pausedUntil']){const _0x4c0f26=new Date(_0x2dcc80[_0x45ec2b(0x1d3)]);if(new Date()>=_0x4c0f26)return AGENT_STATUS['IDLE'];}return _0x2dcc80[_0x45ec2b(0x1c9)];}static[a0_0x546181(0x19e)](_0x1820ea){const _0xd76765=a0_0x546181;if(!this[_0xd76765(0x1a9)](_0x1820ea)||!_0x1820ea[_0xd76765(0x1d3)])return null;const _0x3c5b8c=new Date(_0x1820ea['pausedUntil']),_0x5958c5=new Date();return Math[_0xd76765(0x1a5)](0x0,_0x3c5b8c['getTime']()-_0x5958c5[_0xd76765(0x1a4)]());}static[a0_0x546181(0x19f)](_0x3aac03){const _0x4267c0=a0_0x546181;return{'id':_0x3aac03['id'],'name':_0x3aac03[_0x4267c0(0x1bd)],'type':_0x3aac03['type'],'status':this[_0x4267c0(0x19d)](_0x3aac03),'model':_0x3aac03['currentModel'],'messageCount':_0x3aac03[_0x4267c0(0x18b)][_0x4267c0(0x18f)],'lastActivity':_0x3aac03[_0x4267c0(0x193)],'isPaused':this[_0x4267c0(0x1a9)](_0x3aac03),'timeUntilPauseExpiry':this[_0x4267c0(0x19e)](_0x3aac03)};}static[a0_0x546181(0x1d2)](_0x27349e){const _0x5b01a1=a0_0x546181,_0x422442={..._0x27349e};return delete _0x422442['state']['cache'],delete _0x422442[_0x5b01a1(0x194)]['sessionData'],_0x422442['systemPrompt']&&_0x422442['systemPrompt']['length']>0x1f4&&(_0x422442['systemPrompt']=_0x422442['systemPrompt']['substring'](0x0,0x1f4)+_0x5b01a1(0x1c1)),_0x422442;}}export default{'AgentValidator':AgentValidator,'AgentFactory':AgentFactory,'AgentUtils':AgentUtils};
|