vibecodingmachine-core 2026.2.26-1739 → 2026.3.9-850
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/package.json +1 -1
- package/src/agents/AgentCheckDiscoveryService.js +180 -0
- package/src/agents/AgentCheckService.js +18 -261
- package/src/agents/AgentCheckStatisticsService.js +195 -0
- package/src/agents/EnvironmentConfigurationManager.js +31 -380
- package/src/agents/InstallationType.js +19 -6
- package/src/agents/SimpleAgentCheckService.js +472 -0
- package/src/agents/config-managers/ConfigUtils.js +72 -0
- package/src/agents/config-managers/DefaultConfig.js +58 -0
- package/src/agents/config-managers/EnvVarLoader.js +66 -0
- package/src/agents/config-managers/FileConfigLoader.js +124 -0
- package/src/agents/config-managers/TypeConverters.js +61 -0
- package/src/agents/config-managers/VariableMappings.js +92 -0
- package/src/agents/discovery/AgentDiscoveryService-refactored.js +272 -0
- package/src/agents/discovery/AgentDiscoveryService.js +29 -403
- package/src/agents/discovery/agent-validator.js +262 -0
- package/src/agents/discovery/discovery-results.js +176 -0
- package/src/agents/discovery/discovery-scanner.js +268 -0
- package/src/agents/discovery/discovery-utils.js +161 -0
- package/src/agents/discovery/executable-analyzer.js +290 -0
- package/src/agents/discovery/history-manager.js +310 -0
- package/src/agents/verification/ResultAnalyzer-refactored.js +341 -0
- package/src/agents/verification/ResultAnalyzer.js +30 -431
- package/src/agents/verification/analysis-utils.js +310 -0
- package/src/agents/verification/batch-analyzer.js +440 -0
- package/src/agents/verification/pattern-recognizer.js +369 -0
- package/src/agents/verification/report-generator.js +320 -0
- package/src/agents/verification/test-analyzer.js +290 -0
- package/src/agents/windows/InstallerFactory.js +4 -0
- package/src/agents/windows/VSCodeExtensionInstaller.js +404 -0
- package/src/analysis/analysis-engine.js +314 -0
- package/src/analysis/ast-analyzer.js +342 -0
- package/src/analysis/boundary-detector-refactored.js +378 -0
- package/src/analysis/boundary-detector.js +200 -603
- package/src/analysis/boundary-scanner.js +609 -0
- package/src/analysis/boundary-types.js +118 -0
- package/src/analysis/boundary-utils.js +293 -0
- package/src/analysis/deadline-priority-calculator.js +18 -0
- package/src/analysis/detection-methods.js +347 -0
- package/src/analysis/importance-priority-calculator.js +18 -0
- package/src/analysis/priority/factor-calculators.js +204 -0
- package/src/analysis/priority/factor-helpers.js +71 -0
- package/src/analysis/priority/priority-constants.js +73 -0
- package/src/analysis/priority/priority-factor-calculators.js +301 -0
- package/src/analysis/priority/reasons-generator.js +44 -0
- package/src/analysis/priority-calculator.js +15 -580
- package/src/analysis/strategy-generator.js +16 -66
- package/src/analysis/type-priority-calculator.js +18 -0
- package/src/analysis/urgency-priority-calculator.js +18 -0
- package/src/auto-mode/AutoModeBusinessLogic.js +2 -40
- package/src/commands/disable-requirement.js +60 -0
- package/src/commands/disable-spec.js +60 -0
- package/src/commands/enable-requirement.js +60 -0
- package/src/commands/enable-spec.js +60 -0
- package/src/commands/registry.js +1 -6
- package/src/commands/requirements.js +8 -2
- package/src/ide-integration/applescript-manager.cjs +9 -24
- package/src/ide-integration/cdp-handlers/chat-reader.js +44 -0
- package/src/ide-integration/cdp-handlers/connection-handler.js +88 -0
- package/src/ide-integration/cdp-handlers/continuation-handler.js +314 -0
- package/src/ide-integration/cdp-handlers/message-submitter.js +75 -0
- package/src/ide-integration/cdp-handlers/text-sender.js +138 -0
- package/src/ide-integration/cdp-manager.js +28 -573
- package/src/ide-integration/claude-code-cli-manager.cjs +48 -12
- package/src/ide-integration/ide-openers/claude-opener.js +171 -0
- package/src/ide-integration/ide-openers/cursor-opener.js +53 -0
- package/src/ide-integration/ide-openers/other-ides-opener.js +230 -0
- package/src/ide-integration/ide-openers/vscode-opener.js +147 -0
- package/src/ide-integration/macos-ide-manager.js +20 -582
- package/src/ide-integration/macos-quota-checker.js +164 -0
- package/src/ide-integration/macos-text-sender.js +19 -38
- package/src/ide-integration/provider-manager.cjs +52 -7
- package/src/index.cjs +6 -0
- package/src/index.js +10 -0
- package/src/llm/direct-llm-manager.cjs +501 -0
- package/src/localization/translations/en-part1.js +363 -0
- package/src/localization/translations/en-part2.js +320 -0
- package/src/localization/translations/en.js +4 -687
- package/src/localization/translations/es-part1.js +363 -0
- package/src/localization/translations/es-part2.js +320 -0
- package/src/localization/translations/es.js +4 -688
- package/src/models/file-analysis-collection.js +139 -0
- package/src/models/file-analysis-metrics.js +50 -0
- package/src/models/file-analysis.js +15 -262
- package/src/models/plan-manager.js +410 -0
- package/src/models/refactoring-models.js +380 -0
- package/src/models/refactoring-plan-refactored.js +81 -0
- package/src/models/refactoring-plan.js +2 -663
- package/src/monitoring/alert-system.js +4 -45
- package/src/monitoring/continuous-scan-notifications.js +37 -191
- package/src/monitoring/notification-handlers/base-handler.js +58 -0
- package/src/monitoring/notification-handlers/error-handler.js +36 -0
- package/src/monitoring/notification-handlers/index.js +21 -0
- package/src/monitoring/notification-handlers/new-violation-handler.js +91 -0
- package/src/monitoring/notification-handlers/progress-handler.js +48 -0
- package/src/monitoring/notification-handlers/resolved-violation-handler.js +54 -0
- package/src/monitoring/notification-handlers/threshold-handler.js +36 -0
- package/src/provider-registry.js +8 -0
- package/src/refactoring/boundary/boundary-detector-refactored.js +58 -0
- package/src/refactoring/boundary/boundary-detector.js +26 -596
- package/src/refactoring/boundary/detectors/boundary-analyzers.js +281 -0
- package/src/refactoring/boundary/detectors/boundary-core.js +167 -0
- package/src/refactoring/boundary/detectors/class-detector.js +247 -0
- package/src/refactoring/boundary/detectors/config-detector.js +270 -0
- package/src/refactoring/boundary/detectors/constant-detector.js +269 -0
- package/src/refactoring/boundary/detectors/function-detector.js +248 -0
- package/src/refactoring/boundary/detectors/module-detector.js +249 -0
- package/src/refactoring/boundary/detectors/object-detector.js +247 -0
- package/src/refactoring/boundary/detectors/type-detectors.js +338 -0
- package/src/refactoring/boundary/detectors/utility-detector.js +270 -0
- package/src/refactoring/circular-dependency-resolver-original.js +16 -76
- package/src/refactoring/code-mover-refactored.js +309 -0
- package/src/refactoring/code-mover.js +48 -355
- package/src/refactoring/execution-status.js +18 -0
- package/src/refactoring/execution-strategies.js +172 -0
- package/src/refactoring/file-splitter-core.js +568 -0
- package/src/refactoring/file-splitter-types.js +136 -0
- package/src/refactoring/file-splitter.js +2 -682
- package/src/refactoring/functionality-validator.js +11 -51
- package/src/refactoring/import-manager-refactored.js +385 -0
- package/src/refactoring/import-manager.js +112 -487
- package/src/refactoring/import-models.js +189 -0
- package/src/refactoring/import-parser.js +306 -0
- package/src/refactoring/move-executor.js +431 -0
- package/src/refactoring/move-utils.js +368 -0
- package/src/refactoring/operation-executor.js +76 -0
- package/src/refactoring/plan-creator.js +36 -0
- package/src/refactoring/plan-executor.js +143 -0
- package/src/refactoring/plan-validator.js +68 -0
- package/src/refactoring/refactoring-executor-result.js +70 -0
- package/src/refactoring/refactoring-executor.js +34 -569
- package/src/refactoring/refactoring-operation.js +94 -0
- package/src/refactoring/refactoring-plan.js +69 -0
- package/src/refactoring/refactoring-rollback.js +22 -527
- package/src/refactoring/rollback-handlers/RollbackExecutor.js +107 -0
- package/src/refactoring/rollback-handlers/RollbackManager.js +265 -0
- package/src/refactoring/rollback-handlers/RollbackOperation.js +105 -0
- package/src/refactoring/rollback-handlers/RollbackResult.js +109 -0
- package/src/refactoring/rollback-handlers/RollbackStatistics.js +77 -0
- package/src/refactoring/test-validator.js +32 -448
- package/src/refactoring/validation/baseline-runner.js +71 -0
- package/src/refactoring/validation/report-generator.js +136 -0
- package/src/refactoring/validation/result-comparator.js +92 -0
- package/src/refactoring/validation/test-suite.js +59 -0
- package/src/refactoring/validation/test-validation-result.js +83 -0
- package/src/refactoring/validation/validation-runner.js +95 -0
- package/src/refactoring/validation/validation-status.js +18 -0
- package/src/rui/commands/AgentCommandParser.js +60 -369
- package/src/rui/commands/AgentResponseFormatter.js +7 -47
- package/src/rui/commands/parsers/CommandMapper.js +148 -0
- package/src/rui/commands/parsers/CommandValidator.js +228 -0
- package/src/rui/commands/parsers/ComponentExtractor.js +100 -0
- package/src/rui/commands/parsers/TokenParser.js +69 -0
- package/src/rui/commands/parsers/tokenizer.js +153 -0
- package/src/utils/current-requirement-operations.js +50 -1
- package/src/utils/report-generator.js +18 -514
- package/src/utils/report-generators/analysis-generator.js +115 -0
- package/src/utils/report-generators/base-generator.js +141 -0
- package/src/utils/report-generators/compliance-generator.js +41 -0
- package/src/utils/report-generators/format-handlers.js +185 -0
- package/src/utils/report-generators/refactoring-generator.js +46 -0
- package/src/utils/report-generators/validation-generator.js +63 -0
- package/src/utils/requirement-enable-disable.js +265 -0
- package/src/utils/requirement-helpers/requirement-file-ops.js +69 -1
- package/src/utils/requirement-helpers/requirement-mover.js +88 -1
- package/src/utils/requirement-helpers.js +5 -2
- package/src/utils/smoke-test-cli.js +45 -8
- package/src/utils/specification-enable-disable.js +122 -0
- package/src/utils/specification-helpers.js +30 -4
- package/src/utils/specification-migration.js +5 -5
- package/src/utils/test-comparator.js +118 -0
- package/src/utils/test-config.js +54 -0
- package/src/utils/test-executor.js +133 -0
- package/src/utils/test-parser.js +215 -0
- package/src/utils/test-runner-baseline.js +63 -0
- package/src/utils/test-runner-core.js +98 -0
- package/src/utils/test-runner-report.js +39 -0
- package/src/utils/test-runner-validation.js +71 -0
- package/src/utils/test-runner.js +11 -535
- package/src/validation/comparison-analyzer.js +333 -0
- package/src/validation/compliance-reporter-new.js +282 -0
- package/src/validation/compliance-reporter-refactored.js +344 -0
- package/src/validation/compliance-reporter.js +278 -591
- package/src/validation/compliance-utils.js +278 -0
- package/src/validation/html-generator.js +446 -0
- package/src/validation/metrics/category-calculator.js +137 -0
- package/src/validation/metrics/metrics-helpers.js +155 -0
- package/src/validation/metrics/overview-calculator.js +85 -0
- package/src/validation/metrics/overview-metrics.js +41 -0
- package/src/validation/metrics/quality-calculator.js +166 -0
- package/src/validation/metrics/size-calculator.js +69 -0
- package/src/validation/metrics-calculator.js +27 -551
|
@@ -7,10 +7,16 @@
|
|
|
7
7
|
|
|
8
8
|
const fs = require('fs').promises;
|
|
9
9
|
const path = require('path');
|
|
10
|
-
const { spawn
|
|
11
|
-
const { promisify } = require('util');
|
|
10
|
+
const { spawn } = require('child_process');
|
|
12
11
|
|
|
13
|
-
const
|
|
12
|
+
const { analyzeExecutable } = require('./executable-analyzer');
|
|
13
|
+
const { validateAndDeduplicateAgents, validateAgent } = require('./agent-validator');
|
|
14
|
+
const {
|
|
15
|
+
recordDiscoveryOperation,
|
|
16
|
+
updateDiscoveryStatus,
|
|
17
|
+
getDiscoveryStatus,
|
|
18
|
+
getDiscoveryHistory
|
|
19
|
+
} = require('./history-manager');
|
|
14
20
|
|
|
15
21
|
/**
|
|
16
22
|
* Agent Discovery Service class
|
|
@@ -51,8 +57,6 @@ class AgentDiscoveryService {
|
|
|
51
57
|
const errors = [];
|
|
52
58
|
|
|
53
59
|
// Discover agents from each path
|
|
54
|
-
const pathAgents = [];
|
|
55
|
-
|
|
56
60
|
for (const discoveryPath of this.discoveryPaths) {
|
|
57
61
|
try {
|
|
58
62
|
const agents = await this.discoverFromPath(discoveryPath);
|
|
@@ -68,7 +72,7 @@ class AgentDiscoveryService {
|
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
// Validate and deduplicate discovered agents
|
|
71
|
-
const validAgents = await
|
|
75
|
+
const validAgents = await validateAndDeduplicateAgents(discoveredAgents, this.logger);
|
|
72
76
|
const duplicateCount = discoveredAgents.length - validAgents.length;
|
|
73
77
|
|
|
74
78
|
if (duplicateCount > 0) {
|
|
@@ -76,7 +80,7 @@ class AgentDiscoveryService {
|
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
// Update discovery status
|
|
79
|
-
await
|
|
83
|
+
await updateDiscoveryStatus(validAgents, discoveredAgents.length, duplicateCount, warnings, errors, this.fileManager, this.logger);
|
|
80
84
|
|
|
81
85
|
const duration = Date.now() - startTime;
|
|
82
86
|
|
|
@@ -91,11 +95,11 @@ class AgentDiscoveryService {
|
|
|
91
95
|
});
|
|
92
96
|
}
|
|
93
97
|
|
|
94
|
-
await
|
|
98
|
+
await recordDiscoveryOperation('discover', {
|
|
95
99
|
totalDiscovered: discoveredAgents.length,
|
|
96
100
|
validAgents: validAgents.length,
|
|
97
101
|
duration
|
|
98
|
-
});
|
|
102
|
+
}, this.fileManager, this.logger);
|
|
99
103
|
|
|
100
104
|
return {
|
|
101
105
|
success: errors.length === 0,
|
|
@@ -150,14 +154,15 @@ class AgentDiscoveryService {
|
|
|
150
154
|
|
|
151
155
|
try {
|
|
152
156
|
const fileStat = await fs.stat(filePath);
|
|
153
|
-
const isDirectory =
|
|
157
|
+
const isDirectory = fileStat.isDirectory();
|
|
158
|
+
|
|
154
159
|
if (isDirectory) {
|
|
155
160
|
const subAgents = await this.discoverFromPath(filePath);
|
|
156
161
|
agents.push(...subAgents);
|
|
157
162
|
} else {
|
|
158
163
|
// Check if it's an executable file
|
|
159
164
|
if (fileStat.isFile() && fileStat.mode & parseInt('111', 8)) {
|
|
160
|
-
const agentInfo = await
|
|
165
|
+
const agentInfo = await analyzeExecutable(filePath, this.logger);
|
|
161
166
|
|
|
162
167
|
if (agentInfo) {
|
|
163
168
|
agents.push(agentInfo);
|
|
@@ -187,225 +192,6 @@ class AgentDiscoveryService {
|
|
|
187
192
|
}
|
|
188
193
|
}
|
|
189
194
|
|
|
190
|
-
/**
|
|
191
|
-
* Analyze executable file for agent information
|
|
192
|
-
* @param {string} filePath - Path to executable file
|
|
193
|
-
* @returns {Promise<Object>} - Agent information or null
|
|
194
|
-
*/
|
|
195
|
-
async analyzeExecutable(filePath) {
|
|
196
|
-
try {
|
|
197
|
-
// Get file info
|
|
198
|
-
const stat = await fs.stat(filePath);
|
|
199
|
-
const fileName = path.basename(filePath);
|
|
200
|
-
|
|
201
|
-
// Try to get version information
|
|
202
|
-
let version = 'unknown';
|
|
203
|
-
let description = '';
|
|
204
|
-
|
|
205
|
-
// Execute file with --help or --version flag
|
|
206
|
-
try {
|
|
207
|
-
const { stdout } = await execAsync(`"${filePath}" --version`, {
|
|
208
|
-
timeout: 5000
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
// Parse version from output
|
|
212
|
-
const versionMatch = stdout.match(/(\d+\.\d+\.\d+)/);
|
|
213
|
-
if (versionMatch) {
|
|
214
|
-
version = versionMatch[1];
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Try to get description from help output
|
|
218
|
-
const { stdout: helpOutput } = await execAsync(`"${filePath}" --help`, {
|
|
219
|
-
timeout: 5000
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
// Extract description from help output (first line that looks like a description)
|
|
223
|
-
const helpLines = helpOutput.split('\n');
|
|
224
|
-
const descriptionLine = helpLines.find(line =>
|
|
225
|
-
line && !line.startsWith('Usage:') &&
|
|
226
|
-
!line.startsWith('Options:') &&
|
|
227
|
-
line.trim().length > 10
|
|
228
|
-
);
|
|
229
|
-
|
|
230
|
-
if (descriptionLine) {
|
|
231
|
-
description = descriptionLine.trim();
|
|
232
|
-
}
|
|
233
|
-
} catch (versionError) {
|
|
234
|
-
// Version check failed, continue with unknown version
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// Determine agent type based on file characteristics
|
|
238
|
-
let type = 'CLI';
|
|
239
|
-
if (fileName.includes('gui') || fileName.includes('window') || fileName.includes('app')) {
|
|
240
|
-
type = 'GUI';
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// Generate unique ID based on filename
|
|
244
|
-
const id = this.generateAgentId(fileName, filePath);
|
|
245
|
-
|
|
246
|
-
// Determine capabilities based on help output
|
|
247
|
-
const capabilities = await this.determineCapabilities(filePath, helpOutput);
|
|
248
|
-
|
|
249
|
-
return {
|
|
250
|
-
id,
|
|
251
|
-
name: this.generateAgentName(fileName, description),
|
|
252
|
-
path: filePath,
|
|
253
|
-
version,
|
|
254
|
-
description,
|
|
255
|
-
type,
|
|
256
|
-
capabilities,
|
|
257
|
-
discovered: true,
|
|
258
|
-
discoveredAt: new Date().toISOString()
|
|
259
|
-
};
|
|
260
|
-
} catch (error) {
|
|
261
|
-
if (this.logger) {
|
|
262
|
-
await this.logger.warn(`Error analyzing executable ${filePath}: ${error.message}`);
|
|
263
|
-
}
|
|
264
|
-
return null;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Generate agent ID from filename and path
|
|
270
|
-
* @param {string} fileName - File name
|
|
271
|
-
* @param {string} filePath - File path
|
|
272
|
-
* @returns {string} - Generated agent ID
|
|
273
|
-
*/
|
|
274
|
-
generateAgentId(fileName, filePath) {
|
|
275
|
-
// Use filename as base, make it lowercase and replace special chars
|
|
276
|
-
const baseId = fileName
|
|
277
|
-
.toLowerCase()
|
|
278
|
-
.replace(/[^a-z0-9]/g, '-')
|
|
279
|
-
.replace(/\.(exe|sh|bat|cmd)$/g, '');
|
|
280
|
-
|
|
281
|
-
// Add path hash for uniqueness
|
|
282
|
-
const pathHash = filePath
|
|
283
|
-
.split('/')
|
|
284
|
-
.slice(-2)
|
|
285
|
-
.join('-')
|
|
286
|
-
.substring(0, 8);
|
|
287
|
-
|
|
288
|
-
return `${baseId}-${pathHash}`;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* Generate agent name from filename and description
|
|
293
|
-
* @param {string} fileName - File name
|
|
294
|
-
* @param {string} description - Description from help output
|
|
295
|
-
* @returns {string} - Generated agent name
|
|
296
|
-
*/
|
|
297
|
-
generateAgentName(fileName, description) {
|
|
298
|
-
// Use description if available, otherwise generate from filename
|
|
299
|
-
if (description && description.trim()) {
|
|
300
|
-
return description.trim();
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// Generate name from filename
|
|
304
|
-
const name = fileName
|
|
305
|
-
.replace(/\.(exe|sh|bat|cmd)$/g, '')
|
|
306
|
-
.replace(/-/g, ' ')
|
|
307
|
-
.split(' ')
|
|
308
|
-
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
309
|
-
.join(' ');
|
|
310
|
-
|
|
311
|
-
return name;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Determine agent capabilities from help output
|
|
316
|
-
* @param {string} filePath - Path to executable
|
|
317
|
-
* @param {string} helpOutput - Help output from executable
|
|
318
|
-
* @returns {Array} - Array of capabilities
|
|
319
|
-
*/
|
|
320
|
-
async determineCapabilities(filePath, helpOutput) {
|
|
321
|
-
const capabilities = [];
|
|
322
|
-
const fileName = path.basename(filePath).toLowerCase();
|
|
323
|
-
|
|
324
|
-
// Common CLI capabilities
|
|
325
|
-
if (helpOutput.includes('--check') || helpOutput.includes('check ')) {
|
|
326
|
-
capabilities.push('check');
|
|
327
|
-
}
|
|
328
|
-
if (helpOutput.includes('--install') || helpOutput.includes('install ')) {
|
|
329
|
-
capabilities.push('install');
|
|
330
|
-
}
|
|
331
|
-
if (helpOutput.includes('--verify') || helpOutput.includes('verify ')) {
|
|
332
|
-
capabilities.push('verify');
|
|
333
|
-
}
|
|
334
|
-
if (helpOutput.includes('--logs') || helpOutput.includes('logs ')) {
|
|
335
|
-
capabilities.push('logs');
|
|
336
|
-
}
|
|
337
|
-
if (helpOutput.includes('--status') || helpOutput.includes('status ')) {
|
|
338
|
-
capabilities.push('status');
|
|
339
|
-
}
|
|
340
|
-
if (helpOutput.includes('--update') || helpOutput.includes('update ')) {
|
|
341
|
-
capabilities.push('update');
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
// GUI-specific capabilities
|
|
345
|
-
if (fileName.includes('gui') || fileName.includes('window')) {
|
|
346
|
-
capabilities.push('gui');
|
|
347
|
-
}
|
|
348
|
-
if (fileName.includes('app')) {
|
|
349
|
-
capabilities.push('app-interface');
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// Add default capabilities based on file type
|
|
353
|
-
capabilities.push('help');
|
|
354
|
-
|
|
355
|
-
return capabilities;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Validate and deduplicate discovered agents
|
|
360
|
-
* @param {Array} agents - Discovered agents
|
|
361
|
-
* @returns {Array} - Valid, deduplicated agents
|
|
362
|
-
*/
|
|
363
|
-
async validateAndDeduplicateAgents(agents) {
|
|
364
|
-
const validAgents = [];
|
|
365
|
-
const seenIds = new Set();
|
|
366
|
-
const seenPaths = new Set();
|
|
367
|
-
|
|
368
|
-
for (const agent of agents) {
|
|
369
|
-
// Validate required fields
|
|
370
|
-
if (!agent.id || !agent.name || !agent.path) {
|
|
371
|
-
if (this.logger) {
|
|
372
|
-
await this.logger.warn('Invalid agent configuration: missing required fields', {
|
|
373
|
-
agent: agent.id || 'unknown'
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
continue;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
// Check for duplicates
|
|
380
|
-
if (seenIds.has(agent.id)) {
|
|
381
|
-
if (this.logger) {
|
|
382
|
-
await this.logger.warn('Duplicate agent ID found: ' + agent.id);
|
|
383
|
-
}
|
|
384
|
-
continue;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
if (seenPaths.has(agent.path)) {
|
|
388
|
-
if (this.logger) {
|
|
389
|
-
await this.logger.warn('Duplicate agent path found: ' + agent.path);
|
|
390
|
-
}
|
|
391
|
-
continue;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// Additional validation
|
|
395
|
-
if (agent.version === 'unknown') {
|
|
396
|
-
if (this.logger) {
|
|
397
|
-
await this.logger.warn(`Agent ${agent.id} has unknown version`);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
validAgents.push(agent);
|
|
402
|
-
seenIds.add(agent.id);
|
|
403
|
-
seenPaths.add(agent.path);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
return validAgents;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
195
|
/**
|
|
410
196
|
* Add discovered agent to configuration
|
|
411
197
|
* @param {Object} agent - Agent to add
|
|
@@ -422,7 +208,7 @@ class AgentDiscoveryService {
|
|
|
422
208
|
}
|
|
423
209
|
|
|
424
210
|
// Validate agent before adding
|
|
425
|
-
const validation =
|
|
211
|
+
const validation = validateAgent(agent);
|
|
426
212
|
if (!validation.valid) {
|
|
427
213
|
return {
|
|
428
214
|
success: false,
|
|
@@ -437,10 +223,10 @@ class AgentDiscoveryService {
|
|
|
437
223
|
}
|
|
438
224
|
|
|
439
225
|
// Record addition in history
|
|
440
|
-
await
|
|
226
|
+
await recordDiscoveryOperation('add', {
|
|
441
227
|
agentId: agent.id,
|
|
442
228
|
agentName: agent.name
|
|
443
|
-
});
|
|
229
|
+
}, this.fileManager, this.logger);
|
|
444
230
|
|
|
445
231
|
return {
|
|
446
232
|
success: true,
|
|
@@ -465,7 +251,7 @@ class AgentDiscoveryService {
|
|
|
465
251
|
|
|
466
252
|
/**
|
|
467
253
|
* Remove agent from configuration
|
|
468
|
-
* @param {string} agentId - ID
|
|
254
|
+
* @param {string} agentId - Agent ID to remove
|
|
469
255
|
* @returns {Promise<Object>} - Removal result
|
|
470
256
|
*/
|
|
471
257
|
async removeAgent(agentId) {
|
|
@@ -476,35 +262,29 @@ class AgentDiscoveryService {
|
|
|
476
262
|
});
|
|
477
263
|
}
|
|
478
264
|
|
|
479
|
-
//
|
|
480
|
-
let
|
|
265
|
+
// Remove from configuration manager
|
|
266
|
+
let removed = false;
|
|
481
267
|
if (this.configManager) {
|
|
482
|
-
|
|
268
|
+
removed = await this.configManager.removeAgent(agentId);
|
|
483
269
|
}
|
|
484
270
|
|
|
485
|
-
if (!
|
|
271
|
+
if (!removed) {
|
|
486
272
|
return {
|
|
487
273
|
success: false,
|
|
488
|
-
error: 'Agent not found',
|
|
274
|
+
error: 'Agent not found in configuration',
|
|
489
275
|
agentId
|
|
490
276
|
};
|
|
491
277
|
}
|
|
492
278
|
|
|
493
|
-
// Remove from configuration manager
|
|
494
|
-
if (this.configManager) {
|
|
495
|
-
await this.configManager.removeAgent(agentId);
|
|
496
|
-
}
|
|
497
|
-
|
|
498
279
|
// Record removal in history
|
|
499
|
-
await
|
|
500
|
-
agentId
|
|
501
|
-
|
|
502
|
-
});
|
|
280
|
+
await recordDiscoveryOperation('remove', {
|
|
281
|
+
agentId
|
|
282
|
+
}, this.fileManager, this.logger);
|
|
503
283
|
|
|
504
284
|
return {
|
|
505
285
|
success: true,
|
|
506
286
|
agentId,
|
|
507
|
-
message: `Agent ${
|
|
287
|
+
message: `Agent ${agentId} removed successfully`
|
|
508
288
|
};
|
|
509
289
|
} catch (error) {
|
|
510
290
|
if (this.logger) {
|
|
@@ -522,160 +302,6 @@ class AgentDiscoveryService {
|
|
|
522
302
|
}
|
|
523
303
|
}
|
|
524
304
|
|
|
525
|
-
/**
|
|
526
|
-
* Validate agent configuration
|
|
527
|
-
* @param {Object} agent - Agent to validate
|
|
528
|
-
* @returns {Object} - Validation result
|
|
529
|
-
*/
|
|
530
|
-
validateAgent(agent) {
|
|
531
|
-
const errors = [];
|
|
532
|
-
|
|
533
|
-
// Check required fields
|
|
534
|
-
if (!agent.id || !agent.id.trim()) {
|
|
535
|
-
errors.push('Agent ID is required');
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
if (!agent.name || !agent.name.trim()) {
|
|
539
|
-
errors.push('Agent name is required');
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
if (!agent.path || !agent.path.trim()) {
|
|
543
|
-
errors.push('Agent path is required');
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
if (!agent.version || !agent.version.trim()) {
|
|
547
|
-
errors.push('Agent version is required');
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
if (!agent.description || !agent.description.trim()) {
|
|
551
|
-
errors.push('Agent description is required');
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
if (!agent.type || !['CLI', 'GUI'].includes(agent.type)) {
|
|
555
|
-
errors.push('Agent type must be CLI or GUI');
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
return {
|
|
559
|
-
valid: errors.length === 0,
|
|
560
|
-
errors
|
|
561
|
-
};
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* Update discovery status file
|
|
566
|
-
* @param {Array} validAgents - Valid discovered agents
|
|
567
|
-
* @param {number} totalDiscovered - Total agents discovered
|
|
568
|
-
* @param {number} duplicateCount - Number of duplicates removed
|
|
569
|
-
* @param {Array} warnings - Discovery warnings
|
|
570
|
-
* @param {Array} errors - Discovery errors
|
|
571
|
-
*/
|
|
572
|
-
async updateDiscoveryStatus(validAgents, totalDiscovered, duplicateCount, warnings, errors) {
|
|
573
|
-
const status = {
|
|
574
|
-
lastDiscovery: new Date().toISOString(),
|
|
575
|
-
totalDiscovered,
|
|
576
|
-
validAgents,
|
|
577
|
-
duplicates: duplicateCount,
|
|
578
|
-
warnings,
|
|
579
|
-
errors,
|
|
580
|
-
discoveryPaths: this.discoveryPaths
|
|
581
|
-
};
|
|
582
|
-
|
|
583
|
-
if (this.fileManager) {
|
|
584
|
-
await this.fileManager.writeFile('discovery-status', JSON.stringify(status, null, 2));
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
if (this.logger) {
|
|
588
|
-
await this.logger.info('Discovery status updated', {
|
|
589
|
-
totalDiscovered,
|
|
590
|
-
validAgents,
|
|
591
|
-
duplicates: duplicateCount
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* Record discovery operation in history
|
|
598
|
-
* @param {string} operation - Operation type
|
|
599
|
-
* @param {Object} details - Operation details
|
|
600
|
-
*/
|
|
601
|
-
async recordDiscoveryOperation(operation, details) {
|
|
602
|
-
const historyEntry = {
|
|
603
|
-
timestamp: new Date().toISOString(),
|
|
604
|
-
operation,
|
|
605
|
-
...details
|
|
606
|
-
};
|
|
607
|
-
|
|
608
|
-
let history = [];
|
|
609
|
-
if (this.fileManager) {
|
|
610
|
-
try {
|
|
611
|
-
const historyData = await this.fileManager.readFile('discovery-history');
|
|
612
|
-
history = JSON.parse(historyData || '[]');
|
|
613
|
-
} catch (error) {
|
|
614
|
-
// File doesn't exist yet, start with empty history
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
history.push(historyEntry);
|
|
619
|
-
|
|
620
|
-
// Keep only last 100 entries
|
|
621
|
-
if (history.length > 100) {
|
|
622
|
-
history = history.slice(-100);
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
if (this.fileManager) {
|
|
626
|
-
await this.fileManager.writeFile('discovery-history', JSON.stringify(history, null, 2));
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
if (this.logger) {
|
|
630
|
-
await this.logger.info('Discovery operation recorded', {
|
|
631
|
-
operation,
|
|
632
|
-
details
|
|
633
|
-
});
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
/**
|
|
638
|
-
* Get discovery status
|
|
639
|
-
* @returns {Promise<Object>} - Discovery status
|
|
640
|
-
*/
|
|
641
|
-
async getDiscoveryStatus() {
|
|
642
|
-
try {
|
|
643
|
-
if (this.fileManager) {
|
|
644
|
-
const statusData = await this.fileManager.readFile('discovery-status');
|
|
645
|
-
return {
|
|
646
|
-
success: true,
|
|
647
|
-
status: JSON.parse(statusData || '{}')
|
|
648
|
-
};
|
|
649
|
-
}
|
|
650
|
-
} catch (error) {
|
|
651
|
-
return {
|
|
652
|
-
success: false,
|
|
653
|
-
error: 'Discovery status file not found'
|
|
654
|
-
};
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
/**
|
|
659
|
-
* Get discovery history
|
|
660
|
-
* @returns {Promise<Object>} - Discovery history
|
|
661
|
-
*/
|
|
662
|
-
async getDiscoveryHistory() {
|
|
663
|
-
try {
|
|
664
|
-
if (this.fileManager) {
|
|
665
|
-
const historyData = await this.fileManager.readFile('discovery-history');
|
|
666
|
-
return {
|
|
667
|
-
success: true,
|
|
668
|
-
history: JSON.parse(historyData || '[]')
|
|
669
|
-
};
|
|
670
|
-
}
|
|
671
|
-
} catch (error) {
|
|
672
|
-
return {
|
|
673
|
-
success: false,
|
|
674
|
-
error: 'Discovery history file not found'
|
|
675
|
-
};
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
|
|
679
305
|
/**
|
|
680
306
|
* Get service information
|
|
681
307
|
* @returns {Object} - Service info
|