@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/tools/baseTool.js
CHANGED
|
@@ -1,800 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BaseTool - Abstract base class for all tools in the Loxia AI Agents System
|
|
3
|
-
*
|
|
4
|
-
* Purpose:
|
|
5
|
-
* - Define standardized tool interface
|
|
6
|
-
* - Provide common tool functionality
|
|
7
|
-
* - Handle parameter validation
|
|
8
|
-
* - Manage tool execution lifecycle
|
|
9
|
-
* - Support both sync and async operations
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
TOOL_STATUS,
|
|
14
|
-
OPERATION_STATUS,
|
|
15
|
-
ERROR_TYPES,
|
|
16
|
-
SYSTEM_DEFAULTS
|
|
17
|
-
} from '../utilities/constants.js';
|
|
18
|
-
|
|
19
|
-
class BaseTool {
|
|
20
|
-
constructor(config = {}, logger = null) {
|
|
21
|
-
this.id = this.constructor.name.toLowerCase().replace('tool', '');
|
|
22
|
-
this.config = config;
|
|
23
|
-
this.logger = logger;
|
|
24
|
-
|
|
25
|
-
// Tool capabilities
|
|
26
|
-
this.requiresProject = false;
|
|
27
|
-
this.isAsync = false;
|
|
28
|
-
this.timeout = config.timeout || SYSTEM_DEFAULTS.MAX_TOOL_EXECUTION_TIME;
|
|
29
|
-
this.maxConcurrentOperations = config.maxConcurrentOperations || 1;
|
|
30
|
-
|
|
31
|
-
// Operation tracking
|
|
32
|
-
this.activeOperations = new Map();
|
|
33
|
-
this.operationHistory = [];
|
|
34
|
-
|
|
35
|
-
// Tool state
|
|
36
|
-
this.isEnabled = config.enabled !== false;
|
|
37
|
-
this.lastUsed = null;
|
|
38
|
-
this.usageCount = 0;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Get tool description for LLM consumption
|
|
43
|
-
* Must be implemented by subclasses
|
|
44
|
-
* @returns {string} Tool description
|
|
45
|
-
*/
|
|
46
|
-
getDescription() {
|
|
47
|
-
throw new Error(`Tool ${this.id} must implement getDescription()`);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Parse parameters from tool command content
|
|
52
|
-
* Must be implemented by subclasses
|
|
53
|
-
* @param {string} content - Raw tool command content
|
|
54
|
-
* @returns {Object} Parsed parameters object
|
|
55
|
-
*/
|
|
56
|
-
parseParameters(content) {
|
|
57
|
-
throw new Error(`Tool ${this.id} must implement parseParameters()`);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Execute tool with parsed parameters
|
|
62
|
-
* Must be implemented by subclasses
|
|
63
|
-
* @param {Object} params - Parsed parameters
|
|
64
|
-
* @param {Object} context - Execution context
|
|
65
|
-
* @returns {Promise<*>} Execution result
|
|
66
|
-
*/
|
|
67
|
-
async execute(params, context) {
|
|
68
|
-
throw new Error(`Tool ${this.id} must implement execute()`);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Get tool capabilities metadata
|
|
73
|
-
* @returns {Object} Capabilities object
|
|
74
|
-
*/
|
|
75
|
-
getCapabilities() {
|
|
76
|
-
return {
|
|
77
|
-
id: this.id,
|
|
78
|
-
async: this.isAsync,
|
|
79
|
-
requiresProject: this.requiresProject,
|
|
80
|
-
timeout: this.timeout,
|
|
81
|
-
maxConcurrentOperations: this.maxConcurrentOperations,
|
|
82
|
-
enabled: this.isEnabled,
|
|
83
|
-
supportedActions: this.getSupportedActions(),
|
|
84
|
-
parameterSchema: this.getParameterSchema()
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Validate tool parameters
|
|
90
|
-
* Can be overridden by subclasses for custom validation
|
|
91
|
-
* @param {Object} params - Parameters to validate
|
|
92
|
-
* @returns {Object} Validation result with valid flag and error message
|
|
93
|
-
*/
|
|
94
|
-
validateParameters(params) {
|
|
95
|
-
try {
|
|
96
|
-
if (!params || typeof params !== 'object') {
|
|
97
|
-
return {
|
|
98
|
-
valid: false,
|
|
99
|
-
error: 'Parameters must be an object'
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Check required parameters
|
|
104
|
-
const requiredParams = this.getRequiredParameters();
|
|
105
|
-
for (const required of requiredParams) {
|
|
106
|
-
if (!(required in params)) {
|
|
107
|
-
return {
|
|
108
|
-
valid: false,
|
|
109
|
-
error: `Missing required parameter: ${required}`
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Validate parameter types
|
|
115
|
-
const typeValidation = this.validateParameterTypes(params);
|
|
116
|
-
if (!typeValidation.valid) {
|
|
117
|
-
return typeValidation;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Custom validation
|
|
121
|
-
const customValidation = this.customValidateParameters(params);
|
|
122
|
-
if (!customValidation.valid) {
|
|
123
|
-
return customValidation;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return { valid: true };
|
|
127
|
-
|
|
128
|
-
} catch (error) {
|
|
129
|
-
return {
|
|
130
|
-
valid: false,
|
|
131
|
-
error: `Parameter validation failed: ${error.message}`
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Execute tool with full lifecycle management
|
|
138
|
-
* @param {Object} params - Tool parameters
|
|
139
|
-
* @param {Object} context - Execution context
|
|
140
|
-
* @returns {Promise<Object>} Execution result with metadata
|
|
141
|
-
*/
|
|
142
|
-
async executeWithLifecycle(params, context) {
|
|
143
|
-
const operationId = this.generateOperationId();
|
|
144
|
-
const startTime = Date.now();
|
|
145
|
-
|
|
146
|
-
// Check if tool is enabled
|
|
147
|
-
if (!this.isEnabled) {
|
|
148
|
-
throw new Error(`Tool ${this.id} is disabled`);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// Check concurrent operation limits
|
|
152
|
-
if (this.activeOperations.size >= this.maxConcurrentOperations) {
|
|
153
|
-
throw new Error(`Tool ${this.id} has reached maximum concurrent operations limit`);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Validate parameters
|
|
157
|
-
const validation = this.validateParameters(params);
|
|
158
|
-
if (!validation.valid) {
|
|
159
|
-
throw new Error(`Parameter validation failed: ${validation.error}`);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Create operation record
|
|
163
|
-
const operation = {
|
|
164
|
-
id: operationId,
|
|
165
|
-
toolId: this.id,
|
|
166
|
-
status: TOOL_STATUS.EXECUTING,
|
|
167
|
-
startTime: new Date().toISOString(),
|
|
168
|
-
params,
|
|
169
|
-
context: this.sanitizeContext(context)
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
this.activeOperations.set(operationId, operation);
|
|
173
|
-
|
|
174
|
-
try {
|
|
175
|
-
this.logger?.info(`Tool execution started: ${this.id}`, {
|
|
176
|
-
operationId,
|
|
177
|
-
toolId: this.id,
|
|
178
|
-
context: operation.context
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
// Execute with timeout
|
|
182
|
-
const result = await this.executeWithTimeout(params, context);
|
|
183
|
-
|
|
184
|
-
// Update operation status
|
|
185
|
-
operation.status = TOOL_STATUS.COMPLETED;
|
|
186
|
-
operation.result = result;
|
|
187
|
-
operation.endTime = new Date().toISOString();
|
|
188
|
-
operation.executionTime = Date.now() - startTime;
|
|
189
|
-
|
|
190
|
-
// Update tool statistics
|
|
191
|
-
this.lastUsed = new Date().toISOString();
|
|
192
|
-
this.usageCount++;
|
|
193
|
-
|
|
194
|
-
this.logger?.info(`Tool execution completed: ${this.id}`, {
|
|
195
|
-
operationId,
|
|
196
|
-
executionTime: operation.executionTime,
|
|
197
|
-
success: true
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
return {
|
|
201
|
-
success: true,
|
|
202
|
-
operationId,
|
|
203
|
-
result,
|
|
204
|
-
executionTime: operation.executionTime,
|
|
205
|
-
toolId: this.id
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
} catch (error) {
|
|
209
|
-
// Update operation status
|
|
210
|
-
operation.status = TOOL_STATUS.FAILED;
|
|
211
|
-
operation.error = error.message;
|
|
212
|
-
operation.endTime = new Date().toISOString();
|
|
213
|
-
operation.executionTime = Date.now() - startTime;
|
|
214
|
-
|
|
215
|
-
this.logger?.error(`Tool execution failed: ${this.id}`, {
|
|
216
|
-
operationId,
|
|
217
|
-
error: error.message,
|
|
218
|
-
executionTime: operation.executionTime
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
throw error;
|
|
222
|
-
|
|
223
|
-
} finally {
|
|
224
|
-
// Move to history and cleanup
|
|
225
|
-
this.operationHistory.push({ ...operation });
|
|
226
|
-
this.activeOperations.delete(operationId);
|
|
227
|
-
|
|
228
|
-
// Cleanup old history entries
|
|
229
|
-
this.cleanupHistory();
|
|
230
|
-
|
|
231
|
-
// Perform tool-specific cleanup
|
|
232
|
-
await this.cleanup(operationId);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Get status of async operation
|
|
238
|
-
* @param {string} operationId - Operation identifier
|
|
239
|
-
* @returns {Promise<Object>} Operation status
|
|
240
|
-
*/
|
|
241
|
-
async getStatus(operationId) {
|
|
242
|
-
const operation = this.activeOperations.get(operationId);
|
|
243
|
-
|
|
244
|
-
if (!operation) {
|
|
245
|
-
// Check history
|
|
246
|
-
const historyEntry = this.operationHistory.find(op => op.id === operationId);
|
|
247
|
-
if (historyEntry) {
|
|
248
|
-
return {
|
|
249
|
-
operationId,
|
|
250
|
-
status: historyEntry.status,
|
|
251
|
-
result: historyEntry.result,
|
|
252
|
-
error: historyEntry.error,
|
|
253
|
-
executionTime: historyEntry.executionTime
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return {
|
|
258
|
-
operationId,
|
|
259
|
-
status: OPERATION_STATUS.NOT_FOUND,
|
|
260
|
-
error: 'Operation not found'
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
return {
|
|
265
|
-
operationId,
|
|
266
|
-
status: operation.status,
|
|
267
|
-
startTime: operation.startTime,
|
|
268
|
-
executionTime: operation.endTime ?
|
|
269
|
-
new Date(operation.endTime).getTime() - new Date(operation.startTime).getTime() :
|
|
270
|
-
Date.now() - new Date(operation.startTime).getTime()
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Resource cleanup after tool execution
|
|
276
|
-
* Can be overridden by subclasses
|
|
277
|
-
* @param {string} operationId - Operation identifier
|
|
278
|
-
* @returns {Promise<void>}
|
|
279
|
-
*/
|
|
280
|
-
async cleanup(operationId) {
|
|
281
|
-
// Default implementation - no cleanup needed
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Get supported actions for this tool
|
|
286
|
-
* Can be overridden by subclasses
|
|
287
|
-
* @returns {Array<string>} Array of supported action names
|
|
288
|
-
*/
|
|
289
|
-
getSupportedActions() {
|
|
290
|
-
return ['execute'];
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Get parameter schema for validation
|
|
295
|
-
* Can be overridden by subclasses
|
|
296
|
-
* @returns {Object} Parameter schema
|
|
297
|
-
*/
|
|
298
|
-
getParameterSchema() {
|
|
299
|
-
return {
|
|
300
|
-
type: 'object',
|
|
301
|
-
properties: {},
|
|
302
|
-
required: []
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Get required parameters
|
|
308
|
-
* Can be overridden by subclasses
|
|
309
|
-
* @returns {Array<string>} Array of required parameter names
|
|
310
|
-
*/
|
|
311
|
-
getRequiredParameters() {
|
|
312
|
-
return [];
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* Validate parameter types
|
|
317
|
-
* Can be overridden by subclasses
|
|
318
|
-
* @param {Object} params - Parameters to validate
|
|
319
|
-
* @returns {Object} Validation result
|
|
320
|
-
*/
|
|
321
|
-
validateParameterTypes(params) {
|
|
322
|
-
// Default implementation - all parameters are valid
|
|
323
|
-
return { valid: true };
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Custom parameter validation
|
|
328
|
-
* Can be overridden by subclasses
|
|
329
|
-
* @param {Object} params - Parameters to validate
|
|
330
|
-
* @returns {Object} Validation result
|
|
331
|
-
*/
|
|
332
|
-
customValidateParameters(params) {
|
|
333
|
-
// Default implementation - no custom validation
|
|
334
|
-
return { valid: true };
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Execute tool with timeout protection
|
|
339
|
-
* @private
|
|
340
|
-
*/
|
|
341
|
-
async executeWithTimeout(params, context) {
|
|
342
|
-
return new Promise(async (resolve, reject) => {
|
|
343
|
-
const timeoutId = setTimeout(() => {
|
|
344
|
-
reject(new Error(`Tool execution timed out after ${this.timeout}ms`));
|
|
345
|
-
}, this.timeout);
|
|
346
|
-
|
|
347
|
-
try {
|
|
348
|
-
const result = await this.execute(params, context);
|
|
349
|
-
clearTimeout(timeoutId);
|
|
350
|
-
resolve(result);
|
|
351
|
-
} catch (error) {
|
|
352
|
-
clearTimeout(timeoutId);
|
|
353
|
-
reject(error);
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Generate unique operation ID
|
|
360
|
-
* @private
|
|
361
|
-
*/
|
|
362
|
-
generateOperationId() {
|
|
363
|
-
return `${this.id}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* Sanitize context for logging
|
|
368
|
-
* @private
|
|
369
|
-
*/
|
|
370
|
-
sanitizeContext(context) {
|
|
371
|
-
const sanitized = { ...context };
|
|
372
|
-
|
|
373
|
-
// Remove sensitive information
|
|
374
|
-
delete sanitized.apiKeys;
|
|
375
|
-
delete sanitized.secrets;
|
|
376
|
-
delete sanitized.passwords;
|
|
377
|
-
|
|
378
|
-
// Truncate large content
|
|
379
|
-
if (sanitized.content && sanitized.content.length > 500) {
|
|
380
|
-
sanitized.content = sanitized.content.substring(0, 500) + '... [truncated]';
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
return sanitized;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Cleanup old history entries
|
|
388
|
-
* @private
|
|
389
|
-
*/
|
|
390
|
-
cleanupHistory() {
|
|
391
|
-
const maxHistoryEntries = 100;
|
|
392
|
-
if (this.operationHistory.length > maxHistoryEntries) {
|
|
393
|
-
this.operationHistory = this.operationHistory.slice(-maxHistoryEntries);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* Get tool usage statistics
|
|
399
|
-
* @returns {Object} Usage statistics
|
|
400
|
-
*/
|
|
401
|
-
getUsageStats() {
|
|
402
|
-
return {
|
|
403
|
-
toolId: this.id,
|
|
404
|
-
usageCount: this.usageCount,
|
|
405
|
-
lastUsed: this.lastUsed,
|
|
406
|
-
activeOperations: this.activeOperations.size,
|
|
407
|
-
totalOperations: this.operationHistory.length,
|
|
408
|
-
averageExecutionTime: this.calculateAverageExecutionTime(),
|
|
409
|
-
successRate: this.calculateSuccessRate(),
|
|
410
|
-
isEnabled: this.isEnabled
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Calculate average execution time
|
|
416
|
-
* @private
|
|
417
|
-
*/
|
|
418
|
-
calculateAverageExecutionTime() {
|
|
419
|
-
const completedOps = this.operationHistory.filter(op =>
|
|
420
|
-
op.status === TOOL_STATUS.COMPLETED && op.executionTime
|
|
421
|
-
);
|
|
422
|
-
|
|
423
|
-
if (completedOps.length === 0) return 0;
|
|
424
|
-
|
|
425
|
-
const totalTime = completedOps.reduce((sum, op) => sum + op.executionTime, 0);
|
|
426
|
-
return Math.round(totalTime / completedOps.length);
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Calculate success rate
|
|
431
|
-
* @private
|
|
432
|
-
*/
|
|
433
|
-
calculateSuccessRate() {
|
|
434
|
-
if (this.operationHistory.length === 0) return 0;
|
|
435
|
-
|
|
436
|
-
const successfulOps = this.operationHistory.filter(op =>
|
|
437
|
-
op.status === TOOL_STATUS.COMPLETED
|
|
438
|
-
);
|
|
439
|
-
|
|
440
|
-
return (successfulOps.length / this.operationHistory.length) * 100;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Enable tool
|
|
445
|
-
*/
|
|
446
|
-
enable() {
|
|
447
|
-
this.isEnabled = true;
|
|
448
|
-
this.logger?.info(`Tool enabled: ${this.id}`);
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* Disable tool
|
|
453
|
-
*/
|
|
454
|
-
disable() {
|
|
455
|
-
this.isEnabled = false;
|
|
456
|
-
this.logger?.info(`Tool disabled: ${this.id}`);
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
/**
|
|
460
|
-
* Reset tool statistics
|
|
461
|
-
*/
|
|
462
|
-
resetStats() {
|
|
463
|
-
this.usageCount = 0;
|
|
464
|
-
this.lastUsed = null;
|
|
465
|
-
this.operationHistory = [];
|
|
466
|
-
this.logger?.info(`Tool statistics reset: ${this.id}`);
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
/**
|
|
471
|
-
* ToolsRegistry - Manages registration and discovery of tools
|
|
472
|
-
*/
|
|
473
|
-
class ToolsRegistry {
|
|
474
|
-
constructor(logger = null) {
|
|
475
|
-
this.logger = logger;
|
|
476
|
-
this.tools = new Map();
|
|
477
|
-
this.toolDescriptions = new Map();
|
|
478
|
-
this.toolCapabilities = new Map();
|
|
479
|
-
this.asyncOperations = new Map();
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* Register a tool class
|
|
484
|
-
* @param {Class} toolClass - Tool class to register
|
|
485
|
-
* @returns {Promise<void>}
|
|
486
|
-
*/
|
|
487
|
-
async registerTool(toolClass) {
|
|
488
|
-
try {
|
|
489
|
-
const tool = new toolClass();
|
|
490
|
-
|
|
491
|
-
if (!(tool instanceof BaseTool)) {
|
|
492
|
-
throw new Error(`Tool ${toolClass.name} must extend BaseTool`);
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
const capabilities = tool.getCapabilities();
|
|
496
|
-
|
|
497
|
-
// Validate tool implementation
|
|
498
|
-
await this.validateTool(tool);
|
|
499
|
-
|
|
500
|
-
this.tools.set(tool.id, tool);
|
|
501
|
-
this.toolDescriptions.set(tool.id, tool.getDescription());
|
|
502
|
-
this.toolCapabilities.set(tool.id, capabilities);
|
|
503
|
-
|
|
504
|
-
this.logger?.info(`Tool registered: ${tool.id}`, {
|
|
505
|
-
capabilities: capabilities.supportedActions,
|
|
506
|
-
async: capabilities.async,
|
|
507
|
-
requiresProject: capabilities.requiresProject
|
|
508
|
-
});
|
|
509
|
-
|
|
510
|
-
} catch (error) {
|
|
511
|
-
this.logger?.error(`Tool registration failed: ${error.message}`, {
|
|
512
|
-
toolClass: toolClass.name
|
|
513
|
-
});
|
|
514
|
-
throw error;
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
/**
|
|
519
|
-
* Auto-discover tools in directory
|
|
520
|
-
* @param {string} directory - Directory path to scan
|
|
521
|
-
* @returns {Promise<number>} Number of tools discovered
|
|
522
|
-
*/
|
|
523
|
-
async discoverTools(directory) {
|
|
524
|
-
// Implementation would scan directory for tool files
|
|
525
|
-
// For now, return 0
|
|
526
|
-
return 0;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
/**
|
|
530
|
-
* Validate tool implementation
|
|
531
|
-
* @param {BaseTool} tool - Tool instance to validate
|
|
532
|
-
* @returns {Promise<void>}
|
|
533
|
-
*/
|
|
534
|
-
async validateTool(tool) {
|
|
535
|
-
// Check required methods
|
|
536
|
-
const requiredMethods = ['getDescription', 'parseParameters', 'execute'];
|
|
537
|
-
|
|
538
|
-
for (const method of requiredMethods) {
|
|
539
|
-
if (typeof tool[method] !== 'function') {
|
|
540
|
-
throw new Error(`Tool ${tool.id} missing required method: ${method}`);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
// Test parameter parsing
|
|
545
|
-
try {
|
|
546
|
-
const testParams = tool.parseParameters('test content');
|
|
547
|
-
if (typeof testParams !== 'object') {
|
|
548
|
-
throw new Error(`Tool ${tool.id} parseParameters must return an object`);
|
|
549
|
-
}
|
|
550
|
-
} catch (error) {
|
|
551
|
-
// Parsing may fail for test content, that's okay
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
// Validate capabilities
|
|
555
|
-
const capabilities = tool.getCapabilities();
|
|
556
|
-
if (!capabilities || typeof capabilities !== 'object') {
|
|
557
|
-
throw new Error(`Tool ${tool.id} getCapabilities must return an object`);
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* Get tool by ID
|
|
563
|
-
* @param {string} toolId - Tool identifier
|
|
564
|
-
* @returns {BaseTool|null} Tool instance or null
|
|
565
|
-
*/
|
|
566
|
-
getTool(toolId) {
|
|
567
|
-
return this.tools.get(toolId) || null;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
/**
|
|
571
|
-
* Get all tool capabilities for LLM consumption
|
|
572
|
-
* @returns {Object} All tool capabilities
|
|
573
|
-
*/
|
|
574
|
-
getToolCapabilities() {
|
|
575
|
-
const capabilities = {};
|
|
576
|
-
|
|
577
|
-
for (const [toolId, tool] of this.tools.entries()) {
|
|
578
|
-
if (tool.isEnabled) {
|
|
579
|
-
capabilities[toolId] = {
|
|
580
|
-
description: this.toolDescriptions.get(toolId),
|
|
581
|
-
capabilities: this.toolCapabilities.get(toolId),
|
|
582
|
-
usageStats: tool.getUsageStats()
|
|
583
|
-
};
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
return capabilities;
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
/**
|
|
591
|
-
* Execute tool securely with validation
|
|
592
|
-
* @param {string} toolId - Tool identifier
|
|
593
|
-
* @param {Object} params - Tool parameters
|
|
594
|
-
* @param {Object} context - Execution context
|
|
595
|
-
* @returns {Promise<*>} Execution result
|
|
596
|
-
*/
|
|
597
|
-
async executeToolSecurely(toolId, params, context) {
|
|
598
|
-
const tool = this.getTool(toolId);
|
|
599
|
-
if (!tool) {
|
|
600
|
-
throw new Error(`Tool not found: ${toolId}`);
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
if (!tool.isEnabled) {
|
|
604
|
-
throw new Error(`Tool is disabled: ${toolId}`);
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
return await tool.executeWithLifecycle(params, context);
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
/**
|
|
611
|
-
* List all registered tools
|
|
612
|
-
* @returns {Array<string>} Array of tool IDs
|
|
613
|
-
*/
|
|
614
|
-
listTools() {
|
|
615
|
-
return Array.from(this.tools.keys());
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
/**
|
|
619
|
-
* Generate comprehensive tool descriptions for agent system prompts
|
|
620
|
-
* @param {Array<string>} capabilities - Specific tool IDs to include (empty = all)
|
|
621
|
-
* @param {Object} options - Generation options
|
|
622
|
-
* @returns {string} Formatted tool descriptions section
|
|
623
|
-
*/
|
|
624
|
-
generateToolDescriptionsForPrompt(capabilities = [], options = {}) {
|
|
625
|
-
const {
|
|
626
|
-
includeExamples = true,
|
|
627
|
-
includeUsageGuidelines = true,
|
|
628
|
-
includeSecurityNotes = true,
|
|
629
|
-
compact = false
|
|
630
|
-
} = options;
|
|
631
|
-
|
|
632
|
-
// Get tools to include
|
|
633
|
-
const toolIds = capabilities.length > 0
|
|
634
|
-
? capabilities.filter(cap => this.tools.has(cap))
|
|
635
|
-
: Array.from(this.tools.keys());
|
|
636
|
-
|
|
637
|
-
if (toolIds.length === 0) {
|
|
638
|
-
return '';
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
let description = '\n## AVAILABLE TOOLS\n\n';
|
|
642
|
-
description += 'You have access to the following tools to perform operations and tasks:\n\n';
|
|
643
|
-
|
|
644
|
-
// Add individual tool descriptions
|
|
645
|
-
for (const toolId of toolIds) {
|
|
646
|
-
const tool = this.tools.get(toolId);
|
|
647
|
-
if (!tool || !tool.isEnabled) continue;
|
|
648
|
-
|
|
649
|
-
try {
|
|
650
|
-
if (compact) {
|
|
651
|
-
// Compact format - just tool name and brief description
|
|
652
|
-
const capabilities = tool.getCapabilities();
|
|
653
|
-
const actions = capabilities.supportedActions || ['execute'];
|
|
654
|
-
description += `**${toolId}**: ${actions.join(', ')}\n`;
|
|
655
|
-
} else {
|
|
656
|
-
// Full format - complete tool description
|
|
657
|
-
description += `### ${toolId.toUpperCase()} TOOL\n\n`;
|
|
658
|
-
description += tool.getDescription();
|
|
659
|
-
description += '\n\n---\n\n';
|
|
660
|
-
}
|
|
661
|
-
} catch (error) {
|
|
662
|
-
this.logger?.warn(`Failed to get description for tool: ${toolId}`, {
|
|
663
|
-
error: error.message
|
|
664
|
-
});
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
if (compact) {
|
|
669
|
-
description += '\nUse [tool id="tool-name"]<parameters>[/tool] or JSON format to invoke tools.\n\n';
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
// Add comprehensive tool invocation instructions
|
|
673
|
-
description += '## TOOL INVOCATION SYNTAX\n\n';
|
|
674
|
-
description += '**IMPORTANT**: You MUST use one of these exact formats to invoke tools:\n\n';
|
|
675
|
-
description += '### Format 1: Bracket Notation\n';
|
|
676
|
-
description += '```\n';
|
|
677
|
-
description += '[tool id="toolname"]\n';
|
|
678
|
-
description += '<parameters here>\n';
|
|
679
|
-
description += '[/tool]\n';
|
|
680
|
-
description += '```\n\n';
|
|
681
|
-
description += '### Format 2: JSON in Markdown Code Block (REQUIRED for JSON)\n';
|
|
682
|
-
description += '```\n';
|
|
683
|
-
description += '```json\n';
|
|
684
|
-
description += '{\n';
|
|
685
|
-
description += ' "toolId": "toolname",\n';
|
|
686
|
-
description += ' "parameters": { ... } or "actions": [ ... ]\n';
|
|
687
|
-
description += '}\n';
|
|
688
|
-
description += '```\n';
|
|
689
|
-
description += '```\n\n';
|
|
690
|
-
description += '**WARNING**: Plain JSON without markdown code blocks (```json) will NOT be executed!\n';
|
|
691
|
-
description += 'Always wrap JSON tool commands in ```json ... ``` blocks.\n\n';
|
|
692
|
-
description += '### Format 3: XML Format\n';
|
|
693
|
-
description += '```xml\n';
|
|
694
|
-
description += '<tool-command>\n';
|
|
695
|
-
description += ' <tool id="toolname">\n';
|
|
696
|
-
description += ' <parameter>value</parameter>\n';
|
|
697
|
-
description += ' </tool>\n';
|
|
698
|
-
description += '</tool-command>\n';
|
|
699
|
-
description += '```\n\n';
|
|
700
|
-
description += 'After invoking a tool, WAIT for the actual response. Do NOT generate imaginary responses.\n';
|
|
701
|
-
|
|
702
|
-
return description;
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
/**
|
|
706
|
-
* Enhance existing system prompt with tool descriptions
|
|
707
|
-
* @param {string} existingPrompt - Current system prompt
|
|
708
|
-
* @param {Array<string>} capabilities - Agent capabilities
|
|
709
|
-
* @param {Object} options - Enhancement options
|
|
710
|
-
* @returns {string} Enhanced system prompt
|
|
711
|
-
*/
|
|
712
|
-
enhanceSystemPrompt(existingPrompt, capabilities = [], options = {}) {
|
|
713
|
-
const toolSection = this.generateToolDescriptionsForPrompt(capabilities, options);
|
|
714
|
-
|
|
715
|
-
if (!toolSection.trim()) {
|
|
716
|
-
return existingPrompt || '';
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
const prompt = existingPrompt || '';
|
|
720
|
-
|
|
721
|
-
// If prompt already contains tool section, replace it
|
|
722
|
-
if (prompt.includes('## AVAILABLE TOOLS')) {
|
|
723
|
-
return prompt.replace(
|
|
724
|
-
/## AVAILABLE TOOLS[\s\S]*?(?=##|$)/,
|
|
725
|
-
toolSection + '\n'
|
|
726
|
-
);
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
const orientationParagraph = `IMPORTANT: when asked to perform an action or operation, use each response to invoke a tool if needed, and update the user on the progress (same message).`;
|
|
730
|
-
|
|
731
|
-
// Otherwise, append to the end
|
|
732
|
-
return prompt + (prompt.endsWith('\n') ? '' : '\n') + toolSection + orientationParagraph + '\n';
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
/**
|
|
736
|
-
* Get available tools with metadata for web UI
|
|
737
|
-
* @returns {Array} Array of tool information objects
|
|
738
|
-
*/
|
|
739
|
-
getAvailableToolsForUI() {
|
|
740
|
-
const tools = [];
|
|
741
|
-
|
|
742
|
-
for (const [toolId, tool] of this.tools.entries()) {
|
|
743
|
-
const capabilities = tool.getCapabilities();
|
|
744
|
-
|
|
745
|
-
// Extract tool name and description from the tool's description
|
|
746
|
-
const fullDescription = tool.getDescription();
|
|
747
|
-
const firstLine = fullDescription.split('\n').find(line => line.trim().length > 0) || '';
|
|
748
|
-
const toolName = firstLine.replace(/^.*Tool:\s*/i, '').replace(/\s*-.*$/, '').trim();
|
|
749
|
-
|
|
750
|
-
tools.push({
|
|
751
|
-
id: toolId, // This is the correct ID to use in capabilities
|
|
752
|
-
name: toolName || toolId.charAt(0).toUpperCase() + toolId.slice(1),
|
|
753
|
-
description: firstLine,
|
|
754
|
-
category: this._getToolCategory(toolId),
|
|
755
|
-
enabled: capabilities.enabled,
|
|
756
|
-
async: capabilities.async,
|
|
757
|
-
requiresProject: capabilities.requiresProject,
|
|
758
|
-
className: tool.constructor.name
|
|
759
|
-
});
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
return tools.sort((a, b) => a.name.localeCompare(b.name));
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
/**
|
|
766
|
-
* Get tool category for organization
|
|
767
|
-
* @param {string} toolId - Tool identifier
|
|
768
|
-
* @returns {string} Tool category
|
|
769
|
-
* @private
|
|
770
|
-
*/
|
|
771
|
-
_getToolCategory(toolId) {
|
|
772
|
-
const categories = {
|
|
773
|
-
'terminal': 'System',
|
|
774
|
-
'filesystem': 'File Operations',
|
|
775
|
-
'browser': 'Automation',
|
|
776
|
-
'agentdelay': 'Utility'
|
|
777
|
-
};
|
|
778
|
-
|
|
779
|
-
return categories[toolId] || 'Other';
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
/**
|
|
783
|
-
* Get registry statistics
|
|
784
|
-
* @returns {Object} Registry statistics
|
|
785
|
-
*/
|
|
786
|
-
getRegistryStats() {
|
|
787
|
-
const enabledTools = Array.from(this.tools.values()).filter(tool => tool.isEnabled);
|
|
788
|
-
const totalOperations = Array.from(this.tools.values())
|
|
789
|
-
.reduce((sum, tool) => sum + tool.usageCount, 0);
|
|
790
|
-
|
|
791
|
-
return {
|
|
792
|
-
totalTools: this.tools.size,
|
|
793
|
-
enabledTools: enabledTools.length,
|
|
794
|
-
totalOperations,
|
|
795
|
-
activeOperations: this.asyncOperations.size
|
|
796
|
-
};
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
export { BaseTool, ToolsRegistry };
|
|
1
|
+
const a0_0x2a701a=a0_0x5e6a;function a0_0x2cea(){const _0x43913f=['ww91igHHDMuGywnJzxnZihrVihrOzsbMB2XSB3DPBMCGDg9VBhmGDg8GCgvYzM9YBsbVCgvYyxrPB25ZigfUzcb0yxnRCZOkcG','mZa1oda4mgTHuuvxEq','BgvUz3rO','y3vZDg9TvMfSAwrHDgvqyxjHBwv0zxjZ','CMvWBgfJzq','Aw5MBW','x2DLDfrVB2XdyxrLz29YEq','z2v0uMvXDwLYzwrqyxjHBwv0zxjZ','z2v0q2fWywjPBgL0AwvZ','ndiWnZiYmxzlz2fkEa','t3bLCMf0Aw9Uig5VDcbMB3vUza','iYmGve9ptcbjtLzpq0fusu9oifnztLrbwaOk','C3vIC3rY','zgLZywjSzq','vg9VBcbUB3qGzM91BMq6ia','zgvSzxrL','Dg9mB3DLCKnHC2u','vg9VBcbYzwDPC3rLCMvKoIa','ifrpt0WkcG','C3vIC3rYAw5N','ygbGANnVBGO','C3rHDhvZ','y29UzMLN','Dg9tDhjPBMC','vg9VBcbLBMfIBgvKoIa','q09nueXfveve','yxn5BMm','C2L6zq','AgfZ','zxHLy3v0zvrVB2Xtzwn1CMvSEq','zNjVBq','ihbHCNnLugfYyw1LDgvYCYbTDxn0ihjLDhvYBIbHBIbVyMPLy3q','vg9VBcbZDgf0Axn0AwnZihjLC2v0oIa','mJCWmZu4rgPyrxPJ','mtiWotyYnerABefbDa','z2v0','Dg9VBerLC2nYAxb0Aw9UCW','Dg9VBhm','ica8Dg9VBcbPzd0IDg9VBg5HBwuIpGO','zxHLy3v0Aw9UvgLTzq','BM93','zMLSDgvY','u3LZDgvT','y2fSy3vSyxrLu3vJy2vZC1jHDgu','y29UC3rYDwn0B3i','DhjPBq','z2v0rgvZy3jPChrPB24','Bg9Nz2vY','DMfSAwq','qxv0B21HDgLVBG','CMvXDwLYzxnqCM9Qzwn0','y29UDgv4Da','zxHLy3v0zq','z2v0vxnHz2vtDgf0CW','y29UDgvUDa','ygbGcG','kIPjtvbpuLrbtLqQkJOGww91ie1vu1qGDxnLig9UzsbVzIb0AgvZzsbLEgfJDcbMB3jTyxrZihrVigLUDM9Rzsb0B29SCZOkcG','kIO6ia','zNvUy3rPB24','z2v0vgLTzq','BgfZDfvZzwq','z2v0uMvNAxn0CNLtDgf0CW','Dg9vChbLCKnHC2u','y2XLyw51CeHPC3rVCNK','phrVB2WTy29TBwfUzd4k','tufyx1rpt0XFrvHfq1vusu9ox1rjtuu','iYmJia','yxn5BMnpCgvYyxrPB25Z','Dg9VBenHCgfIAwXPDgLLCW','rKfjteve','zxHLy3v0zvDPDgHmAwzLy3LJBgu','mZG4ndjTsfPnuvC','CgfYC2vqyxjHBwv0zxjZ','nZu1CKLczvHh','DMfSAwrHDgvqyxjHBwv0zxjZ','BwvZC2fNzq','Dg9ju09tDhjPBMC','mZu4mdK2BxHAvvrL','AxnfBMfIBgvK','DMfSAwrHDgvuB29S','tK9ux0zpvu5e','igDLDenHCgfIAwXPDgLLCYbTDxn0ihjLDhvYBIbHBIbVyMPLy3q','CMvKDwnL','iYmJiezVCM1HDcaZoIbytuWGrM9YBwf0cG','vg9VBca','B3bLCMf0Aw9UsgLZDg9YEq','DMfSAwrHDgvqyxjHBwv0zxjuExbLCW','ugfYyw1LDgvYihzHBgLKyxrPB24GzMfPBgvKoIa','CMvZzxrtDgf0CW','C2v0','ChvZAa','iYmGqvzbsuXbqKXfifrpt0Xt','otuZmKv4C1jqEa','ygbGEg1ScG','icaIDg9VBeLKiJOGiNrVB2XUyw1LiIWk','Bg9JywXLq29TCgfYzq','t3rOzxi','ygbGcGO','A2v5CW','z2vUzxjHDgvpCgvYyxrPB25jza','twLZC2LUzYbYzxf1AxjLzcbWyxjHBwv0zxi6ia','igHHCYbYzwfJAgvKig1HEgLTDw0Gy29Uy3vYCMvUDcbVCgvYyxrPB25ZigXPBwL0','nJnpEMTAqw4','ig11C3qGzxH0zw5KiejHC2vuB29S','zMLUza','C2fUAxrPEMvdB250zxH0','C2XPy2u','y2fSy3vSyxrLqxzLCMfNzuv4zwn1DgLVBLrPBwu','z2v0ugfYyw1LDgvYu2nOzw1H','rvHfq1vusu5h','DxnHz2vdB3vUDa','y2XLyw51Ca','ntCWyvPzANzM','ugfYyw1LDgvYCYbTDxn0igjLigfUig9IAMvJDa','Bwf4q29Uy3vYCMvUDe9WzxjHDgLVBNm','AxnbC3LUyW','BMfTzq','zw5KC1DPDgG','zxjYB3i','zw5KvgLTzq','igLZigrPC2fIBgvK','C3rHCNruAw1L','C3vWCg9YDgvKqwn0Aw9UCW','mtbjtwnnC0G','zw5HyMXLza','C2vJCMv0CW','rMfPBgvKihrVigDLDcbKzxnJCMLWDgLVBIbMB3iGDg9VBdOG','su1qt1juqu5uoIb3AgvUigfZA2vKihrVihbLCMzVCM0Gyw4Gywn0Aw9Uig9Yig9WzxjHDgLVBIWGDxnLigvHy2GGCMvZCg9UC2uGDg8GAw52B2TLigeGDg9VBcbPzIbUzwvKzwqSigfUzcb1CgrHDguGDgHLihvZzxiGB24GDgHLihbYB2DYzxnZicHZyw1Lig1LC3nHz2uPlG','ywn0AxzLt3bLCMf0Aw9UCW'];a0_0x2cea=function(){return _0x43913f;};return a0_0x2cea();}function a0_0x5e6a(_0x1fbd7f,_0x40e05e){_0x1fbd7f=_0x1fbd7f-0x1cf;const _0x2ceab0=a0_0x2cea();let _0x5e6a26=_0x2ceab0[_0x1fbd7f];if(a0_0x5e6a['eSCRuS']===undefined){var _0x1bd0b4=function(_0x3ee6b3){const _0x46cae2='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x181af8='',_0x3e8586='';for(let _0x1b9452=0x0,_0x4644fd,_0x53c8e3,_0x482f46=0x0;_0x53c8e3=_0x3ee6b3['charAt'](_0x482f46++);~_0x53c8e3&&(_0x4644fd=_0x1b9452%0x4?_0x4644fd*0x40+_0x53c8e3:_0x53c8e3,_0x1b9452++%0x4)?_0x181af8+=String['fromCharCode'](0xff&_0x4644fd>>(-0x2*_0x1b9452&0x6)):0x0){_0x53c8e3=_0x46cae2['indexOf'](_0x53c8e3);}for(let _0xe07fa7=0x0,_0x110841=_0x181af8['length'];_0xe07fa7<_0x110841;_0xe07fa7++){_0x3e8586+='%'+('00'+_0x181af8['charCodeAt'](_0xe07fa7)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3e8586);};a0_0x5e6a['yqYOqC']=_0x1bd0b4,a0_0x5e6a['TPDciZ']={},a0_0x5e6a['eSCRuS']=!![];}const _0x2c1aa9=_0x2ceab0[0x0],_0x1d3006=_0x1fbd7f+_0x2c1aa9,_0x2c10ed=a0_0x5e6a['TPDciZ'][_0x1d3006];return!_0x2c10ed?(_0x5e6a26=a0_0x5e6a['yqYOqC'](_0x5e6a26),a0_0x5e6a['TPDciZ'][_0x1d3006]=_0x5e6a26):_0x5e6a26=_0x2c10ed,_0x5e6a26;}(function(_0x3ae6f4,_0x6551ce){const _0x28fa6e=a0_0x5e6a,_0x343291=_0x3ae6f4();while(!![]){try{const _0x1d67b4=parseInt(_0x28fa6e(0x231))/0x1*(parseInt(_0x28fa6e(0x1e4))/0x2)+-parseInt(_0x28fa6e(0x20c))/0x3+-parseInt(_0x28fa6e(0x246))/0x4*(parseInt(_0x28fa6e(0x233))/0x5)+-parseInt(_0x28fa6e(0x1eb))/0x6+-parseInt(_0x28fa6e(0x1cf))/0x7*(-parseInt(_0x28fa6e(0x237))/0x8)+-parseInt(_0x28fa6e(0x1f3))/0x9+-parseInt(_0x28fa6e(0x1d9))/0xa*(-parseInt(_0x28fa6e(0x20b))/0xb);if(_0x1d67b4===_0x6551ce)break;else _0x343291['push'](_0x343291['shift']());}catch(_0x124b4e){_0x343291['push'](_0x343291['shift']());}}}(a0_0x2cea,0x3ef20));import{TOOL_STATUS,OPERATION_STATUS,ERROR_TYPES,SYSTEM_DEFAULTS}from'../utilities/constants.js';class BaseTool{constructor(_0x181af8={},_0x3e8586=null){const _0x570752=a0_0x5e6a;this['id']=this[_0x570752(0x216)][_0x570752(0x1dd)][_0x570752(0x1fa)]()[_0x570752(0x1ee)]('tool',''),this[_0x570752(0x200)]=_0x181af8,this['logger']=_0x3e8586,this[_0x570752(0x21c)]=![],this['isAsync']=![],this['timeout']=_0x181af8['timeout']||SYSTEM_DEFAULTS[_0x570752(0x22b)],this['maxConcurrentOperations']=_0x181af8[_0x570752(0x1db)]||0x1,this['activeOperations']=new Map(),this[_0x570752(0x23f)]=[],this[_0x570752(0x238)]=_0x181af8[_0x570752(0x1e5)]!==![],this['lastUsed']=null,this[_0x570752(0x1d7)]=0x0;}['getDescription'](){const _0x27d551=a0_0x5e6a;throw new Error(_0x27d551(0x23e)+this['id']+'\x20must\x20implement\x20getDescription()');}['parseParameters'](_0x1b9452){throw new Error('Tool\x20'+this['id']+'\x20must\x20implement\x20parseParameters()');}async[a0_0x2a701a(0x21e)](_0x4644fd,_0x53c8e3){const _0x59f10b=a0_0x2a701a;throw new Error(_0x59f10b(0x23e)+this['id']+'\x20must\x20implement\x20execute()');}[a0_0x2a701a(0x1f2)](){const _0x323888=a0_0x2a701a;return{'id':this['id'],'async':this[_0x323888(0x1dc)],'requiresProject':this['requiresProject'],'timeout':this['timeout'],'maxConcurrentOperations':this['maxConcurrentOperations'],'enabled':this[_0x323888(0x238)],'supportedActions':this['getSupportedActions'](),'parameterSchema':this[_0x323888(0x1d5)]()};}[a0_0x2a701a(0x234)](_0x482f46){const _0x3702a8=a0_0x2a701a;try{if(!_0x482f46||typeof _0x482f46!=='object')return{'valid':![],'error':_0x3702a8(0x1da)};const requiredParams=this[_0x3702a8(0x1f1)]();for(const required of requiredParams){if(!(required in _0x482f46))return{'valid':![],'error':_0x3702a8(0x24e)+required};}const _0xe07fa7=this['validateParameterTypes'](_0x482f46);if(!_0xe07fa7['valid'])return _0xe07fa7;const _0x110841=this[_0x3702a8(0x1ed)](_0x482f46);if(!_0x110841[_0x3702a8(0x21a)])return _0x110841;return{'valid':!![]};}catch(_0x8bb48c){return{'valid':![],'error':_0x3702a8(0x241)+_0x8bb48c['message']};}}async[a0_0x2a701a(0x230)](_0x33a899,_0x49aaab){const _0x5dfeb6=a0_0x2a701a,_0x2b62e0=this[_0x5dfeb6(0x24d)](),_0x2c9ae0=Date['now']();if(!this['isEnabled'])throw new Error('Tool\x20'+this['id']+_0x5dfeb6(0x1e1));if(this['activeOperations']['size']>=this['maxConcurrentOperations'])throw new Error('Tool\x20'+this['id']+_0x5dfeb6(0x24f));const _0x57b534=this['validateParameters'](_0x33a899);if(!_0x57b534['valid'])throw new Error(_0x5dfeb6(0x241)+_0x57b534['error']);const _0x5ad226={'id':_0x2b62e0,'toolId':this['id'],'status':TOOL_STATUS[_0x5dfeb6(0x1d6)],'startTime':new Date()['toISOString'](),'params':_0x33a899,'context':this['sanitizeContext'](_0x49aaab)};this[_0x5dfeb6(0x1e9)][_0x5dfeb6(0x243)](_0x2b62e0,_0x5ad226);try{this['logger']?.[_0x5dfeb6(0x1ef)]('Tool\x20execution\x20started:\x20'+this['id'],{'operationId':_0x2b62e0,'toolId':this['id'],'context':_0x5ad226[_0x5dfeb6(0x21d)]});const _0xc9a465=await this['executeWithTimeout'](_0x33a899,_0x49aaab);return _0x5ad226['status']=TOOL_STATUS[_0x5dfeb6(0x203)],_0x5ad226['result']=_0xc9a465,_0x5ad226['endTime']=new Date()['toISOString'](),_0x5ad226[_0x5dfeb6(0x211)]=Date['now']()-_0x2c9ae0,this['lastUsed']=new Date()['toISOString'](),this['usageCount']++,this['logger']?.[_0x5dfeb6(0x1ef)]('Tool\x20execution\x20completed:\x20'+this['id'],{'operationId':_0x2b62e0,'executionTime':_0x5ad226['executionTime'],'success':!![]}),{'success':!![],'operationId':_0x2b62e0,'result':_0xc9a465,'executionTime':_0x5ad226['executionTime'],'toolId':this['id']};}catch(_0x212644){_0x5ad226['status']=TOOL_STATUS[_0x5dfeb6(0x22f)],_0x5ad226[_0x5dfeb6(0x1df)]=_0x212644['message'],_0x5ad226['endTime']=new Date()[_0x5dfeb6(0x236)](),_0x5ad226[_0x5dfeb6(0x211)]=Date[_0x5dfeb6(0x212)]()-_0x2c9ae0,this['logger']?.[_0x5dfeb6(0x1df)]('Tool\x20execution\x20failed:\x20'+this['id'],{'operationId':_0x2b62e0,'error':_0x212644['message'],'executionTime':_0x5ad226[_0x5dfeb6(0x211)]});throw _0x212644;}finally{this['operationHistory']['push']({..._0x5ad226}),this[_0x5dfeb6(0x1e9)][_0x5dfeb6(0x1f9)](_0x2b62e0),this[_0x5dfeb6(0x229)](),await this[_0x5dfeb6(0x1d8)](_0x2b62e0);}}async['getStatus'](_0x4233b9){const _0x46349e=a0_0x2a701a,_0x2ce568=this[_0x46349e(0x1e9)][_0x46349e(0x20d)](_0x4233b9);if(!_0x2ce568){const _0xd813c3=this[_0x46349e(0x23f)][_0x46349e(0x1d1)](_0x10cea3=>_0x10cea3['id']===_0x4233b9);if(_0xd813c3)return{'operationId':_0x4233b9,'status':_0xd813c3['status'],'result':_0xd813c3['result'],'error':_0xd813c3[_0x46349e(0x1df)],'executionTime':_0xd813c3['executionTime']};return{'operationId':_0x4233b9,'status':OPERATION_STATUS[_0x46349e(0x23a)],'error':_0x46349e(0x1f4)};}return{'operationId':_0x4233b9,'status':_0x2ce568['status'],'startTime':_0x2ce568[_0x46349e(0x1e2)],'executionTime':_0x2ce568[_0x46349e(0x1e0)]?new Date(_0x2ce568[_0x46349e(0x1e0)])[_0x46349e(0x225)]()-new Date(_0x2ce568['startTime'])[_0x46349e(0x225)]():Date[_0x46349e(0x212)]()-new Date(_0x2ce568['startTime'])['getTime']()};}async['cleanup'](_0x37aa3e){}['getSupportedActions'](){const _0x2c65a5=a0_0x2a701a;return[_0x2c65a5(0x21e)];}['getParameterSchema'](){return{'type':'object','properties':{},'required':[]};}[a0_0x2a701a(0x1f1)](){return[];}[a0_0x2a701a(0x240)](_0x1c9dab){return{'valid':!![]};}[a0_0x2a701a(0x1ed)](_0x136820){return{'valid':!![]};}async['executeWithTimeout'](_0x59eac3,_0x4f902c){return new Promise(async(_0x37f119,_0xad8e99)=>{const _0x523da4=a0_0x5e6a,_0x353b69=setTimeout(()=>{_0xad8e99(new Error('Tool\x20execution\x20timed\x20out\x20after\x20'+this['timeout']+'ms'));},this['timeout']);try{const _0x198bfa=await this[_0x523da4(0x21e)](_0x59eac3,_0x4f902c);clearTimeout(_0x353b69),_0x37f119(_0x198bfa);}catch(_0x50d0f9){clearTimeout(_0x353b69),_0xad8e99(_0x50d0f9);}});}['generateOperationId'](){const _0x185558=a0_0x2a701a;return this['id']+'-'+Date['now']()+'-'+Math['random']()[_0x185558(0x201)](0x24)[_0x185558(0x1f6)](0x2,0x9);}[a0_0x2a701a(0x1d2)](_0x409080){const _0x10b622=a0_0x2a701a,_0x17f4ff={..._0x409080};return delete _0x17f4ff['apiKeys'],delete _0x17f4ff[_0x10b622(0x1e6)],delete _0x17f4ff['passwords'],_0x17f4ff[_0x10b622(0x220)]&&_0x17f4ff['content'][_0x10b622(0x1ec)]>0x1f4&&(_0x17f4ff[_0x10b622(0x220)]=_0x17f4ff[_0x10b622(0x220)][_0x10b622(0x1fd)](0x0,0x1f4)+'...\x20[truncated]'),_0x17f4ff;}['cleanupHistory'](){const _0x4b6674=a0_0x2a701a,_0x521ca9=0x64;this[_0x4b6674(0x23f)][_0x4b6674(0x1ec)]>_0x521ca9&&(this['operationHistory']=this['operationHistory'][_0x4b6674(0x1d3)](-_0x521ca9));}[a0_0x2a701a(0x21f)](){const _0x4ff097=a0_0x2a701a;return{'toolId':this['id'],'usageCount':this['usageCount'],'lastUsed':this[_0x4ff097(0x226)],'activeOperations':this['activeOperations']['size'],'totalOperations':this[_0x4ff097(0x23f)][_0x4ff097(0x1ec)],'averageExecutionTime':this[_0x4ff097(0x1d4)](),'successRate':this['calculateSuccessRate'](),'isEnabled':this['isEnabled']};}[a0_0x2a701a(0x1d4)](){const _0x3ee6fa=a0_0x2a701a,_0x5ff78f=this['operationHistory'][_0x3ee6fa(0x213)](_0x482d92=>_0x482d92['status']===TOOL_STATUS['COMPLETED']&&_0x482d92['executionTime']);if(_0x5ff78f['length']===0x0)return 0x0;const _0x1369a0=_0x5ff78f['reduce']((_0x2b8963,_0x11427b)=>_0x2b8963+_0x11427b['executionTime'],0x0);return Math['round'](_0x1369a0/_0x5ff78f[_0x3ee6fa(0x1ec)]);}[a0_0x2a701a(0x215)](){const _0x43b3e3=a0_0x2a701a;if(this[_0x43b3e3(0x23f)][_0x43b3e3(0x1ec)]===0x0)return 0x0;const _0x2a9bab=this['operationHistory']['filter'](_0x13639d=>_0x13639d[_0x43b3e3(0x1ff)]===TOOL_STATUS['COMPLETED']);return _0x2a9bab[_0x43b3e3(0x1ec)]/this[_0x43b3e3(0x23f)]['length']*0x64;}['enable'](){const _0x55a521=a0_0x2a701a;this['isEnabled']=!![],this[_0x55a521(0x219)]?.['info'](_0x55a521(0x202)+this['id']);}[a0_0x2a701a(0x1f7)](){const _0x1bbc5d=a0_0x2a701a;this[_0x1bbc5d(0x238)]=![],this['logger']?.['info']('Tool\x20disabled:\x20'+this['id']);}[a0_0x2a701a(0x242)](){const _0x59a875=a0_0x2a701a;this[_0x59a875(0x1d7)]=0x0,this['lastUsed']=null,this['operationHistory']=[],this[_0x59a875(0x219)]?.['info'](_0x59a875(0x20a)+this['id']);}}class ToolsRegistry{constructor(_0x46f8c5=null){const _0x27ffeb=a0_0x2a701a;this['logger']=_0x46f8c5,this['tools']=new Map(),this['toolDescriptions']=new Map(),this[_0x27ffeb(0x22e)]=new Map(),this['asyncOperations']=new Map();}async['registerTool'](_0x145683){const _0x258b43=a0_0x2a701a;try{const _0x46ce21=new _0x145683();if(!(_0x46ce21 instanceof BaseTool))throw new Error('Tool\x20'+_0x145683[_0x258b43(0x1dd)]+_0x258b43(0x1d0));const _0xabda3f=_0x46ce21[_0x258b43(0x1f2)]();await this[_0x258b43(0x239)](_0x46ce21),this[_0x258b43(0x20f)]['set'](_0x46ce21['id'],_0x46ce21),this['toolDescriptions'][_0x258b43(0x243)](_0x46ce21['id'],_0x46ce21['getDescription']()),this[_0x258b43(0x22e)][_0x258b43(0x243)](_0x46ce21['id'],_0xabda3f),this['logger']?.[_0x258b43(0x1ef)](_0x258b43(0x1fb)+_0x46ce21['id'],{'capabilities':_0xabda3f['supportedActions'],'async':_0xabda3f[_0x258b43(0x204)],'requiresProject':_0xabda3f[_0x258b43(0x21c)]});}catch(_0x448bd4){this['logger']?.[_0x258b43(0x1df)]('Tool\x20registration\x20failed:\x20'+_0x448bd4[_0x258b43(0x235)],{'toolClass':_0x145683[_0x258b43(0x1dd)]});throw _0x448bd4;}}async['discoverTools'](_0x5b6129){return 0x0;}async[a0_0x2a701a(0x239)](_0x234db8){const _0x51ba9d=a0_0x2a701a,requiredMethods=[_0x51ba9d(0x218),_0x51ba9d(0x232),'execute'];for(const _0x187b50 of requiredMethods){if(typeof _0x234db8[_0x187b50]!==_0x51ba9d(0x224))throw new Error('Tool\x20'+_0x234db8['id']+'\x20missing\x20required\x20method:\x20'+_0x187b50);}try{const _0x1bb962=_0x234db8['parseParameters']('test\x20content');if(typeof _0x1bb962!=='object')throw new Error(_0x51ba9d(0x23e)+_0x234db8['id']+_0x51ba9d(0x209));}catch(_0x150bca){}const _0x577426=_0x234db8['getCapabilities']();if(!_0x577426||typeof _0x577426!=='object')throw new Error('Tool\x20'+_0x234db8['id']+_0x51ba9d(0x23b));}['getTool'](_0x1878d1){const _0x501026=a0_0x2a701a;return this[_0x501026(0x20f)]['get'](_0x1878d1)||null;}['getToolCapabilities'](){const _0x32224d=a0_0x2a701a,_0xf4a954={};for(const [_0x1bc28e,_0x1b7fa4]of this['tools']['entries']()){_0x1b7fa4['isEnabled']&&(_0xf4a954[_0x1bc28e]={'description':this[_0x32224d(0x20e)][_0x32224d(0x20d)](_0x1bc28e),'capabilities':this['toolCapabilities']['get'](_0x1bc28e),'usageStats':_0x1b7fa4['getUsageStats']()});}return _0xf4a954;}async[a0_0x2a701a(0x207)](_0x4c7032,_0x5d22de,_0x157d28){const _0x38efc6=a0_0x2a701a,_0x6f6a9=this['getTool'](_0x4c7032);if(!_0x6f6a9)throw new Error(_0x38efc6(0x1f8)+_0x4c7032);if(!_0x6f6a9['isEnabled'])throw new Error('Tool\x20is\x20disabled:\x20'+_0x4c7032);return await _0x6f6a9['executeWithLifecycle'](_0x5d22de,_0x157d28);}['listTools'](){const _0x5b6de0=a0_0x2a701a;return Array['from'](this[_0x5b6de0(0x20f)]['keys']());}['generateToolDescriptionsForPrompt'](_0x529691=[],_0x12e609={}){const _0xae4230=a0_0x2a701a,{includeExamples:includeExamples=!![],includeUsageGuidelines:includeUsageGuidelines=!![],includeSecurityNotes:includeSecurityNotes=!![],compact:compact=![]}=_0x12e609,_0x54fa51=_0x529691[_0xae4230(0x1ec)]>0x0?_0x529691[_0xae4230(0x213)](_0x1bf2a9=>this[_0xae4230(0x20f)][_0xae4230(0x206)](_0x1bf2a9)):Array['from'](this[_0xae4230(0x20f)][_0xae4230(0x24c)]());if(_0x54fa51['length']===0x0)return'';let _0x4ae7a2='\x0a##\x20AVAILABLE\x20TOOLS\x0a\x0a';_0x4ae7a2+=_0xae4230(0x1ea);for(const _0x5db326 of _0x54fa51){const _0x547de9=this[_0xae4230(0x20f)]['get'](_0x5db326);if(!_0x547de9||!_0x547de9['isEnabled'])continue;try{if(compact){const _0x23bfa8=_0x547de9[_0xae4230(0x1f2)](),_0x142656=_0x23bfa8[_0xae4230(0x1e3)]||[_0xae4230(0x21e)];_0x4ae7a2+='**'+_0x5db326+_0xae4230(0x223)+_0x142656['join'](',\x20')+'\x0a';}else _0x4ae7a2+=_0xae4230(0x22c)+_0x5db326[_0xae4230(0x228)]()+_0xae4230(0x1fc),_0x4ae7a2+=_0x547de9['getDescription'](),_0x4ae7a2+='\x0a\x0a---\x0a\x0a';}catch(_0x4e9d25){this['logger']?.['warn'](_0xae4230(0x1e7)+_0x5db326,{'error':_0x4e9d25['message']});}}return compact&&(_0x4ae7a2+='\x0aUse\x20[tool\x20id=\x22tool-name\x22]<parameters>[/tool]\x20or\x20JSON\x20format\x20to\x20invoke\x20tools.\x0a\x0a'),_0x4ae7a2+=_0xae4230(0x1f5),_0x4ae7a2+=_0xae4230(0x222),_0x4ae7a2+='###\x20Format\x201:\x20Bracket\x20Notation\x0a',_0x4ae7a2+=_0xae4230(0x221),_0x4ae7a2+='[tool\x20id=\x22toolname\x22]\x0a',_0x4ae7a2+='<parameters\x20here>\x0a',_0x4ae7a2+='[/tool]\x0a',_0x4ae7a2+='```\x0a\x0a',_0x4ae7a2+='###\x20Format\x202:\x20JSON\x20in\x20Markdown\x20Code\x20Block\x20(REQUIRED\x20for\x20JSON)\x0a',_0x4ae7a2+='```\x0a',_0x4ae7a2+=_0xae4230(0x1fe),_0x4ae7a2+='{\x0a',_0x4ae7a2+=_0xae4230(0x248),_0x4ae7a2+='\x20\x20\x22parameters\x22:\x20{\x20...\x20}\x20or\x20\x22actions\x22:\x20[\x20...\x20]\x0a',_0x4ae7a2+='}\x0a',_0x4ae7a2+='```\x0a',_0x4ae7a2+=_0xae4230(0x24b),_0x4ae7a2+='**WARNING**:\x20Plain\x20JSON\x20without\x20markdown\x20code\x20blocks\x20(```json)\x20will\x20NOT\x20be\x20executed!\x0a',_0x4ae7a2+='Always\x20wrap\x20JSON\x20tool\x20commands\x20in\x20```json\x20...\x20```\x20blocks.\x0a\x0a',_0x4ae7a2+=_0xae4230(0x23d),_0x4ae7a2+=_0xae4230(0x247),_0x4ae7a2+=_0xae4230(0x22a),_0x4ae7a2+=_0xae4230(0x210),_0x4ae7a2+='\x20\x20\x20\x20<parameter>value</parameter>\x0a',_0x4ae7a2+='\x20\x20</tool>\x0a',_0x4ae7a2+='</tool-command>\x0a',_0x4ae7a2+=_0xae4230(0x24b),_0x4ae7a2+='After\x20invoking\x20a\x20tool,\x20WAIT\x20for\x20the\x20actual\x20response.\x20Do\x20NOT\x20generate\x20imaginary\x20responses.\x0a',_0x4ae7a2;}['enhanceSystemPrompt'](_0x86f4d0,_0x223aae=[],_0x354fc6={}){const _0xd2a83f=a0_0x2a701a,_0x457e2f=this['generateToolDescriptionsForPrompt'](_0x223aae,_0x354fc6);if(!_0x457e2f['trim']())return _0x86f4d0||'';const _0x527852=_0x86f4d0||'';if(_0x527852['includes'](_0xd2a83f(0x245)))return _0x527852['replace'](/## AVAILABLE TOOLS[\s\S]*?(?=##|$)/,_0x457e2f+'\x0a');const _0x3a97d1=_0xd2a83f(0x1e8);return _0x527852+(_0x527852[_0xd2a83f(0x1de)]('\x0a')?'':'\x0a')+_0x457e2f+_0x3a97d1+'\x0a';}['getAvailableToolsForUI'](){const _0x88908c=a0_0x2a701a,_0x465a99=[];for(const [_0x35cf9d,_0x676019]of this[_0x88908c(0x20f)]['entries']()){const _0x548f02=_0x676019[_0x88908c(0x1f2)](),_0x59dd17=_0x676019['getDescription'](),_0x369f2c=_0x59dd17['split']('\x0a')[_0x88908c(0x1d1)](_0x2b6c16=>_0x2b6c16[_0x88908c(0x217)]()['length']>0x0)||'',_0x1097d5=_0x369f2c[_0x88908c(0x1ee)](/^.*Tool:\s*/i,'')[_0x88908c(0x1ee)](/\s*-.*$/,'')['trim']();_0x465a99[_0x88908c(0x244)]({'id':_0x35cf9d,'name':_0x1097d5||_0x35cf9d['charAt'](0x0)[_0x88908c(0x228)]()+_0x35cf9d[_0x88908c(0x1d3)](0x1),'description':_0x369f2c,'category':this[_0x88908c(0x1f0)](_0x35cf9d),'enabled':_0x548f02[_0x88908c(0x1e5)],'async':_0x548f02[_0x88908c(0x204)],'requiresProject':_0x548f02['requiresProject'],'className':_0x676019['constructor']['name']});}return _0x465a99['sort']((_0x5b2404,_0x52887f)=>_0x5b2404['name'][_0x88908c(0x249)](_0x52887f['name']));}['_getToolCategory'](_0x503f8c){const _0x445faa=a0_0x2a701a,_0x5d8c3c={'terminal':_0x445faa(0x214),'filesystem':'File\x20Operations','browser':_0x445faa(0x21b),'agentdelay':'Utility'};return _0x5d8c3c[_0x503f8c]||_0x445faa(0x24a);}[a0_0x2a701a(0x227)](){const _0x469982=a0_0x2a701a,_0x45e2a1=Array[_0x469982(0x208)](this[_0x469982(0x20f)]['values']())['filter'](_0x2211e6=>_0x2211e6['isEnabled']),_0x5d84dc=Array['from'](this['tools']['values']())[_0x469982(0x23c)]((_0x35ff73,_0x4b8976)=>_0x35ff73+_0x4b8976['usageCount'],0x0);return{'totalTools':this['tools']['size'],'enabledTools':_0x45e2a1['length'],'totalOperations':_0x5d84dc,'activeOperations':this[_0x469982(0x22d)][_0x469982(0x205)]};}}export{BaseTool,ToolsRegistry};
|