@loxia-labs/loxia-autopilot-one 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +44 -54
  2. package/bin/cli.js +1 -115
  3. package/bin/loxia-terminal-v2.js +3 -0
  4. package/bin/loxia-terminal.js +3 -0
  5. package/bin/start-with-terminal.js +3 -0
  6. package/package.json +14 -15
  7. package/scripts/install-scanners.js +1 -235
  8. package/src/analyzers/CSSAnalyzer.js +1 -297
  9. package/src/analyzers/ConfigValidator.js +1 -690
  10. package/src/analyzers/ESLintAnalyzer.js +1 -320
  11. package/src/analyzers/JavaScriptAnalyzer.js +1 -261
  12. package/src/analyzers/PrettierFormatter.js +1 -247
  13. package/src/analyzers/PythonAnalyzer.js +1 -266
  14. package/src/analyzers/SecurityAnalyzer.js +1 -729
  15. package/src/analyzers/TypeScriptAnalyzer.js +1 -247
  16. package/src/analyzers/codeCloneDetector/analyzer.js +1 -344
  17. package/src/analyzers/codeCloneDetector/detector.js +1 -203
  18. package/src/analyzers/codeCloneDetector/index.js +1 -160
  19. package/src/analyzers/codeCloneDetector/parser.js +1 -199
  20. package/src/analyzers/codeCloneDetector/reporter.js +1 -148
  21. package/src/analyzers/codeCloneDetector/scanner.js +1 -59
  22. package/src/core/agentPool.js +1 -1474
  23. package/src/core/agentScheduler.js +1 -2147
  24. package/src/core/contextManager.js +1 -709
  25. package/src/core/messageProcessor.js +1 -732
  26. package/src/core/orchestrator.js +1 -548
  27. package/src/core/stateManager.js +1 -877
  28. package/src/index.js +1 -631
  29. package/src/interfaces/cli.js +1 -549
  30. package/src/interfaces/terminal/__tests__/smoke/advancedFeatures.test.js +1 -0
  31. package/src/interfaces/terminal/__tests__/smoke/agentControl.test.js +1 -0
  32. package/src/interfaces/terminal/__tests__/smoke/agents.test.js +1 -0
  33. package/src/interfaces/terminal/__tests__/smoke/components.test.js +1 -0
  34. package/src/interfaces/terminal/__tests__/smoke/connection.test.js +1 -0
  35. package/src/interfaces/terminal/__tests__/smoke/enhancements.test.js +1 -0
  36. package/src/interfaces/terminal/__tests__/smoke/imports.test.js +1 -0
  37. package/src/interfaces/terminal/__tests__/smoke/messages.test.js +1 -0
  38. package/src/interfaces/terminal/__tests__/smoke/tools.test.js +1 -0
  39. package/src/interfaces/terminal/api/apiClient.js +1 -0
  40. package/src/interfaces/terminal/api/messageRouter.js +1 -0
  41. package/src/interfaces/terminal/api/session.js +1 -0
  42. package/src/interfaces/terminal/api/websocket.js +1 -0
  43. package/src/interfaces/terminal/components/AgentCreator.js +1 -0
  44. package/src/interfaces/terminal/components/AgentEditor.js +1 -0
  45. package/src/interfaces/terminal/components/AgentSwitcher.js +1 -0
  46. package/src/interfaces/terminal/components/ErrorBoundary.js +1 -0
  47. package/src/interfaces/terminal/components/ErrorPanel.js +1 -0
  48. package/src/interfaces/terminal/components/Header.js +1 -0
  49. package/src/interfaces/terminal/components/HelpPanel.js +1 -0
  50. package/src/interfaces/terminal/components/InputBox.js +1 -0
  51. package/src/interfaces/terminal/components/Layout.js +1 -0
  52. package/src/interfaces/terminal/components/LoadingSpinner.js +1 -0
  53. package/src/interfaces/terminal/components/MessageList.js +1 -0
  54. package/src/interfaces/terminal/components/MultilineTextInput.js +1 -0
  55. package/src/interfaces/terminal/components/SearchPanel.js +1 -0
  56. package/src/interfaces/terminal/components/SettingsPanel.js +1 -0
  57. package/src/interfaces/terminal/components/StatusBar.js +1 -0
  58. package/src/interfaces/terminal/components/TextInput.js +1 -0
  59. package/src/interfaces/terminal/config/agentEditorConstants.js +1 -0
  60. package/src/interfaces/terminal/config/constants.js +1 -0
  61. package/src/interfaces/terminal/index.js +1 -0
  62. package/src/interfaces/terminal/state/useAgentControl.js +1 -0
  63. package/src/interfaces/terminal/state/useAgents.js +1 -0
  64. package/src/interfaces/terminal/state/useConnection.js +1 -0
  65. package/src/interfaces/terminal/state/useMessages.js +1 -0
  66. package/src/interfaces/terminal/state/useTools.js +1 -0
  67. package/src/interfaces/terminal/utils/debugLogger.js +1 -0
  68. package/src/interfaces/terminal/utils/settingsStorage.js +1 -0
  69. package/src/interfaces/terminal/utils/theme.js +1 -0
  70. package/src/interfaces/webServer.js +1 -2162
  71. package/src/modules/fileExplorer/controller.js +1 -280
  72. package/src/modules/fileExplorer/index.js +1 -37
  73. package/src/modules/fileExplorer/middleware.js +1 -92
  74. package/src/modules/fileExplorer/routes.js +1 -125
  75. package/src/modules/fileExplorer/types.js +1 -44
  76. package/src/services/aiService.js +1 -1232
  77. package/src/services/apiKeyManager.js +1 -164
  78. package/src/services/benchmarkService.js +1 -366
  79. package/src/services/budgetService.js +1 -539
  80. package/src/services/contextInjectionService.js +1 -247
  81. package/src/services/conversationCompactionService.js +1 -637
  82. package/src/services/errorHandler.js +1 -810
  83. package/src/services/fileAttachmentService.js +1 -544
  84. package/src/services/modelRouterService.js +1 -366
  85. package/src/services/modelsService.js +1 -322
  86. package/src/services/qualityInspector.js +1 -796
  87. package/src/services/tokenCountingService.js +1 -536
  88. package/src/tools/agentCommunicationTool.js +1 -1344
  89. package/src/tools/agentDelayTool.js +1 -485
  90. package/src/tools/asyncToolManager.js +1 -604
  91. package/src/tools/baseTool.js +1 -800
  92. package/src/tools/browserTool.js +1 -920
  93. package/src/tools/cloneDetectionTool.js +1 -621
  94. package/src/tools/dependencyResolverTool.js +1 -1215
  95. package/src/tools/fileContentReplaceTool.js +1 -875
  96. package/src/tools/fileSystemTool.js +1 -1107
  97. package/src/tools/fileTreeTool.js +1 -853
  98. package/src/tools/imageTool.js +1 -901
  99. package/src/tools/importAnalyzerTool.js +1 -1060
  100. package/src/tools/jobDoneTool.js +1 -248
  101. package/src/tools/seekTool.js +1 -956
  102. package/src/tools/staticAnalysisTool.js +1 -1778
  103. package/src/tools/taskManagerTool.js +1 -2873
  104. package/src/tools/terminalTool.js +1 -2304
  105. package/src/tools/webTool.js +1 -1430
  106. package/src/types/agent.js +1 -519
  107. package/src/types/contextReference.js +1 -972
  108. package/src/types/conversation.js +1 -730
  109. package/src/types/toolCommand.js +1 -747
  110. package/src/utilities/attachmentValidator.js +1 -292
  111. package/src/utilities/configManager.js +1 -582
  112. package/src/utilities/constants.js +1 -722
  113. package/src/utilities/directoryAccessManager.js +1 -535
  114. package/src/utilities/fileProcessor.js +1 -307
  115. package/src/utilities/logger.js +1 -436
  116. package/src/utilities/tagParser.js +1 -1246
  117. package/src/utilities/toolConstants.js +1 -317
  118. package/web-ui/build/index.html +2 -2
  119. package/web-ui/build/static/{index-Dy2bYbOa.css → index-CClD1090.css} +1 -1
  120. package/web-ui/build/static/{index-CjkkcnFA.js → index-lCBai6dX.js} +66 -67
@@ -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_0xd8f2b7=a0_0x4677;(function(_0x4619c8,_0xfefa44){const _0x278202=a0_0x4677,_0x4f8c8b=_0x4619c8();while(!![]){try{const _0x37984a=-parseInt(_0x278202(0x241))/0x1+parseInt(_0x278202(0x25f))/0x2+parseInt(_0x278202(0x1f0))/0x3*(parseInt(_0x278202(0x249))/0x4)+-parseInt(_0x278202(0x1ee))/0x5*(parseInt(_0x278202(0x1f5))/0x6)+-parseInt(_0x278202(0x22c))/0x7+-parseInt(_0x278202(0x1e9))/0x8*(parseInt(_0x278202(0x25c))/0x9)+parseInt(_0x278202(0x1ff))/0xa;if(_0x37984a===_0xfefa44)break;else _0x4f8c8b['push'](_0x4f8c8b['shift']());}catch(_0x477492){_0x4f8c8b['push'](_0x4f8c8b['shift']());}}}(a0_0x499d,0x3d4db));import{TOOL_STATUS,OPERATION_STATUS,ERROR_TYPES,SYSTEM_DEFAULTS}from'../utilities/constants.js';class BaseTool{constructor(_0x11d65a={},_0x1df1c6=null){const _0x1e116b=a0_0x4677;this['id']=this[_0x1e116b(0x214)]['name']['toLowerCase']()[_0x1e116b(0x24f)](_0x1e116b(0x1e8),''),this[_0x1e116b(0x238)]=_0x11d65a,this[_0x1e116b(0x252)]=_0x1df1c6,this[_0x1e116b(0x259)]=![],this['isAsync']=![],this[_0x1e116b(0x205)]=_0x11d65a['timeout']||SYSTEM_DEFAULTS['MAX_TOOL_EXECUTION_TIME'],this[_0x1e116b(0x222)]=_0x11d65a[_0x1e116b(0x222)]||0x1,this[_0x1e116b(0x1e6)]=new Map(),this['operationHistory']=[],this['isEnabled']=_0x11d65a[_0x1e116b(0x240)]!==![],this[_0x1e116b(0x250)]=null,this['usageCount']=0x0;}[a0_0xd8f2b7(0x21c)](){const _0x28f815=a0_0xd8f2b7;throw new Error(_0x28f815(0x200)+this['id']+'\x20must\x20implement\x20getDescription()');}[a0_0xd8f2b7(0x242)](_0x23bd6b){const _0x14b83b=a0_0xd8f2b7;throw new Error(_0x14b83b(0x200)+this['id']+_0x14b83b(0x229));}async['execute'](_0x169d47,_0x4553f9){throw new Error('Tool\x20'+this['id']+'\x20must\x20implement\x20execute()');}['getCapabilities'](){const _0x7d1681=a0_0xd8f2b7;return{'id':this['id'],'async':this[_0x7d1681(0x256)],'requiresProject':this['requiresProject'],'timeout':this[_0x7d1681(0x205)],'maxConcurrentOperations':this['maxConcurrentOperations'],'enabled':this['isEnabled'],'supportedActions':this[_0x7d1681(0x263)](),'parameterSchema':this[_0x7d1681(0x21f)]()};}[a0_0xd8f2b7(0x20a)](_0x4f80cc){const _0x3f85e2=a0_0xd8f2b7;try{if(!_0x4f80cc||typeof _0x4f80cc!=='object')return{'valid':![],'error':_0x3f85e2(0x26a)};const requiredParams=this['getRequiredParameters']();for(const required of requiredParams){if(!(required in _0x4f80cc))return{'valid':![],'error':_0x3f85e2(0x267)+required};}const _0x4f0ca5=this['validateParameterTypes'](_0x4f80cc);if(!_0x4f0ca5[_0x3f85e2(0x247)])return _0x4f0ca5;const _0x1879ef=this[_0x3f85e2(0x21a)](_0x4f80cc);if(!_0x1879ef[_0x3f85e2(0x247)])return _0x1879ef;return{'valid':!![]};}catch(_0x8a68fa){return{'valid':![],'error':_0x3f85e2(0x1e7)+_0x8a68fa['message']};}}async['executeWithLifecycle'](_0x7526f4,_0x1d872c){const _0x459130=a0_0xd8f2b7,_0x5b916f=this[_0x459130(0x23a)](),_0x3ed533=Date[_0x459130(0x22a)]();if(!this['isEnabled'])throw new Error('Tool\x20'+this['id']+'\x20is\x20disabled');if(this['activeOperations'][_0x459130(0x266)]>=this['maxConcurrentOperations'])throw new Error('Tool\x20'+this['id']+_0x459130(0x20b));const _0x306a66=this['validateParameters'](_0x7526f4);if(!_0x306a66[_0x459130(0x247)])throw new Error('Parameter\x20validation\x20failed:\x20'+_0x306a66[_0x459130(0x236)]);const _0x899c2f={'id':_0x5b916f,'toolId':this['id'],'status':TOOL_STATUS['EXECUTING'],'startTime':new Date()[_0x459130(0x228)](),'params':_0x7526f4,'context':this['sanitizeContext'](_0x1d872c)};this[_0x459130(0x1e6)][_0x459130(0x1f3)](_0x5b916f,_0x899c2f);try{this[_0x459130(0x252)]?.['info']('Tool\x20execution\x20started:\x20'+this['id'],{'operationId':_0x5b916f,'toolId':this['id'],'context':_0x899c2f[_0x459130(0x212)]});const _0x1896a7=await this[_0x459130(0x1f1)](_0x7526f4,_0x1d872c);return _0x899c2f[_0x459130(0x227)]=TOOL_STATUS[_0x459130(0x244)],_0x899c2f['result']=_0x1896a7,_0x899c2f[_0x459130(0x20e)]=new Date()[_0x459130(0x228)](),_0x899c2f['executionTime']=Date[_0x459130(0x22a)]()-_0x3ed533,this['lastUsed']=new Date()[_0x459130(0x228)](),this['usageCount']++,this['logger']?.[_0x459130(0x25d)](_0x459130(0x264)+this['id'],{'operationId':_0x5b916f,'executionTime':_0x899c2f['executionTime'],'success':!![]}),{'success':!![],'operationId':_0x5b916f,'result':_0x1896a7,'executionTime':_0x899c2f[_0x459130(0x209)],'toolId':this['id']};}catch(_0x4dbe41){_0x899c2f[_0x459130(0x227)]=TOOL_STATUS[_0x459130(0x260)],_0x899c2f['error']=_0x4dbe41['message'],_0x899c2f[_0x459130(0x20e)]=new Date()[_0x459130(0x228)](),_0x899c2f[_0x459130(0x209)]=Date['now']()-_0x3ed533,this['logger']?.['error'](_0x459130(0x232)+this['id'],{'operationId':_0x5b916f,'error':_0x4dbe41['message'],'executionTime':_0x899c2f[_0x459130(0x209)]});throw _0x4dbe41;}finally{this[_0x459130(0x254)]['push']({..._0x899c2f}),this[_0x459130(0x1e6)]['delete'](_0x5b916f),this[_0x459130(0x217)](),await this['cleanup'](_0x5b916f);}}async['getStatus'](_0x23021b){const _0x2b55a8=a0_0xd8f2b7,_0x2879e0=this[_0x2b55a8(0x1e6)][_0x2b55a8(0x258)](_0x23021b);if(!_0x2879e0){const _0x4fe1bc=this[_0x2b55a8(0x254)][_0x2b55a8(0x1f7)](_0x223606=>_0x223606['id']===_0x23021b);if(_0x4fe1bc)return{'operationId':_0x23021b,'status':_0x4fe1bc[_0x2b55a8(0x227)],'result':_0x4fe1bc[_0x2b55a8(0x22d)],'error':_0x4fe1bc['error'],'executionTime':_0x4fe1bc[_0x2b55a8(0x209)]};return{'operationId':_0x23021b,'status':OPERATION_STATUS[_0x2b55a8(0x1e5)],'error':_0x2b55a8(0x25a)};}return{'operationId':_0x23021b,'status':_0x2879e0['status'],'startTime':_0x2879e0['startTime'],'executionTime':_0x2879e0[_0x2b55a8(0x20e)]?new Date(_0x2879e0[_0x2b55a8(0x20e)])['getTime']()-new Date(_0x2879e0['startTime'])['getTime']():Date['now']()-new Date(_0x2879e0[_0x2b55a8(0x223)])['getTime']()};}async[a0_0xd8f2b7(0x24a)](_0xa2b8b){}['getSupportedActions'](){const _0x35d5e9=a0_0xd8f2b7;return[_0x35d5e9(0x1f8)];}[a0_0xd8f2b7(0x21f)](){return{'type':'object','properties':{},'required':[]};}['getRequiredParameters'](){return[];}['validateParameterTypes'](_0x4c41c8){return{'valid':!![]};}['customValidateParameters'](_0x5e1f9c){return{'valid':!![]};}async['executeWithTimeout'](_0x4f9ba9,_0x54a029){return new Promise(async(_0x356491,_0xb3353c)=>{const _0x285be7=setTimeout(()=>{const _0x1149ea=a0_0x4677;_0xb3353c(new Error(_0x1149ea(0x1fa)+this['timeout']+'ms'));},this['timeout']);try{const _0x21bdfd=await this['execute'](_0x4f9ba9,_0x54a029);clearTimeout(_0x285be7),_0x356491(_0x21bdfd);}catch(_0x2894fe){clearTimeout(_0x285be7),_0xb3353c(_0x2894fe);}});}['generateOperationId'](){const _0x35eb75=a0_0xd8f2b7;return this['id']+'-'+Date[_0x35eb75(0x22a)]()+'-'+Math[_0x35eb75(0x231)]()['toString'](0x24)[_0x35eb75(0x251)](0x2,0x9);}[a0_0xd8f2b7(0x230)](_0x4eef31){const _0x3d4772=a0_0xd8f2b7,_0x1044c8={..._0x4eef31};return delete _0x1044c8[_0x3d4772(0x204)],delete _0x1044c8['secrets'],delete _0x1044c8['passwords'],_0x1044c8[_0x3d4772(0x20f)]&&_0x1044c8['content'][_0x3d4772(0x1e4)]>0x1f4&&(_0x1044c8['content']=_0x1044c8[_0x3d4772(0x20f)][_0x3d4772(0x22e)](0x0,0x1f4)+_0x3d4772(0x220)),_0x1044c8;}[a0_0xd8f2b7(0x217)](){const _0x57a196=a0_0xd8f2b7,_0x107e92=0x64;this[_0x57a196(0x254)][_0x57a196(0x1e4)]>_0x107e92&&(this[_0x57a196(0x254)]=this['operationHistory']['slice'](-_0x107e92));}[a0_0xd8f2b7(0x201)](){const _0x3b7daf=a0_0xd8f2b7;return{'toolId':this['id'],'usageCount':this['usageCount'],'lastUsed':this['lastUsed'],'activeOperations':this['activeOperations'][_0x3b7daf(0x266)],'totalOperations':this['operationHistory'][_0x3b7daf(0x1e4)],'averageExecutionTime':this[_0x3b7daf(0x257)](),'successRate':this['calculateSuccessRate'](),'isEnabled':this[_0x3b7daf(0x25b)]};}['calculateAverageExecutionTime'](){const _0x148817=a0_0xd8f2b7,_0x342058=this[_0x148817(0x254)][_0x148817(0x22b)](_0x7081a8=>_0x7081a8['status']===TOOL_STATUS['COMPLETED']&&_0x7081a8[_0x148817(0x209)]);if(_0x342058[_0x148817(0x1e4)]===0x0)return 0x0;const _0x37e809=_0x342058['reduce']((_0x298473,_0x57228c)=>_0x298473+_0x57228c[_0x148817(0x209)],0x0);return Math['round'](_0x37e809/_0x342058[_0x148817(0x1e4)]);}[a0_0xd8f2b7(0x1f2)](){const _0x49b8b9=a0_0xd8f2b7;if(this['operationHistory']['length']===0x0)return 0x0;const _0x1f5199=this['operationHistory']['filter'](_0x140e45=>_0x140e45['status']===TOOL_STATUS[_0x49b8b9(0x244)]);return _0x1f5199[_0x49b8b9(0x1e4)]/this['operationHistory']['length']*0x64;}[a0_0xd8f2b7(0x255)](){const _0x8e1e26=a0_0xd8f2b7;this[_0x8e1e26(0x25b)]=!![],this['logger']?.['info'](_0x8e1e26(0x234)+this['id']);}['disable'](){const _0x4af0f0=a0_0xd8f2b7;this['isEnabled']=![],this[_0x4af0f0(0x252)]?.[_0x4af0f0(0x25d)]('Tool\x20disabled:\x20'+this['id']);}[a0_0xd8f2b7(0x261)](){const _0xaf8395=a0_0xd8f2b7;this['usageCount']=0x0,this['lastUsed']=null,this['operationHistory']=[],this[_0xaf8395(0x252)]?.['info']('Tool\x20statistics\x20reset:\x20'+this['id']);}}class ToolsRegistry{constructor(_0x5b7a5d=null){const _0x1a66cb=a0_0xd8f2b7;this['logger']=_0x5b7a5d,this[_0x1a66cb(0x239)]=new Map(),this['toolDescriptions']=new Map(),this['toolCapabilities']=new Map(),this['asyncOperations']=new Map();}async['registerTool'](_0x3e7b20){const _0x8e1268=a0_0xd8f2b7;try{const _0x2af115=new _0x3e7b20();if(!(_0x2af115 instanceof BaseTool))throw new Error('Tool\x20'+_0x3e7b20[_0x8e1268(0x210)]+'\x20must\x20extend\x20BaseTool');const _0xe57ab0=_0x2af115['getCapabilities']();await this[_0x8e1268(0x20d)](_0x2af115),this['tools'][_0x8e1268(0x1f3)](_0x2af115['id'],_0x2af115),this[_0x8e1268(0x25e)]['set'](_0x2af115['id'],_0x2af115[_0x8e1268(0x21c)]()),this['toolCapabilities']['set'](_0x2af115['id'],_0xe57ab0),this['logger']?.[_0x8e1268(0x25d)]('Tool\x20registered:\x20'+_0x2af115['id'],{'capabilities':_0xe57ab0['supportedActions'],'async':_0xe57ab0[_0x8e1268(0x1fc)],'requiresProject':_0xe57ab0[_0x8e1268(0x259)]});}catch(_0x592b4c){this[_0x8e1268(0x252)]?.[_0x8e1268(0x236)](_0x8e1268(0x1fb)+_0x592b4c['message'],{'toolClass':_0x3e7b20['name']});throw _0x592b4c;}}async['discoverTools'](_0x3e2e2f){return 0x0;}async[a0_0xd8f2b7(0x20d)](_0x42a035){const _0x379ab3=a0_0xd8f2b7,requiredMethods=['getDescription','parseParameters','execute'];for(const _0x1b788b of requiredMethods){if(typeof _0x42a035[_0x1b788b]!==_0x379ab3(0x262))throw new Error('Tool\x20'+_0x42a035['id']+_0x379ab3(0x24e)+_0x1b788b);}try{const _0x21c448=_0x42a035[_0x379ab3(0x242)](_0x379ab3(0x23d));if(typeof _0x21c448!==_0x379ab3(0x1ea))throw new Error('Tool\x20'+_0x42a035['id']+_0x379ab3(0x1ed));}catch(_0x367659){}const _0x304cc0=_0x42a035['getCapabilities']();if(!_0x304cc0||typeof _0x304cc0!==_0x379ab3(0x1ea))throw new Error('Tool\x20'+_0x42a035['id']+'\x20getCapabilities\x20must\x20return\x20an\x20object');}[a0_0xd8f2b7(0x21d)](_0x4d2530){return this['tools']['get'](_0x4d2530)||null;}['getToolCapabilities'](){const _0x33b9e9=a0_0xd8f2b7,_0x338212={};for(const [_0xeb7bb9,_0x20e61c]of this['tools'][_0x33b9e9(0x216)]()){_0x20e61c[_0x33b9e9(0x25b)]&&(_0x338212[_0xeb7bb9]={'description':this['toolDescriptions'][_0x33b9e9(0x258)](_0xeb7bb9),'capabilities':this[_0x33b9e9(0x26b)]['get'](_0xeb7bb9),'usageStats':_0x20e61c['getUsageStats']()});}return _0x338212;}async[a0_0xd8f2b7(0x1f9)](_0x7de624,_0x3db6e7,_0x11e966){const _0x16cf4f=a0_0xd8f2b7,_0x19bfab=this['getTool'](_0x7de624);if(!_0x19bfab)throw new Error('Tool\x20not\x20found:\x20'+_0x7de624);if(!_0x19bfab[_0x16cf4f(0x25b)])throw new Error('Tool\x20is\x20disabled:\x20'+_0x7de624);return await _0x19bfab['executeWithLifecycle'](_0x3db6e7,_0x11e966);}['listTools'](){const _0x3fa833=a0_0xd8f2b7;return Array['from'](this[_0x3fa833(0x239)][_0x3fa833(0x23f)]());}['generateToolDescriptionsForPrompt'](_0x28885e=[],_0x2bca10={}){const _0x5bf9f1=a0_0xd8f2b7,{includeExamples:includeExamples=!![],includeUsageGuidelines:includeUsageGuidelines=!![],includeSecurityNotes:includeSecurityNotes=!![],compact:compact=![]}=_0x2bca10,_0x4cb9e9=_0x28885e['length']>0x0?_0x28885e['filter'](_0x29f8e8=>this['tools']['has'](_0x29f8e8)):Array[_0x5bf9f1(0x1e3)](this[_0x5bf9f1(0x239)][_0x5bf9f1(0x23f)]());if(_0x4cb9e9[_0x5bf9f1(0x1e4)]===0x0)return'';let _0x14a788=_0x5bf9f1(0x26d);_0x14a788+=_0x5bf9f1(0x253);for(const _0x181558 of _0x4cb9e9){const _0x4ab7ad=this['tools']['get'](_0x181558);if(!_0x4ab7ad||!_0x4ab7ad['isEnabled'])continue;try{if(compact){const _0x4df9f9=_0x4ab7ad['getCapabilities'](),_0x44c519=_0x4df9f9[_0x5bf9f1(0x1f6)]||['execute'];_0x14a788+='**'+_0x181558+_0x5bf9f1(0x1fe)+_0x44c519[_0x5bf9f1(0x225)](',\x20')+'\x0a';}else _0x14a788+=_0x5bf9f1(0x218)+_0x181558['toUpperCase']()+_0x5bf9f1(0x208),_0x14a788+=_0x4ab7ad[_0x5bf9f1(0x21c)](),_0x14a788+=_0x5bf9f1(0x23e);}catch(_0xc1bf9d){this['logger']?.[_0x5bf9f1(0x219)](_0x5bf9f1(0x202)+_0x181558,{'error':_0xc1bf9d[_0x5bf9f1(0x1ef)]});}}return compact&&(_0x14a788+=_0x5bf9f1(0x24b)),_0x14a788+=_0x5bf9f1(0x243),_0x14a788+='**IMPORTANT**:\x20You\x20MUST\x20use\x20one\x20of\x20these\x20exact\x20formats\x20to\x20invoke\x20tools:\x0a\x0a',_0x14a788+='###\x20Format\x201:\x20Bracket\x20Notation\x0a',_0x14a788+='```\x0a',_0x14a788+=_0x5bf9f1(0x22f),_0x14a788+=_0x5bf9f1(0x211),_0x14a788+=_0x5bf9f1(0x20c),_0x14a788+='```\x0a\x0a',_0x14a788+='###\x20Format\x202:\x20JSON\x20in\x20Markdown\x20Code\x20Block\x20(REQUIRED\x20for\x20JSON)\x0a',_0x14a788+='```\x0a',_0x14a788+='```json\x0a',_0x14a788+='{\x0a',_0x14a788+=_0x5bf9f1(0x221),_0x14a788+=_0x5bf9f1(0x21e),_0x14a788+='}\x0a',_0x14a788+=_0x5bf9f1(0x268),_0x14a788+=_0x5bf9f1(0x1ec),_0x14a788+='**WARNING**:\x20Plain\x20JSON\x20without\x20markdown\x20code\x20blocks\x20(```json)\x20will\x20NOT\x20be\x20executed!\x0a',_0x14a788+=_0x5bf9f1(0x203),_0x14a788+='###\x20Format\x203:\x20XML\x20Format\x0a',_0x14a788+=_0x5bf9f1(0x245),_0x14a788+=_0x5bf9f1(0x224),_0x14a788+='\x20\x20<tool\x20id=\x22toolname\x22>\x0a',_0x14a788+=_0x5bf9f1(0x207),_0x14a788+='\x20\x20</tool>\x0a',_0x14a788+='</tool-command>\x0a',_0x14a788+=_0x5bf9f1(0x1ec),_0x14a788+='After\x20invoking\x20a\x20tool,\x20WAIT\x20for\x20the\x20actual\x20response.\x20Do\x20NOT\x20generate\x20imaginary\x20responses.\x0a',_0x14a788;}['enhanceSystemPrompt'](_0x300249,_0x4d8db2=[],_0x4f7cf8={}){const _0x943c89=a0_0xd8f2b7,_0xc85d14=this[_0x943c89(0x215)](_0x4d8db2,_0x4f7cf8);if(!_0xc85d14['trim']())return _0x300249||'';const _0x62322b=_0x300249||'';if(_0x62322b['includes'](_0x943c89(0x24c)))return _0x62322b['replace'](/## AVAILABLE TOOLS[\s\S]*?(?=##|$)/,_0xc85d14+'\x0a');const _0x502a68=_0x943c89(0x246);return _0x62322b+(_0x62322b['endsWith']('\x0a')?'':'\x0a')+_0xc85d14+_0x502a68+'\x0a';}['getAvailableToolsForUI'](){const _0x21b588=a0_0xd8f2b7,_0x72f194=[];for(const [_0x3f56a3,_0x502760]of this[_0x21b588(0x239)]['entries']()){const _0x3b174f=_0x502760[_0x21b588(0x269)](),_0xb4be27=_0x502760[_0x21b588(0x21c)](),_0x3153b3=_0xb4be27[_0x21b588(0x1fd)]('\x0a')['find'](_0x4bf7f3=>_0x4bf7f3['trim']()[_0x21b588(0x1e4)]>0x0)||'',_0x2a3564=_0x3153b3['replace'](/^.*Tool:\s*/i,'')['replace'](/\s*-.*$/,'')[_0x21b588(0x206)]();_0x72f194[_0x21b588(0x1eb)]({'id':_0x3f56a3,'name':_0x2a3564||_0x3f56a3[_0x21b588(0x213)](0x0)['toUpperCase']()+_0x3f56a3[_0x21b588(0x23b)](0x1),'description':_0x3153b3,'category':this['_getToolCategory'](_0x3f56a3),'enabled':_0x3b174f[_0x21b588(0x240)],'async':_0x3b174f['async'],'requiresProject':_0x3b174f[_0x21b588(0x259)],'className':_0x502760['constructor']['name']});}return _0x72f194[_0x21b588(0x23c)]((_0x2bcfcf,_0x5aa895)=>_0x2bcfcf['name'][_0x21b588(0x248)](_0x5aa895[_0x21b588(0x210)]));}[a0_0xd8f2b7(0x26c)](_0x169d6e){const _0x46f2c7=a0_0xd8f2b7,_0x34e1a7={'terminal':_0x46f2c7(0x265),'filesystem':_0x46f2c7(0x24d),'browser':_0x46f2c7(0x226),'agentdelay':'Utility'};return _0x34e1a7[_0x169d6e]||'Other';}[a0_0xd8f2b7(0x21b)](){const _0x4025ab=a0_0xd8f2b7,_0x224190=Array['from'](this[_0x4025ab(0x239)]['values']())['filter'](_0x13e613=>_0x13e613[_0x4025ab(0x25b)]),_0x8e454f=Array[_0x4025ab(0x1e3)](this['tools'][_0x4025ab(0x233)]())[_0x4025ab(0x235)]((_0x1f6fc4,_0x58ba8a)=>_0x1f6fc4+_0x58ba8a[_0x4025ab(0x237)],0x0);return{'totalTools':this[_0x4025ab(0x239)][_0x4025ab(0x266)],'enabledTools':_0x224190['length'],'totalOperations':_0x8e454f,'activeOperations':this[_0x4025ab(0x1f4)][_0x4025ab(0x266)]};}}function a0_0x499d(){const _0x24c348=['C3bSAxq','kIO6ia','nZu0mdu2mg5my0nVta','vg9VBca','z2v0vxnHz2vtDgf0CW','rMfPBgvKihrVigDLDcbKzxnJCMLWDgLVBIbMB3iGDg9VBdOG','qwX3yxLZihDYyxaGsLnptIb0B29SignVBw1HBMrZigLUigbGygPZB24GlI4UigbGycbIBg9JA3mUcGO','yxbPs2v5CW','DgLTzw91Da','DhjPBq','icaGidXWyxjHBwv0zxi+DMfSDwu8l3bHCMfTzxrLCJ4k','ifrpt0WkcG','zxHLy3v0Aw9UvgLTzq','DMfSAwrHDgvqyxjHBwv0zxjZ','igHHCYbYzwfJAgvKig1HEgLTDw0Gy29Uy3vYCMvUDcbVCgvYyxrPB25ZigXPBwL0','wY90B29SxqO','DMfSAwrHDgvuB29S','zw5KvgLTzq','y29UDgvUDa','BMfTzq','phbHCMfTzxrLCNmGAgvYzt4k','y29UDgv4Da','y2HHCKf0','y29UC3rYDwn0B3i','z2vUzxjHDgvuB29SrgvZy3jPChrPB25ZrM9YuhjVBxb0','zw50CMLLCW','y2XLyw51CeHPC3rVCNK','iYmJia','D2fYBG','y3vZDg9TvMfSAwrHDgvqyxjHBwv0zxjZ','z2v0uMvNAxn0CNLtDgf0CW','z2v0rgvZy3jPChrPB24','z2v0vg9VBa','icaICgfYyw1LDgvYCYi6ihSGlI4Uih0GB3iGiMfJDgLVBNmIoIbBic4UlIbDcG','z2v0ugfYyw1LDgvYu2nOzw1H','lI4UifT0CNvUy2f0zwrD','icaIDg9VBeLKiJOGiNrVB2XUyw1LiIWk','Bwf4q29Uy3vYCMvUDe9WzxjHDgLVBNm','C3rHCNruAw1L','phrVB2WTy29TBwfUzd4k','AM9PBG','qxv0B21HDgLVBG','C3rHDhvZ','Dg9ju09tDhjPBMC','ig11C3qGAw1WBgvTzw50ihbHCNnLugfYyw1LDgvYCYGP','BM93','zMLSDgvY','mZe3nZq2mwziDwnTBa','CMvZDwX0','C3vIC3rYAw5N','w3rVB2WGAwq9iNrVB2XUyw1LiL0k','C2fUAxrPEMvdB250zxH0','CMfUzg9T','vg9VBcbLEgvJDxrPB24GzMfPBgvKoIa','DMfSDwvZ','vg9VBcbLBMfIBgvKoIa','CMvKDwnL','zxjYB3i','DxnHz2vdB3vUDa','y29UzMLN','Dg9VBhm','z2vUzxjHDgvpCgvYyxrPB25jza','C2XPy2u','C29YDa','DgvZDcbJB250zw50','cGOTls0kcG','A2v5CW','zw5HyMXLza','mJm0ntCYvLbtAwD6','CgfYC2vqyxjHBwv0zxjZ','iYmGve9ptcbjtLzpq0fusu9oifnztLrbwaOk','q09nueXfveve','ygbGEg1ScG','su1qt1juqu5uoIb3AgvUigfZA2vKihrVihbLCMzVCM0Gyw4Gywn0Aw9Uig9Yig9WzxjHDgLVBIWGDxnLigvHy2GGCMvZCg9UC2uGDg8GAw52B2TLigeGDg9VBcbPzIbUzwvKzwqSigfUzcb1CgrHDguGDgHLihvZzxiGB24GDgHLihbYB2DYzxnZicHZyw1Lig1LC3nHz2uPlG','DMfSAwq','Bg9JywXLq29TCgfYzq','ntCWofbXqMPKta','y2XLyw51Ca','cLvZzsbBDg9VBcbPzd0IDg9VBc1Uyw1LiL08CgfYyw1LDgvYCZ5Bl3rVB2XDig9YiePtt04GzM9YBwf0ihrVigLUDM9Rzsb0B29SCY4kcG','iYmGqvzbsuXbqKXfifrpt0Xt','rMLSzsbpCgvYyxrPB25Z','ig1PC3nPBMCGCMvXDwLYzwqGBwv0Ag9KoIa','CMvWBgfJzq','BgfZDfvZzwq','C3vIC3rY','Bg9Nz2vY','ww91igHHDMuGywnJzxnZihrVihrOzsbMB2XSB3DPBMCGDg9VBhmGDg8GCgvYzM9YBsbVCgvYyxrPB25ZigfUzcb0yxnRCZOkcG','B3bLCMf0Aw9UsgLZDg9YEq','zw5HyMXL','AxnbC3LUyW','y2fSy3vSyxrLqxzLCMfNzuv4zwn1DgLVBLrPBwu','z2v0','CMvXDwLYzxnqCM9Qzwn0','t3bLCMf0Aw9Uig5VDcbMB3vUza','AxnfBMfIBgvK','mZC3nJy3tgTLuend','Aw5MBW','Dg9VBerLC2nYAxb0Aw9UCW','mZm5otyYBuvms0jS','rKfjteve','CMvZzxrtDgf0CW','zNvUy3rPB24','z2v0u3vWCg9YDgvKqwn0Aw9UCW','vg9VBcbLEgvJDxrPB24Gy29TCgXLDgvKoIa','u3LZDgvT','C2L6zq','twLZC2LUzYbYzxf1AxjLzcbWyxjHBwv0zxi6ia','ygbGcG','z2v0q2fWywjPBgL0AwvZ','ugfYyw1LDgvYCYbTDxn0igjLigfUig9IAMvJDa','Dg9VBenHCgfIAwXPDgLLCW','x2DLDfrVB2XdyxrLz29YEq','cImJiefwquLmqujmrsbut09muWOk','zNjVBq','BgvUz3rO','tK9ux0zpvu5e','ywn0AxzLt3bLCMf0Aw9UCW','ugfYyw1LDgvYihzHBgLKyxrPB24GzMfPBgvKoIa','Dg9VBa','ndbwr21XwhK','B2jQzwn0','ChvZAa','ygbGcGO','ihbHCNnLugfYyw1LDgvYCYbTDxn0ihjLDhvYBIbHBIbVyMPLy3q','mtKYodGWCg5fy21S','BwvZC2fNzq','nJm2ze5QC3bs','zxHLy3v0zvDPDgHuAw1LB3v0','y2fSy3vSyxrLu3vJy2vZC1jHDgu','C2v0','yxn5BMnpCgvYyxrPB25Z','mtj0DunsuK0','C3vWCg9YDgvKqwn0Aw9UCW','zMLUza','zxHLy3v0zq','zxHLy3v0zvrVB2Xtzwn1CMvSEq','vg9VBcbLEgvJDxrPB24GDgLTzwqGB3v0igfMDgvYia','vg9VBcbYzwDPC3rYyxrPB24GzMfPBgvKoIa','yxn5BMm'];a0_0x499d=function(){return _0x24c348;};return a0_0x499d();}function a0_0x4677(_0x13853e,_0x474b76){_0x13853e=_0x13853e-0x1e3;const _0x499d1d=a0_0x499d();let _0x467781=_0x499d1d[_0x13853e];if(a0_0x4677['JituRh']===undefined){var _0x273277=function(_0x44f234){const _0x284b2e='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x11d65a='',_0x1df1c6='';for(let _0x23bd6b=0x0,_0x169d47,_0x4553f9,_0x4f80cc=0x0;_0x4553f9=_0x44f234['charAt'](_0x4f80cc++);~_0x4553f9&&(_0x169d47=_0x23bd6b%0x4?_0x169d47*0x40+_0x4553f9:_0x4553f9,_0x23bd6b++%0x4)?_0x11d65a+=String['fromCharCode'](0xff&_0x169d47>>(-0x2*_0x23bd6b&0x6)):0x0){_0x4553f9=_0x284b2e['indexOf'](_0x4553f9);}for(let _0x4f0ca5=0x0,_0x1879ef=_0x11d65a['length'];_0x4f0ca5<_0x1879ef;_0x4f0ca5++){_0x1df1c6+='%'+('00'+_0x11d65a['charCodeAt'](_0x4f0ca5)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x1df1c6);};a0_0x4677['lOWLEq']=_0x273277,a0_0x4677['pgtFbb']={},a0_0x4677['JituRh']=!![];}const _0x42694c=_0x499d1d[0x0],_0x1be5d9=_0x13853e+_0x42694c,_0x1c1991=a0_0x4677['pgtFbb'][_0x1be5d9];return!_0x1c1991?(_0x467781=a0_0x4677['lOWLEq'](_0x467781),a0_0x4677['pgtFbb'][_0x1be5d9]=_0x467781):_0x467781=_0x1c1991,_0x467781;}export{BaseTool,ToolsRegistry};