vibecodingmachine-core 2026.2.20-438 → 2026.2.26-1642
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 +240 -0
- package/package.json +10 -2
- package/src/agents/Agent.js +300 -0
- package/src/agents/AgentAdditionService.js +311 -0
- package/src/agents/AgentCheckService.js +690 -0
- package/src/agents/AgentInstallationService.js +140 -0
- package/src/agents/AgentSetupService.js +467 -0
- package/src/agents/AgentStatus.js +183 -0
- package/src/agents/AgentVerificationService.js +634 -0
- package/src/agents/ConfigurationSchemaValidator.js +543 -0
- package/src/agents/EnvironmentConfigurationManager.js +602 -0
- package/src/agents/InstallationErrorHandler.js +372 -0
- package/src/agents/InstallationLog.js +363 -0
- package/src/agents/InstallationMethod.js +510 -0
- package/src/agents/InstallationOrchestrator.js +352 -0
- package/src/agents/InstallationProgressReporter.js +372 -0
- package/src/agents/InstallationRetryManager.js +322 -0
- package/src/agents/InstallationType.js +254 -0
- package/src/agents/OperationTypes.js +310 -0
- package/src/agents/PerformanceMetricsCollector.js +493 -0
- package/src/agents/SecurityValidationService.js +534 -0
- package/src/agents/VerificationTest.js +354 -0
- package/src/agents/VerificationType.js +226 -0
- package/src/agents/WindowsPermissionHandler.js +518 -0
- package/src/agents/config/AgentConfigManager.js +393 -0
- package/src/agents/config/AgentDefaultsRegistry.js +373 -0
- package/src/agents/config/ConfigValidator.js +281 -0
- package/src/agents/discovery/AgentDiscoveryService.js +707 -0
- package/src/agents/logging/AgentLogger.js +511 -0
- package/src/agents/status/AgentStatusManager.js +481 -0
- package/src/agents/storage/FileManager.js +454 -0
- package/src/agents/verification/AgentCommunicationTester.js +474 -0
- package/src/agents/verification/BaseVerifier.js +430 -0
- package/src/agents/verification/CommandVerifier.js +480 -0
- package/src/agents/verification/FileOperationVerifier.js +453 -0
- package/src/agents/verification/ResultAnalyzer.js +707 -0
- package/src/agents/verification/TestRequirementManager.js +495 -0
- package/src/agents/verification/VerificationRunner.js +433 -0
- package/src/agents/windows/BaseWindowsInstaller.js +441 -0
- package/src/agents/windows/ChocolateyInstaller.js +509 -0
- package/src/agents/windows/DirectInstaller.js +443 -0
- package/src/agents/windows/InstallerFactory.js +391 -0
- package/src/agents/windows/NpmInstaller.js +505 -0
- package/src/agents/windows/PowerShellInstaller.js +458 -0
- package/src/agents/windows/WinGetInstaller.js +390 -0
- package/src/analysis/analysis-reporter.js +132 -0
- package/src/analysis/boundary-detector.js +712 -0
- package/src/analysis/categorizer.js +340 -0
- package/src/analysis/codebase-scanner.js +384 -0
- package/src/analysis/line-counter.js +513 -0
- package/src/analysis/priority-calculator.js +679 -0
- package/src/analysis/report/analysis-report.js +250 -0
- package/src/analysis/report/package-analyzer.js +278 -0
- package/src/analysis/report/recommendation-generator.js +382 -0
- package/src/analysis/report/statistics-generator.js +515 -0
- package/src/analysis/reports/analysis-report-model.js +101 -0
- package/src/analysis/reports/recommendation-generator.js +283 -0
- package/src/analysis/reports/report-generators.js +191 -0
- package/src/analysis/reports/statistics-calculator.js +231 -0
- package/src/analysis/reports/trend-analyzer.js +219 -0
- package/src/analysis/strategy-generator.js +814 -0
- package/src/auto-mode/AutoModeBusinessLogic.js +836 -0
- package/src/config/refactoring-config.js +307 -0
- package/src/health-tracking/json-storage.js +38 -2
- package/src/ide-integration/applescript-manager-core.js +233 -0
- package/src/ide-integration/applescript-manager.cjs +357 -28
- package/src/ide-integration/applescript-manager.js +89 -3599
- package/src/ide-integration/cdp-manager.js +306 -0
- package/src/ide-integration/claude-code-cli-manager.cjs +1 -1
- package/src/ide-integration/continuation-handler.js +337 -0
- package/src/ide-integration/ide-status-checker.js +292 -0
- package/src/ide-integration/macos-ide-manager.js +627 -0
- package/src/ide-integration/macos-text-sender.js +528 -0
- package/src/ide-integration/response-reader.js +548 -0
- package/src/ide-integration/windows-automation-manager.js +121 -0
- package/src/ide-integration/windows-ide-manager.js +373 -0
- package/src/index.cjs +25 -3
- package/src/index.js +15 -1
- package/src/llm/direct-llm-manager.cjs +90 -2
- package/src/models/compliance-report.js +538 -0
- package/src/models/file-analysis.js +681 -0
- package/src/models/refactoring-plan.js +770 -0
- package/src/monitoring/alert-system.js +834 -0
- package/src/monitoring/compliance-progress-tracker.js +437 -0
- package/src/monitoring/continuous-scan-notifications.js +661 -0
- package/src/monitoring/continuous-scanner.js +279 -0
- package/src/monitoring/file-monitor/file-analyzer.js +262 -0
- package/src/monitoring/file-monitor/file-monitor.js +237 -0
- package/src/monitoring/file-monitor/watcher.js +194 -0
- package/src/monitoring/file-monitor.js +17 -0
- package/src/monitoring/notification-manager.js +437 -0
- package/src/monitoring/scanner-core.js +368 -0
- package/src/monitoring/scanner-events.js +214 -0
- package/src/monitoring/violation-notification-system.js +515 -0
- package/src/refactoring/boundaries/cohesion-analyzer.js +316 -0
- package/src/refactoring/boundaries/extraction-result.js +285 -0
- package/src/refactoring/boundaries/extraction-strategies.js +392 -0
- package/src/refactoring/boundaries/module-boundary.js +209 -0
- package/src/refactoring/boundary/boundary-detector.js +741 -0
- package/src/refactoring/boundary/boundary-types.js +405 -0
- package/src/refactoring/boundary/extraction-strategies.js +554 -0
- package/src/refactoring/boundary-extraction-result.js +77 -0
- package/src/refactoring/boundary-extraction-strategies.js +330 -0
- package/src/refactoring/boundary-extractor.js +384 -0
- package/src/refactoring/boundary-types.js +46 -0
- package/src/refactoring/circular/circular-dependency.js +88 -0
- package/src/refactoring/circular/cycle-detection.js +147 -0
- package/src/refactoring/circular/dependency-node.js +82 -0
- package/src/refactoring/circular/dependency-result.js +107 -0
- package/src/refactoring/circular/dependency-types.js +58 -0
- package/src/refactoring/circular/graph-builder.js +213 -0
- package/src/refactoring/circular/resolution-strategy.js +72 -0
- package/src/refactoring/circular/strategy-generator.js +229 -0
- package/src/refactoring/circular-dependency-resolver-original.js +809 -0
- package/src/refactoring/circular-dependency-resolver.js +200 -0
- package/src/refactoring/code-mover.js +761 -0
- package/src/refactoring/file-splitter.js +696 -0
- package/src/refactoring/functionality-validator.js +816 -0
- package/src/refactoring/import-manager.js +774 -0
- package/src/refactoring/module-boundary.js +107 -0
- package/src/refactoring/refactoring-executor.js +672 -0
- package/src/refactoring/refactoring-rollback.js +614 -0
- package/src/refactoring/test-validator.js +631 -0
- package/src/requirement-management/default-requirement-manager.js +321 -0
- package/src/requirement-management/requirement-file-parser.js +159 -0
- package/src/requirement-management/requirement-sequencer.js +221 -0
- package/src/rui/commands/AgentCommandParser.js +600 -0
- package/src/rui/commands/AgentCommands.js +487 -0
- package/src/rui/commands/AgentResponseFormatter.js +832 -0
- package/src/scripts/verify-full-compliance.js +269 -0
- package/src/sync/sync-engine-core.js +1 -0
- package/src/sync/sync-engine-remote-handlers.js +135 -0
- package/src/task-generation/automated-task-generator.js +351 -0
- package/src/task-generation/prioritizer.js +287 -0
- package/src/task-generation/task-list-updater.js +215 -0
- package/src/task-generation/task-management-integration.js +480 -0
- package/src/task-generation/task-manager-integration.js +270 -0
- package/src/task-generation/violation-task-generator.js +474 -0
- package/src/task-management/continuous-scan-integration.js +342 -0
- package/src/timeout-management/index.js +12 -3
- package/src/timeout-management/response-time-tracker.js +167 -0
- package/src/timeout-management/timeout-calculator.js +159 -0
- package/src/timeout-management/timeout-config-manager.js +172 -0
- package/src/utils/ast-analyzer.js +417 -0
- package/src/utils/current-requirement-manager.js +276 -0
- package/src/utils/current-requirement-operations.js +472 -0
- package/src/utils/dependency-mapper.js +456 -0
- package/src/utils/download-with-progress.js +4 -2
- package/src/utils/electron-update-checker.js +4 -1
- package/src/utils/file-size-analyzer.js +272 -0
- package/src/utils/import-updater.js +280 -0
- package/src/utils/refactoring-tools.js +512 -0
- package/src/utils/report-generator.js +569 -0
- package/src/utils/reports/report-analysis.js +218 -0
- package/src/utils/reports/report-types.js +55 -0
- package/src/utils/reports/summary-generators.js +102 -0
- package/src/utils/requirement-file-management.js +157 -0
- package/src/utils/requirement-helpers/requirement-file-ops.js +392 -0
- package/src/utils/requirement-helpers/requirement-mover.js +414 -0
- package/src/utils/requirement-helpers/requirement-parser.js +326 -0
- package/src/utils/requirement-helpers/requirement-status.js +320 -0
- package/src/utils/requirement-helpers-new.js +55 -0
- package/src/utils/requirement-helpers-refactored.js +367 -0
- package/src/utils/requirement-helpers.js +291 -1191
- package/src/utils/requirement-movement-operations.js +450 -0
- package/src/utils/requirement-movement.js +312 -0
- package/src/utils/requirement-parsing-helpers.js +56 -0
- package/src/utils/requirement-statistics.js +200 -0
- package/src/utils/requirement-text-utils.js +58 -0
- package/src/utils/rollback/rollback-handlers.js +125 -0
- package/src/utils/rollback/rollback-operation.js +63 -0
- package/src/utils/rollback/rollback-recorder.js +166 -0
- package/src/utils/rollback/rollback-state-manager.js +175 -0
- package/src/utils/rollback/rollback-types.js +33 -0
- package/src/utils/rollback/rollback-utils.js +110 -0
- package/src/utils/rollback-manager-original.js +569 -0
- package/src/utils/rollback-manager.js +202 -0
- package/src/utils/smoke-test-cli.js +362 -0
- package/src/utils/smoke-test-gui.js +351 -0
- package/src/utils/smoke-test-orchestrator.js +321 -0
- package/src/utils/smoke-test-runner.js +60 -0
- package/src/utils/smoke-test-web.js +347 -0
- package/src/utils/specification-helpers.js +39 -13
- package/src/utils/specification-migration.js +97 -0
- package/src/utils/test-runner.js +579 -0
- package/src/utils/validation-framework.js +518 -0
- package/src/validation/compliance-analyzer.js +197 -0
- package/src/validation/compliance-report-generator.js +343 -0
- package/src/validation/compliance-reporter.js +711 -0
- package/src/validation/compliance-rules.js +127 -0
- package/src/validation/constitution-validator-new.js +196 -0
- package/src/validation/constitution-validator.js +17 -0
- package/src/validation/file-validators.js +170 -0
- package/src/validation/line-limit/file-analyzer.js +201 -0
- package/src/validation/line-limit/line-limit-validator.js +208 -0
- package/src/validation/line-limit/validation-result.js +144 -0
- package/src/validation/line-limit-core.js +225 -0
- package/src/validation/line-limit-reporter.js +134 -0
- package/src/validation/line-limit-result.js +125 -0
- package/src/validation/line-limit-validator.js +41 -0
- package/src/validation/metrics-calculator.js +660 -0
- package/src/sync/sync-engine-backup.js +0 -559
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Verification Service
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates agent verification across multiple verifiers.
|
|
5
|
+
* Follows constitutional requirements: <555 lines, test-first approach.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const VerificationRunner = require('./verification/VerificationRunner');
|
|
9
|
+
const AgentCommunicationTester = require('./verification/AgentCommunicationTester');
|
|
10
|
+
const TestRequirementManager = require('./verification/TestRequirementManager');
|
|
11
|
+
const ResultAnalyzer = require('./verification/ResultAnalyzer');
|
|
12
|
+
const { VerificationType } = require('./VerificationType');
|
|
13
|
+
const { OperationType, OperationStatus } = require('./OperationTypes');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Agent verification service class
|
|
17
|
+
*/
|
|
18
|
+
class AgentVerificationService {
|
|
19
|
+
/**
|
|
20
|
+
* Create verification service instance
|
|
21
|
+
* @param {Object} config - Service configuration
|
|
22
|
+
*/
|
|
23
|
+
constructor(config = {}) {
|
|
24
|
+
this.configManager = config.configManager || null;
|
|
25
|
+
this.logger = config.logger || null;
|
|
26
|
+
this.fileManager = config.fileManager || null;
|
|
27
|
+
this.parallel = config.parallel !== false; // Default to parallel
|
|
28
|
+
this.maxConcurrency = config.maxConcurrency || 3;
|
|
29
|
+
this.timeout = config.timeout || 180000; // 3 minutes default
|
|
30
|
+
this.continueOnFailure = config.continueOnFailure !== false; // Default to continue
|
|
31
|
+
this.skipVerification = config.skipVerification || false;
|
|
32
|
+
this.enableCommunicationTesting = config.enableCommunicationTesting !== false;
|
|
33
|
+
|
|
34
|
+
// Initialize communication testing components
|
|
35
|
+
if (this.enableCommunicationTesting) {
|
|
36
|
+
this.testManager = new TestRequirementManager({
|
|
37
|
+
logger: this.logger,
|
|
38
|
+
...config.testManagerOptions
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
this.communicationTester = new AgentCommunicationTester({
|
|
42
|
+
testManager: this.testManager,
|
|
43
|
+
logger: this.logger,
|
|
44
|
+
timeout: this.timeout,
|
|
45
|
+
maxConcurrentTests: this.maxConcurrency,
|
|
46
|
+
continueOnFailure: this.continueOnFailure,
|
|
47
|
+
...config.communicationTesterOptions
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
this.resultAnalyzer = new ResultAnalyzer({
|
|
51
|
+
logger: this.logger,
|
|
52
|
+
detailedAnalysis: config.detailedAnalysis !== false,
|
|
53
|
+
...config.analyzerOptions
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Verify agent using available verifiers
|
|
60
|
+
* @param {Object} agent - Agent to verify
|
|
61
|
+
* @param {Object} options - Verification options
|
|
62
|
+
* @returns {Promise<Object>} - Verification result
|
|
63
|
+
*/
|
|
64
|
+
async verifyAgent(agent, options = {}) {
|
|
65
|
+
const { skipVerification = this.skipVerification, testTypes = null, timeout = this.timeout } = options;
|
|
66
|
+
|
|
67
|
+
if (skipVerification) {
|
|
68
|
+
return {
|
|
69
|
+
success: true,
|
|
70
|
+
agentId: agent.id,
|
|
71
|
+
skipped: true,
|
|
72
|
+
message: 'Verification skipped by configuration',
|
|
73
|
+
timestamp: new Date().toISOString()
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (this.logger) {
|
|
78
|
+
await this.logger.info('Starting agent verification', {
|
|
79
|
+
agentId: agent.id,
|
|
80
|
+
agentName: agent.name,
|
|
81
|
+
testTypes,
|
|
82
|
+
timeout
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const startTime = Date.now();
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
// Update agent status to VERIFYING
|
|
90
|
+
await this.updateAgentStatus(agent.id, AgentStatus.VERIFYING, 'Starting verification');
|
|
91
|
+
|
|
92
|
+
// Create verification test configurations
|
|
93
|
+
const testConfigs = this.createTestConfigs(agent, testTypes);
|
|
94
|
+
|
|
95
|
+
if (testConfigs.length === 0) {
|
|
96
|
+
throw new Error('No verification tests configured for agent');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Run verification tests
|
|
100
|
+
const runner = VerificationRunner.createDefault({
|
|
101
|
+
parallel: this.parallel,
|
|
102
|
+
maxConcurrency: this.maxConcurrency,
|
|
103
|
+
timeout,
|
|
104
|
+
continueOnFailure: this.continueOnFailure,
|
|
105
|
+
logger: this.logger
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const verificationResult = await runner.runVerificationTests(agent, testConfigs);
|
|
109
|
+
|
|
110
|
+
// Run communication tests if enabled
|
|
111
|
+
let communicationResult = null;
|
|
112
|
+
if (this.enableCommunicationTesting) {
|
|
113
|
+
if (this.logger) {
|
|
114
|
+
await this.logger.info('Starting agent communication testing', {
|
|
115
|
+
agentId: agent.id,
|
|
116
|
+
agentName: agent.name
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
communicationResult = await this.communicationTester.testCommunication(agent, {
|
|
121
|
+
testTypes: [VerificationType.FILE_OPERATION, VerificationType.COMMAND_EXECUTION]
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
if (this.logger) {
|
|
125
|
+
await this.logger.info('Agent communication testing completed', {
|
|
126
|
+
agentId: agent.id,
|
|
127
|
+
success: communicationResult.success,
|
|
128
|
+
summary: communicationResult.summary
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Combine results and determine overall status
|
|
134
|
+
const standardTestsPassed = verificationResult.summary.allPassed;
|
|
135
|
+
const communicationTestsPassed = !communicationResult || communicationResult.success;
|
|
136
|
+
const allPassed = standardTestsPassed && communicationTestsPassed;
|
|
137
|
+
|
|
138
|
+
const finalStatus = allPassed ? AgentStatus.VERIFIED : AgentStatus.ERROR;
|
|
139
|
+
const message = allPassed ? 'All verification tests passed' : 'Some verification tests failed';
|
|
140
|
+
|
|
141
|
+
// Analyze results if analyzer is available
|
|
142
|
+
let analysis = null;
|
|
143
|
+
if (this.resultAnalyzer) {
|
|
144
|
+
const combinedResult = {
|
|
145
|
+
success: allPassed,
|
|
146
|
+
agentId: agent.id,
|
|
147
|
+
results: [
|
|
148
|
+
...verificationResult.results,
|
|
149
|
+
...(communicationResult ? communicationResult.results : [])
|
|
150
|
+
],
|
|
151
|
+
summary: {
|
|
152
|
+
...verificationResult.summary,
|
|
153
|
+
communicationTests: communicationResult ? communicationResult.summary : null
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
analysis = this.resultAnalyzer.analyzeAgentResult(combinedResult);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Update agent status
|
|
161
|
+
await this.updateAgentStatus(agent.id, finalStatus, message);
|
|
162
|
+
|
|
163
|
+
const duration = Date.now() - startTime;
|
|
164
|
+
|
|
165
|
+
// Log verification result
|
|
166
|
+
await this.logVerification(agent, verificationResult, duration);
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
success: allPassed,
|
|
170
|
+
agentId: agent.id,
|
|
171
|
+
skipped: false,
|
|
172
|
+
finalStatus,
|
|
173
|
+
message,
|
|
174
|
+
duration,
|
|
175
|
+
result: verificationResult,
|
|
176
|
+
communicationResult,
|
|
177
|
+
analysis,
|
|
178
|
+
timestamp: new Date().toISOString()
|
|
179
|
+
};
|
|
180
|
+
} catch (error) {
|
|
181
|
+
const duration = Date.now() - startTime;
|
|
182
|
+
|
|
183
|
+
// Update agent status to ERROR
|
|
184
|
+
await this.updateAgentStatus(agent.id, AgentStatus.ERROR, error.message);
|
|
185
|
+
|
|
186
|
+
// Log verification failure
|
|
187
|
+
await this.logVerificationFailure(agent, error, duration);
|
|
188
|
+
|
|
189
|
+
return {
|
|
190
|
+
success: false,
|
|
191
|
+
agentId: agent.id,
|
|
192
|
+
skipped: false,
|
|
193
|
+
error: error.message,
|
|
194
|
+
duration,
|
|
195
|
+
timestamp: new Date().toISOString()
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Verify multiple agents
|
|
202
|
+
* @param {Array<Object>} agents - Agents to verify
|
|
203
|
+
* @param {Object} options - Verification options
|
|
204
|
+
* @returns {Promise<Object>} - Batch verification result
|
|
205
|
+
*/
|
|
206
|
+
async verifyAgents(agents, options = {}) {
|
|
207
|
+
if (this.logger) {
|
|
208
|
+
await this.logger.info('Starting batch agent verification', {
|
|
209
|
+
agentCount: agents.length,
|
|
210
|
+
parallel: this.parallel,
|
|
211
|
+
maxConcurrency: this.maxConcurrency
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const startTime = Date.now();
|
|
216
|
+
const results = {
|
|
217
|
+
totalAgents: agents.length,
|
|
218
|
+
successful: 0,
|
|
219
|
+
failed: 0,
|
|
220
|
+
skipped: 0,
|
|
221
|
+
duration: 0,
|
|
222
|
+
results: {},
|
|
223
|
+
summary: {
|
|
224
|
+
allSuccessful: false,
|
|
225
|
+
hasFailures: false,
|
|
226
|
+
hasSkipped: false
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
try {
|
|
231
|
+
if (this.parallel) {
|
|
232
|
+
// Verify agents in parallel with concurrency limit
|
|
233
|
+
const batches = this.createBatches(agents, this.maxConcurrency);
|
|
234
|
+
|
|
235
|
+
for (const batch of batches) {
|
|
236
|
+
const batchResults = await this.verifyBatchInParallel(batch, options);
|
|
237
|
+
this.mergeBatchResults(results, batchResults);
|
|
238
|
+
}
|
|
239
|
+
} else {
|
|
240
|
+
// Verify agents sequentially
|
|
241
|
+
for (const agent of agents) {
|
|
242
|
+
const result = await this.verifyAgent(agent, options);
|
|
243
|
+
this.addVerificationResult(results, result);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
} catch (error) {
|
|
247
|
+
if (this.logger) {
|
|
248
|
+
await this.logger.error('Batch verification error', {
|
|
249
|
+
agentCount: agents.length,
|
|
250
|
+
error: error.message
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Add error as failed verification for all agents
|
|
255
|
+
for (const agent of agents) {
|
|
256
|
+
const errorResult = {
|
|
257
|
+
success: false,
|
|
258
|
+
agentId: agent.id,
|
|
259
|
+
error: error.message,
|
|
260
|
+
duration: 0,
|
|
261
|
+
timestamp: new Date().toISOString()
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
this.addVerificationResult(results, errorResult);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
results.duration = Date.now() - startTime;
|
|
269
|
+
this.calculateSummary(results);
|
|
270
|
+
|
|
271
|
+
if (this.logger) {
|
|
272
|
+
await this.logger.info('Batch verification completed', {
|
|
273
|
+
totalAgents: results.totalAgents,
|
|
274
|
+
successful: results.successful,
|
|
275
|
+
failed: results.failed,
|
|
276
|
+
skipped: results.skipped,
|
|
277
|
+
duration: results.duration,
|
|
278
|
+
allSuccessful: results.summary.allSuccessful
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return results;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Verify a batch of agents in parallel
|
|
287
|
+
* @param {Array<Object>} batch - Batch of agents
|
|
288
|
+
* @param {Object} options - Verification options
|
|
289
|
+
* @returns {Promise<Array<Object>>} - Batch results
|
|
290
|
+
*/
|
|
291
|
+
async verifyBatchInParallel(batch, options) {
|
|
292
|
+
const promises = batch.map(agent =>
|
|
293
|
+
this.verifyAgent(agent, options)
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
return Promise.allSettled(promises);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Merge batch results into main results
|
|
301
|
+
* @param {Object} results - Main results
|
|
302
|
+
* @param {Array<Object>} batchResults - Batch results
|
|
303
|
+
*/
|
|
304
|
+
mergeBatchResults(results, batchResults) {
|
|
305
|
+
for (const batchResult of batchResults) {
|
|
306
|
+
if (batchResult.status === 'fulfilled') {
|
|
307
|
+
this.addVerificationResult(results, batchResult.value);
|
|
308
|
+
} else {
|
|
309
|
+
// Handle rejected promise
|
|
310
|
+
const errorResult = {
|
|
311
|
+
success: false,
|
|
312
|
+
agentId: 'unknown',
|
|
313
|
+
error: batchResult.reason?.message || 'Unknown error',
|
|
314
|
+
duration: 0,
|
|
315
|
+
timestamp: new Date().toISOString()
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
this.addVerificationResult(results, errorResult);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Add verification result to results collection
|
|
325
|
+
* @param {Object} results - Results collection
|
|
326
|
+
* @param {Object} result - New result to add
|
|
327
|
+
*/
|
|
328
|
+
addVerificationResult(results, result) {
|
|
329
|
+
results.results[result.agentId] = result;
|
|
330
|
+
|
|
331
|
+
if (result.success) {
|
|
332
|
+
results.successful++;
|
|
333
|
+
} else {
|
|
334
|
+
results.failed++;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (result.skipped) {
|
|
338
|
+
results.skipped++;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Calculate summary statistics
|
|
344
|
+
* @param {Object} results - Results collection
|
|
345
|
+
*/
|
|
346
|
+
calculateSummary(results) {
|
|
347
|
+
results.summary = {
|
|
348
|
+
allSuccessful: results.failed === 0 && results.successful === results.totalAgents,
|
|
349
|
+
hasFailures: results.failed > 0,
|
|
350
|
+
hasSkipped: results.skipped > 0,
|
|
351
|
+
successRate: results.totalAgents > 0 ? (results.successful / results.totalAgents) * 100 : 0,
|
|
352
|
+
failureRate: results.totalAgents > 0 ? (results.failed / results.totalAgents) * 100 : 0
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Create verification test configurations for an agent
|
|
358
|
+
* @param {Object} agent - Agent configuration
|
|
359
|
+
* @param {Array<string>} testTypes - Specific test types to run
|
|
360
|
+
* @returns {Array<Object>} - Test configurations
|
|
361
|
+
*/
|
|
362
|
+
createTestConfigs(agent, testTypes = null) {
|
|
363
|
+
const testConfigs = [];
|
|
364
|
+
|
|
365
|
+
// Use agent's verification commands if available
|
|
366
|
+
if (agent.verificationCommands && agent.verificationCommands.length > 0) {
|
|
367
|
+
for (const command of agent.verificationCommands) {
|
|
368
|
+
testConfigs.push({
|
|
369
|
+
type: VerificationType.COMMAND_EXECUTION,
|
|
370
|
+
description: `Verify ${command}`,
|
|
371
|
+
command: command,
|
|
372
|
+
expectedResult: 'version',
|
|
373
|
+
timeout: 15,
|
|
374
|
+
agentCommand: command
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// Add file operation test
|
|
380
|
+
if (!testTypes || testTypes.includes(VerificationType.FILE_OPERATION)) {
|
|
381
|
+
testConfigs.push({
|
|
382
|
+
type: VerificationType.FILE_OPERATION,
|
|
383
|
+
description: 'File create/read/delete test',
|
|
384
|
+
command: 'echo "test-requirement-{timestamp}" > test-requirement-{timestamp}.txt && cat test-requirement-{timestamp}.txt && rm test-requirement-{timestamp}.txt',
|
|
385
|
+
expectedResult: 'test-requirement-{timestamp}',
|
|
386
|
+
timeout: 10
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// Filter by requested test types
|
|
391
|
+
if (testTypes) {
|
|
392
|
+
return testConfigs.filter(config => testTypes.includes(config.type));
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
return testConfigs;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Create batches for parallel execution
|
|
400
|
+
* @param {Array<Object>} items - Items to batch
|
|
401
|
+
* @param {number} batchSize - Maximum batch size
|
|
402
|
+
* @returns {Array<Array<Object>>} - Array of batches
|
|
403
|
+
*/
|
|
404
|
+
createBatches(items, batchSize) {
|
|
405
|
+
const batches = [];
|
|
406
|
+
|
|
407
|
+
for (let i = 0; i < items.length; i += batchSize) {
|
|
408
|
+
batches.push(items.slice(i, i + batchSize));
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
return batches;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Update agent status
|
|
416
|
+
* @param {string} agentId - Agent identifier
|
|
417
|
+
* @param {string} status - New status
|
|
418
|
+
* @param {string} message - Status message
|
|
419
|
+
*/
|
|
420
|
+
async updateAgentStatus(agentId, status, message = '') {
|
|
421
|
+
if (this.configManager) {
|
|
422
|
+
await this.configManager.updateAgentStatus(agentId, status, message);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Log successful verification
|
|
428
|
+
* @param {Object} agent - Agent configuration
|
|
429
|
+
* @param {Object} result - Verification result
|
|
430
|
+
* @param {number} duration - Verification duration
|
|
431
|
+
*/
|
|
432
|
+
async logVerification(agent, result, duration) {
|
|
433
|
+
if (this.fileManager) {
|
|
434
|
+
await this.fileManager.writeLog('verification', {
|
|
435
|
+
agentId: agent.id,
|
|
436
|
+
operation: OperationType.VERIFY,
|
|
437
|
+
status: result.summary.allPassed ? OperationStatus.COMPLETED : OperationStatus.FAILED,
|
|
438
|
+
message: `Verification ${result.summary.allPassed ? 'passed' : 'failed'} for ${agent.name}`,
|
|
439
|
+
duration,
|
|
440
|
+
result,
|
|
441
|
+
summary: result.summary,
|
|
442
|
+
timestamp: new Date().toISOString()
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Log verification failure
|
|
449
|
+
* @param {Object} agent - Agent configuration
|
|
450
|
+
* @param {Error} error - Verification error
|
|
451
|
+
* @param {number} duration - Verification duration
|
|
452
|
+
*/
|
|
453
|
+
async logVerificationFailure(agent, error, duration) {
|
|
454
|
+
if (this.fileManager) {
|
|
455
|
+
await this.fileManager.writeLog('verification', {
|
|
456
|
+
agentId: agent.id,
|
|
457
|
+
operation: OperationType.VERIFY,
|
|
458
|
+
status: OperationStatus.FAILED,
|
|
459
|
+
message: `Verification failed for ${agent.name}: ${error.message}`,
|
|
460
|
+
duration,
|
|
461
|
+
error: error.message,
|
|
462
|
+
timestamp: new Date().toISOString()
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Get verification statistics for agents
|
|
469
|
+
* @param {Array<Object>} agents - Agents to get stats for
|
|
470
|
+
* @returns {Promise<Object>} - Verification statistics
|
|
471
|
+
*/
|
|
472
|
+
async getVerificationStats(agents) {
|
|
473
|
+
const stats = {
|
|
474
|
+
totalAgents: agents.length,
|
|
475
|
+
verified: 0,
|
|
476
|
+
notVerified: 0,
|
|
477
|
+
error: 0,
|
|
478
|
+
disabled: 0,
|
|
479
|
+
lastVerified: null,
|
|
480
|
+
verificationRate: 0
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
for (const agent of agents) {
|
|
484
|
+
const status = await this.configManager.getAgentStatus(agent.id);
|
|
485
|
+
|
|
486
|
+
if (status) {
|
|
487
|
+
switch (status.status) {
|
|
488
|
+
case AgentStatus.VERIFIED:
|
|
489
|
+
stats.verified++;
|
|
490
|
+
break;
|
|
491
|
+
case AgentStatus.ERROR:
|
|
492
|
+
stats.error++;
|
|
493
|
+
break;
|
|
494
|
+
case AgentStatus.DISABLED:
|
|
495
|
+
stats.disabled++;
|
|
496
|
+
break;
|
|
497
|
+
default:
|
|
498
|
+
stats.notVerified++;
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// Track most recent verification
|
|
503
|
+
if (status.lastChecked) {
|
|
504
|
+
const lastChecked = new Date(status.lastChecked);
|
|
505
|
+
if (!stats.lastVerified || lastChecked > stats.lastVerified) {
|
|
506
|
+
stats.lastVerified = status.lastChecked;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
} else {
|
|
510
|
+
stats.notVerified++;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// Calculate verification rate
|
|
515
|
+
const checkableAgents = stats.verified + stats.notVerified + stats.error;
|
|
516
|
+
stats.verificationRate = checkableAgents > 0 ? (stats.verified / checkableAgents) * 100 : 0;
|
|
517
|
+
|
|
518
|
+
return stats;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Cleanup old test requirement files
|
|
523
|
+
* @param {number} maxAge - Maximum age in milliseconds
|
|
524
|
+
* @returns {Promise<Object>} - Cleanup result
|
|
525
|
+
*/
|
|
526
|
+
async cleanupTestRequirements(maxAge = 3600000) { // 1 hour default
|
|
527
|
+
if (!this.enableCommunicationTesting || !this.testManager) {
|
|
528
|
+
return {
|
|
529
|
+
success: false,
|
|
530
|
+
error: 'Communication testing not enabled'
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
try {
|
|
535
|
+
const result = await this.testManager.cleanupOldFiles(maxAge);
|
|
536
|
+
|
|
537
|
+
if (this.logger) {
|
|
538
|
+
await this.logger.info('Test requirement cleanup completed', {
|
|
539
|
+
maxAge,
|
|
540
|
+
cleanedCount: result.cleanedCount,
|
|
541
|
+
errorCount: result.errorCount
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
return result;
|
|
546
|
+
} catch (error) {
|
|
547
|
+
if (this.logger) {
|
|
548
|
+
await this.logger.error('Test requirement cleanup failed', {
|
|
549
|
+
maxAge,
|
|
550
|
+
error: error.message
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
return {
|
|
555
|
+
success: false,
|
|
556
|
+
error: error.message,
|
|
557
|
+
maxAge
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Get verification service information
|
|
564
|
+
* @returns {Object} - Service info
|
|
565
|
+
*/
|
|
566
|
+
getServiceInfo() {
|
|
567
|
+
return {
|
|
568
|
+
parallel: this.parallel,
|
|
569
|
+
maxConcurrency: this.maxConcurrency,
|
|
570
|
+
timeout: this.timeout,
|
|
571
|
+
continueOnFailure: this.continueOnFailure,
|
|
572
|
+
skipVerification: this.skipVerification,
|
|
573
|
+
enableCommunicationTesting: this.enableCommunicationTesting,
|
|
574
|
+
supportedTestTypes: [
|
|
575
|
+
VerificationType.FILE_OPERATION,
|
|
576
|
+
VerificationType.COMMAND_EXECUTION
|
|
577
|
+
// TODO: Add API_CALL and NETWORK_TEST when implemented
|
|
578
|
+
],
|
|
579
|
+
features: [
|
|
580
|
+
'parallel verification',
|
|
581
|
+
'multiple test types',
|
|
582
|
+
'batch processing',
|
|
583
|
+
'error handling',
|
|
584
|
+
'status management',
|
|
585
|
+
'statistics collection',
|
|
586
|
+
'logging integration',
|
|
587
|
+
'communication testing',
|
|
588
|
+
'test requirement management',
|
|
589
|
+
'result analysis',
|
|
590
|
+
'automated cleanup'
|
|
591
|
+
],
|
|
592
|
+
limitations: [
|
|
593
|
+
'limited to implemented verifiers',
|
|
594
|
+
'depends on agent configuration',
|
|
595
|
+
'timeout affects all tests',
|
|
596
|
+
'memory usage with parallel tests'
|
|
597
|
+
]
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Create verification service with default configuration
|
|
603
|
+
* @param {Object} config - Configuration overrides
|
|
604
|
+
* @returns {AgentVerificationService} - Service instance
|
|
605
|
+
*/
|
|
606
|
+
static createDefault(config = {}) {
|
|
607
|
+
return new AgentVerificationService({
|
|
608
|
+
parallel: true,
|
|
609
|
+
maxConcurrency: 3,
|
|
610
|
+
timeout: 180000,
|
|
611
|
+
continueOnFailure: true,
|
|
612
|
+
skipVerification: false,
|
|
613
|
+
...config
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Create verification service for sequential execution
|
|
619
|
+
* @param {Object} config - Configuration overrides
|
|
620
|
+
* @returns {AgentVerificationService} - Sequential service instance
|
|
621
|
+
*/
|
|
622
|
+
static createSequential(config = {}) {
|
|
623
|
+
return new AgentVerificationService({
|
|
624
|
+
parallel: false,
|
|
625
|
+
maxConcurrency: 1,
|
|
626
|
+
timeout: 300000, // Longer timeout for sequential
|
|
627
|
+
continueOnFailure: false,
|
|
628
|
+
skipVerification: false,
|
|
629
|
+
...config
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
module.exports = AgentVerificationService;
|