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,487 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RUI Agent Commands Handler
|
|
3
|
+
*
|
|
4
|
+
* Handles REST-based commands for agent operations.
|
|
5
|
+
* Follows constitutional requirements: <555 lines, test-first approach.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const AgentConfigManager = require('../../agents/config/AgentConfigManager');
|
|
9
|
+
const AgentCheckService = require('../../agents/AgentCheckService');
|
|
10
|
+
const AgentLogger = require('../../agents/logging/AgentLogger');
|
|
11
|
+
const FileManager = require('../../agents/storage/FileManager');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* RUI agent commands handler class
|
|
15
|
+
*/
|
|
16
|
+
class AgentCommands {
|
|
17
|
+
/**
|
|
18
|
+
* Create commands handler instance
|
|
19
|
+
* @param {Object} options - Handler options
|
|
20
|
+
* @param {AgentConfigManager} options.configManager - Configuration manager
|
|
21
|
+
* @param {AgentCheckService} options.checkService - Agent check service
|
|
22
|
+
* @param {AgentLogger} options.logger - Logger instance
|
|
23
|
+
* @param {FileManager} options.fileManager - File manager instance
|
|
24
|
+
*/
|
|
25
|
+
constructor(options = {}) {
|
|
26
|
+
this.configManager = options.configManager || new AgentConfigManager();
|
|
27
|
+
this.logger = options.logger || new AgentLogger({
|
|
28
|
+
fileManager: new FileManager()
|
|
29
|
+
});
|
|
30
|
+
this.fileManager = options.fileManager || new FileManager();
|
|
31
|
+
|
|
32
|
+
// Initialize check service with proper dependencies
|
|
33
|
+
this.checkService = new AgentCheckService({
|
|
34
|
+
configManager: this.configManager,
|
|
35
|
+
logger: this.logger,
|
|
36
|
+
fileManager: this.fileManager
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
this.commandMap = {
|
|
40
|
+
// REST-style commands
|
|
41
|
+
'GET': this.handleListAgents.bind(this),
|
|
42
|
+
'LIST': this.handleListAgents.bind(this),
|
|
43
|
+
'POST': this.handleCheckAgents.bind(this),
|
|
44
|
+
'CHECK': this.handleCheckAgents.bind(this),
|
|
45
|
+
'PUT': this.handleUpdateAgent.bind(this),
|
|
46
|
+
'UPDATE': this.handleUpdateAgent.bind(this),
|
|
47
|
+
'DELETE': this.handleDeleteAgent.bind(this),
|
|
48
|
+
'REMOVE': this.handleDeleteAgent.bind(this),
|
|
49
|
+
|
|
50
|
+
// Shortcut commands
|
|
51
|
+
'LA': this.handleListAgents.bind(this), // List agents
|
|
52
|
+
'LI': this.handleListAgents.bind(this), // List agents
|
|
53
|
+
'CH': this.handleCheckAgents.bind(this), // Check agents
|
|
54
|
+
'CA': this.handleCheckAgents.bind(this), // Check agents
|
|
55
|
+
'EN': this.handleEnableAgent.bind(this), // Enable agent
|
|
56
|
+
'DI': this.handleDisableAgent.bind(this), // Disable agent
|
|
57
|
+
'GE': this.handleGetAgent.bind(this), // Get agent
|
|
58
|
+
'UP': this.handleUpdateAgent.bind(this), // Update agent
|
|
59
|
+
'RE': this.handleDeleteAgent.bind(this), // Remove agent
|
|
60
|
+
'RM': this.handleDeleteAgent.bind(this) // Remove agent
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Parse and execute command
|
|
66
|
+
* @param {string} verb - Command verb (GET, POST, PUT, DELETE, or shortcuts)
|
|
67
|
+
* @param {string} resource - Resource (agents, agent-id)
|
|
68
|
+
* @param {Object} params - Command parameters
|
|
69
|
+
* @returns {Promise<Object>} - Command result
|
|
70
|
+
*/
|
|
71
|
+
async executeCommand(verb, resource, params = {}) {
|
|
72
|
+
const commandKey = verb.toUpperCase();
|
|
73
|
+
const handler = this.commandMap[commandKey];
|
|
74
|
+
|
|
75
|
+
if (!handler) {
|
|
76
|
+
throw new Error(`Unknown command: ${verb}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Initialize config manager if not already loaded
|
|
80
|
+
if (!this.configManager.loaded) {
|
|
81
|
+
await this.configManager.load();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return await handler(resource, params);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Handle LIST/GET agents command
|
|
89
|
+
* @param {string} resource - Resource (should be 'agents')
|
|
90
|
+
* @param {Object} params - Command parameters
|
|
91
|
+
* @returns {Promise<Object>} - Command result
|
|
92
|
+
*/
|
|
93
|
+
async handleListAgents(resource, params = {}) {
|
|
94
|
+
if (resource !== 'agents' && resource !== 'agent') {
|
|
95
|
+
throw new Error(`Invalid resource for LIST command: ${resource}`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const { includeDisabled = false, includeStatus = true } = params;
|
|
99
|
+
|
|
100
|
+
let agents = includeDisabled
|
|
101
|
+
? this.configManager.getAllAgents()
|
|
102
|
+
: this.configManager.getEnabledAgents();
|
|
103
|
+
|
|
104
|
+
// Add status information if requested
|
|
105
|
+
if (includeStatus) {
|
|
106
|
+
agents = await Promise.all(agents.map(async agent => {
|
|
107
|
+
const status = await this.configManager.getAgentStatus(agent.id);
|
|
108
|
+
return {
|
|
109
|
+
...agent.toJSON(),
|
|
110
|
+
status: status || { status: 'NOT_INSTALLED', lastChecked: null }
|
|
111
|
+
};
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
success: true,
|
|
117
|
+
data: {
|
|
118
|
+
agents,
|
|
119
|
+
count: agents.length,
|
|
120
|
+
includeDisabled,
|
|
121
|
+
timestamp: new Date().toISOString()
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Handle CHECK/POST agents command
|
|
128
|
+
* @param {string} resource - Resource (should be 'agents')
|
|
129
|
+
* @param {Object} params - Command parameters
|
|
130
|
+
* @returns {Promise<Object>} - Command result
|
|
131
|
+
*/
|
|
132
|
+
async handleCheckAgents(resource, params = {}) {
|
|
133
|
+
if (resource !== 'agents' && resource !== 'agent') {
|
|
134
|
+
throw new Error(`Invalid resource for CHECK command: ${resource}`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const {
|
|
138
|
+
agentIds = null,
|
|
139
|
+
forceReinstall = false,
|
|
140
|
+
skipVerification = false,
|
|
141
|
+
timeout = 300000 // 5 minutes default
|
|
142
|
+
} = params;
|
|
143
|
+
|
|
144
|
+
if (this.logger) {
|
|
145
|
+
await this.logger.info('Starting agent check operation', {
|
|
146
|
+
agentIds,
|
|
147
|
+
forceReinstall,
|
|
148
|
+
skipVerification,
|
|
149
|
+
timeout
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
const result = await this.checkService.checkAgents({
|
|
155
|
+
agentIds,
|
|
156
|
+
forceReinstall,
|
|
157
|
+
skipVerification,
|
|
158
|
+
timeout
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
success: true,
|
|
163
|
+
data: result
|
|
164
|
+
};
|
|
165
|
+
} catch (error) {
|
|
166
|
+
if (this.logger) {
|
|
167
|
+
await this.logger.error('Agent check operation failed', {
|
|
168
|
+
error: error.message,
|
|
169
|
+
agentIds,
|
|
170
|
+
forceReinstall,
|
|
171
|
+
skipVerification
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
success: false,
|
|
177
|
+
error: error.message,
|
|
178
|
+
data: null
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Handle GET specific agent command
|
|
185
|
+
* @param {string} resource - Agent ID
|
|
186
|
+
* @param {Object} params - Command parameters
|
|
187
|
+
* @returns {Promise<Object>} - Command result
|
|
188
|
+
*/
|
|
189
|
+
async handleGetAgent(resource, params = {}) {
|
|
190
|
+
const agentId = resource;
|
|
191
|
+
|
|
192
|
+
if (!agentId) {
|
|
193
|
+
throw new Error('Agent ID is required for GET command');
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const agent = this.configManager.getAgent(agentId);
|
|
197
|
+
if (!agent) {
|
|
198
|
+
throw new Error(`Agent not found: ${agentId}`);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const { includeStatus = true, includeLogs = false } = params;
|
|
202
|
+
|
|
203
|
+
let result = agent.toJSON();
|
|
204
|
+
|
|
205
|
+
// Add status information if requested
|
|
206
|
+
if (includeStatus) {
|
|
207
|
+
const status = await this.configManager.getAgentStatus(agentId);
|
|
208
|
+
result.status = status || { status: 'NOT_INSTALLED', lastChecked: null };
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Add logs if requested
|
|
212
|
+
if (includeLogs && this.logger) {
|
|
213
|
+
const logs = await this.logger.getAgentLogs(agentId, { limit: 10 });
|
|
214
|
+
result.recentLogs = logs;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return {
|
|
218
|
+
success: true,
|
|
219
|
+
data: result
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Handle UPDATE/PUT agent command
|
|
225
|
+
* @param {string} resource - Agent ID
|
|
226
|
+
* @param {Object} params - Command parameters
|
|
227
|
+
* @returns {Promise<Object>} - Command result
|
|
228
|
+
*/
|
|
229
|
+
async handleUpdateAgent(resource, params = {}) {
|
|
230
|
+
const agentId = resource;
|
|
231
|
+
|
|
232
|
+
if (!agentId) {
|
|
233
|
+
throw new Error('Agent ID is required for UPDATE command');
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const agent = this.configManager.getAgent(agentId);
|
|
237
|
+
if (!agent) {
|
|
238
|
+
throw new Error(`Agent not found: ${agentId}`);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const { enabled, status, message } = params;
|
|
242
|
+
|
|
243
|
+
try {
|
|
244
|
+
// Update agent properties
|
|
245
|
+
if (enabled !== undefined) {
|
|
246
|
+
await this.configManager[enabled ? 'enableAgent' : 'disableAgent'](agentId);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (status) {
|
|
250
|
+
await this.configManager.updateAgentStatus(agentId, status, message);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Return updated agent
|
|
254
|
+
const updatedAgent = this.configManager.getAgent(agentId);
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
success: true,
|
|
258
|
+
data: updatedAgent.toJSON()
|
|
259
|
+
};
|
|
260
|
+
} catch (error) {
|
|
261
|
+
if (this.logger) {
|
|
262
|
+
await this.logger.error(`Failed to update agent ${agentId}`, {
|
|
263
|
+
agentId,
|
|
264
|
+
params,
|
|
265
|
+
error: error.message
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return {
|
|
270
|
+
success: false,
|
|
271
|
+
error: error.message
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Handle ENABLE agent command
|
|
278
|
+
* @param {string} resource - Agent ID
|
|
279
|
+
* @param {Object} params - Command parameters
|
|
280
|
+
* @returns {Promise<Object>} - Command result
|
|
281
|
+
*/
|
|
282
|
+
async handleEnableAgent(resource, params = {}) {
|
|
283
|
+
const agentId = resource;
|
|
284
|
+
|
|
285
|
+
if (!agentId) {
|
|
286
|
+
throw new Error('Agent ID is required for ENABLE command');
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
try {
|
|
290
|
+
const success = await this.configManager.enableAgent(agentId);
|
|
291
|
+
|
|
292
|
+
if (!success) {
|
|
293
|
+
throw new Error(`Failed to enable agent: ${agentId}`);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const agent = this.configManager.getAgent(agentId);
|
|
297
|
+
|
|
298
|
+
if (this.logger) {
|
|
299
|
+
await this.logger.info(`Agent enabled: ${agentId}`, {
|
|
300
|
+
agentId,
|
|
301
|
+
enabled: true
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return {
|
|
306
|
+
success: true,
|
|
307
|
+
data: agent.toJSON()
|
|
308
|
+
};
|
|
309
|
+
} catch (error) {
|
|
310
|
+
if (this.logger) {
|
|
311
|
+
await this.logger.error(`Failed to enable agent ${agentId}`, {
|
|
312
|
+
agentId,
|
|
313
|
+
error: error.message
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return {
|
|
318
|
+
success: false,
|
|
319
|
+
error: error.message
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Handle DISABLE agent command
|
|
326
|
+
* @param {string} resource - Agent ID
|
|
327
|
+
* @param {Object} params - Command parameters
|
|
328
|
+
* @returns {Promise<Object>} - Command result
|
|
329
|
+
*/
|
|
330
|
+
async handleDisableAgent(resource, params = {}) {
|
|
331
|
+
const agentId = resource;
|
|
332
|
+
|
|
333
|
+
if (!agentId) {
|
|
334
|
+
throw new Error('Agent ID is required for DISABLE command');
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
try {
|
|
338
|
+
const success = await this.configManager.disableAgent(agentId);
|
|
339
|
+
|
|
340
|
+
if (!success) {
|
|
341
|
+
throw new Error(`Failed to disable agent: ${agentId}`);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const agent = this.configManager.getAgent(agentId);
|
|
345
|
+
|
|
346
|
+
if (this.logger) {
|
|
347
|
+
await this.logger.info(`Agent disabled: ${agentId}`, {
|
|
348
|
+
agentId,
|
|
349
|
+
enabled: false
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return {
|
|
354
|
+
success: true,
|
|
355
|
+
data: agent.toJSON()
|
|
356
|
+
};
|
|
357
|
+
} catch (error) {
|
|
358
|
+
if (this.logger) {
|
|
359
|
+
await this.logger.error(`Failed to disable agent ${agentId}`, {
|
|
360
|
+
agentId,
|
|
361
|
+
error: error.message
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
return {
|
|
366
|
+
success: false,
|
|
367
|
+
error: error.message
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Handle DELETE/REMOVE agent command
|
|
374
|
+
* @param {string} resource - Agent ID
|
|
375
|
+
* @param {Object} params - Command parameters
|
|
376
|
+
* @returns {Promise<Object>} - Command result
|
|
377
|
+
*/
|
|
378
|
+
async handleDeleteAgent(resource, params = {}) {
|
|
379
|
+
const agentId = resource;
|
|
380
|
+
|
|
381
|
+
if (!agentId) {
|
|
382
|
+
throw new Error('Agent ID is required for DELETE command');
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const { confirm = false } = params;
|
|
386
|
+
|
|
387
|
+
if (!confirm) {
|
|
388
|
+
return {
|
|
389
|
+
success: false,
|
|
390
|
+
error: 'Confirmation required. Use confirm=true to delete agent.',
|
|
391
|
+
requiresConfirmation: true
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
try {
|
|
396
|
+
const success = await this.configManager.removeAgent(agentId);
|
|
397
|
+
|
|
398
|
+
if (!success) {
|
|
399
|
+
throw new Error(`Failed to remove agent: ${agentId}`);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if (this.logger) {
|
|
403
|
+
await this.logger.info(`Agent removed: ${agentId}`, {
|
|
404
|
+
agentId
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
return {
|
|
409
|
+
success: true,
|
|
410
|
+
data: { message: `Agent ${agentId} removed successfully` }
|
|
411
|
+
};
|
|
412
|
+
} catch (error) {
|
|
413
|
+
if (this.logger) {
|
|
414
|
+
await this.logger.error(`Failed to remove agent ${agentId}`, {
|
|
415
|
+
agentId,
|
|
416
|
+
error: error.message
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
return {
|
|
421
|
+
success: false,
|
|
422
|
+
error: error.message
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Get command help
|
|
429
|
+
* @returns {Object} - Help information
|
|
430
|
+
*/
|
|
431
|
+
getHelp() {
|
|
432
|
+
return {
|
|
433
|
+
availableCommands: [
|
|
434
|
+
{ verb: 'GET', shortcut: 'LA', description: 'List all agents', usage: 'GET agents' },
|
|
435
|
+
{ verb: 'GET', shortcut: 'GE', description: 'Get specific agent', usage: 'GET <agent-id>' },
|
|
436
|
+
{ verb: 'POST', shortcut: 'CH', description: 'Check agents', usage: 'POST agents' },
|
|
437
|
+
{ verb: 'PUT', shortcut: 'EN', description: 'Enable agent', usage: 'PUT <agent-id> enabled=true' },
|
|
438
|
+
{ verb: 'PUT', shortcut: 'DI', description: 'Disable agent', usage: 'PUT <agent-id> enabled=false' },
|
|
439
|
+
{ verb: 'DELETE', shortcut: 'RE', description: 'Remove agent', usage: 'DELETE <agent-id> confirm=true' }
|
|
440
|
+
],
|
|
441
|
+
examples: [
|
|
442
|
+
'GET agents',
|
|
443
|
+
'GET claude-code',
|
|
444
|
+
'POST agents',
|
|
445
|
+
'PUT claude-code enabled=true',
|
|
446
|
+
'PUT claude-code enabled=false',
|
|
447
|
+
'DELETE test-agent confirm=true'
|
|
448
|
+
]
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Validate command parameters
|
|
454
|
+
* @param {string} verb - Command verb
|
|
455
|
+
* @param {string} resource - Resource
|
|
456
|
+
* @param {Object} params - Parameters
|
|
457
|
+
* @returns {Object} - Validation result
|
|
458
|
+
*/
|
|
459
|
+
validateCommand(verb, resource, params = {}) {
|
|
460
|
+
const errors = [];
|
|
461
|
+
const warnings = [];
|
|
462
|
+
|
|
463
|
+
// Validate verb
|
|
464
|
+
const commandKey = verb.toUpperCase();
|
|
465
|
+
if (!this.commandMap[commandKey]) {
|
|
466
|
+
errors.push(`Unknown command: ${verb}`);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// Validate resource for specific commands
|
|
470
|
+
if (['GET', 'PUT', 'DELETE'].includes(commandKey) && !resource) {
|
|
471
|
+
errors.push('Agent ID is required for this command');
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// Validate parameters
|
|
475
|
+
if (commandKey === 'DELETE' && !params.confirm) {
|
|
476
|
+
warnings.push('DELETE command requires confirmation (confirm=true)');
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
return {
|
|
480
|
+
valid: errors.length === 0,
|
|
481
|
+
errors,
|
|
482
|
+
warnings
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
module.exports = AgentCommands;
|