wegho-agentes 4.0.1
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/.agents/AGENT_WORKFLOW.md +528 -0
- package/.agents/AI_COMPATIBILITY.md +332 -0
- package/.agents/CLI.md +222 -0
- package/.agents/README.md +130 -0
- package/.agents/cli.js +389 -0
- package/.agents/code-auditor-agent.ts +333 -0
- package/.agents/config.ts +145 -0
- package/.agents/context-loader.ts +300 -0
- package/.agents/core/agent-parallelizer.test.ts +94 -0
- package/.agents/core/agent-parallelizer.ts +108 -0
- package/.agents/core/architecture-agent.ts +237 -0
- package/.agents/core/base-agent.ts +311 -0
- package/.agents/core/cache-manager.test.ts +147 -0
- package/.agents/core/cache-manager.ts +184 -0
- package/.agents/core/documentation-agent.ts +183 -0
- package/.agents/core/feedback-collector.ts +207 -0
- package/.agents/core/frontend-agent.ts +210 -0
- package/.agents/core/inventory-agent.ts +582 -0
- package/.agents/core/memory-system.ts +397 -0
- package/.agents/core/quality-agent.ts +268 -0
- package/.agents/core/retry-utility.test.ts +165 -0
- package/.agents/core/retry-utility.ts +140 -0
- package/.agents/core/security-agent.ts +217 -0
- package/.agents/core/workflow-validator.test.ts +171 -0
- package/.agents/core/workflow-validator.ts +158 -0
- package/.agents/domains/README.md +53 -0
- package/.agents/domains/logistics/route-agent.ts +177 -0
- package/.agents/domains/news/cms-agent.ts +158 -0
- package/.agents/domains/news/seo-agent.ts +170 -0
- package/.agents/domains/production/production-control-agent.ts +169 -0
- package/.agents/example-learning-system.js +118 -0
- package/.agents/init.ts +164 -0
- package/.agents/memory/architecture-agent/failures.json +1 -0
- package/.agents/memory/architecture-agent/learnings.json +1 -0
- package/.agents/memory/architecture-agent/specialty.md +31 -0
- package/.agents/memory/architecture-agent/successes.json +16 -0
- package/.agents/memory/cms-agent/failures.json +1 -0
- package/.agents/memory/cms-agent/learnings.json +1 -0
- package/.agents/memory/cms-agent/specialty.md +30 -0
- package/.agents/memory/cms-agent/successes.json +16 -0
- package/.agents/memory/documentation-agent/failures.json +1 -0
- package/.agents/memory/documentation-agent/learnings.json +1 -0
- package/.agents/memory/documentation-agent/specialty.md +33 -0
- package/.agents/memory/documentation-agent/successes.json +16 -0
- package/.agents/memory/frontend-agent/failures.json +1 -0
- package/.agents/memory/frontend-agent/learnings.json +1 -0
- package/.agents/memory/frontend-agent/specialty.md +30 -0
- package/.agents/memory/frontend-agent/successes.json +16 -0
- package/.agents/memory/inventory-agent/failures.json +1 -0
- package/.agents/memory/inventory-agent/inventory/index.json +8 -0
- package/.agents/memory/inventory-agent/inventory/types.json +77716 -0
- package/.agents/memory/inventory-agent/inventory/variables.json +405 -0
- package/.agents/memory/inventory-agent/learnings.json +1 -0
- package/.agents/memory/inventory-agent/specialty.md +129 -0
- package/.agents/memory/inventory-agent/successes.json +30 -0
- package/.agents/memory/production-control-agent/failures.json +1 -0
- package/.agents/memory/production-control-agent/learnings.json +1 -0
- package/.agents/memory/production-control-agent/specialty.md +29 -0
- package/.agents/memory/production-control-agent/successes.json +16 -0
- package/.agents/memory/quality-agent/failures.json +16 -0
- package/.agents/memory/quality-agent/learnings.json +1 -0
- package/.agents/memory/quality-agent/specialty.md +31 -0
- package/.agents/memory/quality-agent/successes.json +1 -0
- package/.agents/memory/reference-repositories.json +271 -0
- package/.agents/memory/route-agent/failures.json +1 -0
- package/.agents/memory/route-agent/learnings.json +1 -0
- package/.agents/memory/route-agent/specialty.md +29 -0
- package/.agents/memory/route-agent/successes.json +16 -0
- package/.agents/memory/security-agent/failures.json +1 -0
- package/.agents/memory/security-agent/learnings.json +1 -0
- package/.agents/memory/security-agent/specialty.md +31 -0
- package/.agents/memory/security-agent/successes.json +16 -0
- package/.agents/memory/seo-agent/failures.json +1 -0
- package/.agents/memory/seo-agent/learnings.json +1 -0
- package/.agents/memory/seo-agent/specialty.md +31 -0
- package/.agents/memory/seo-agent/successes.json +16 -0
- package/.agents/orchestrator.ts +438 -0
- package/.agents/project-discovery-agent.ts +342 -0
- package/.agents/security/pentesting-agent.py +387 -0
- package/.agents/security/python-bridge.ts +193 -0
- package/.agents/security/vulnerability-db.json +201 -0
- package/.agents/task-analyzer-agent.ts +346 -0
- package/.agents/test-init-context.js +67 -0
- package/INSTALL.md +300 -0
- package/LICENSE +21 -0
- package/README.md +315 -0
- package/docs/AGENT_RULES.md +292 -0
- package/docs/BUILD_HISTORY.md +65 -0
- package/docs/DESIGN_SYSTEM.md +256 -0
- package/docs/LEARNING_SYSTEM.md +326 -0
- package/docs/SYMBOLS_TREE.md +182 -0
- package/docs/VERSION.md +6 -0
- package/docs/architecture.md +111 -0
- package/package.json +60 -0
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intelligent Orchestrator - Agente de Auditoria Orquestrador
|
|
3
|
+
*
|
|
4
|
+
* Responsabilidades:
|
|
5
|
+
* - Analisar tarefa e selecionar melhores agentes baseado em memória
|
|
6
|
+
* - Distribuir subtarefas para agentes especializados
|
|
7
|
+
* - Executar 6 passos obrigatórios com aprendizado
|
|
8
|
+
* - Coletar feedback e registrar resultados
|
|
9
|
+
* - Dar decisão final GO/NO-GO
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { FrontEndAgent } from './core/frontend-agent';
|
|
13
|
+
import { SecurityAgent } from './core/security-agent';
|
|
14
|
+
import { ArchitectureAgent } from './core/architecture-agent';
|
|
15
|
+
import { QualityAgent } from './core/quality-agent';
|
|
16
|
+
import { DocumentationAgent } from './core/documentation-agent';
|
|
17
|
+
import { InventoryAgent } from './core/inventory-agent';
|
|
18
|
+
|
|
19
|
+
// Domain Agents
|
|
20
|
+
import { CMSAgent } from './domains/news/cms-agent';
|
|
21
|
+
import { SEOAgent } from './domains/news/seo-agent';
|
|
22
|
+
import { ProductionControlAgent } from './domains/production/production-control-agent';
|
|
23
|
+
import { RouteAgent } from './domains/logistics/route-agent';
|
|
24
|
+
|
|
25
|
+
import { TaskAnalyzerAgent, TaskAnalysis, AgentAssignment } from './task-analyzer-agent';
|
|
26
|
+
import { MemorySystem } from './core/memory-system';
|
|
27
|
+
import { FeedbackCollector, UserFeedback } from './core/feedback-collector';
|
|
28
|
+
import { PythonBridge } from './security/python-bridge';
|
|
29
|
+
import { AgentConfig, DEFAULT_CONFIG } from './config';
|
|
30
|
+
import { ProjectContext } from './context-loader';
|
|
31
|
+
import { TaskContext, TaskResult } from './core/base-agent';
|
|
32
|
+
import { RetryUtility } from './core/retry-utility';
|
|
33
|
+
import { AgentParallelizer } from './core/agent-parallelizer';
|
|
34
|
+
|
|
35
|
+
export interface ImplementationPlan {
|
|
36
|
+
title: string;
|
|
37
|
+
description: string;
|
|
38
|
+
hasUIChanges: boolean;
|
|
39
|
+
hasDatabaseChanges: boolean;
|
|
40
|
+
affectedFiles: string[];
|
|
41
|
+
estimatedComplexity: 'low' | 'medium' | 'high';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface AgentReport {
|
|
45
|
+
agentName: string;
|
|
46
|
+
stepNumber: number;
|
|
47
|
+
status: 'success' | 'warning' | 'error';
|
|
48
|
+
summary: string;
|
|
49
|
+
details: string;
|
|
50
|
+
blockers?: string[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ExecutionResult {
|
|
54
|
+
success: boolean;
|
|
55
|
+
status: 'GO' | 'NO-GO';
|
|
56
|
+
reports: AgentReport[];
|
|
57
|
+
blockers: string[];
|
|
58
|
+
taskId: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export class IntelligentOrchestrator {
|
|
62
|
+
private config: AgentConfig;
|
|
63
|
+
private taskAnalyzer: TaskAnalyzerAgent;
|
|
64
|
+
private memory: MemorySystem;
|
|
65
|
+
private feedbackCollector: FeedbackCollector;
|
|
66
|
+
private context: ProjectContext;
|
|
67
|
+
|
|
68
|
+
// Core Agents
|
|
69
|
+
private frontendAgent: FrontEndAgent;
|
|
70
|
+
private securityAgent: SecurityAgent;
|
|
71
|
+
private architectureAgent: ArchitectureAgent;
|
|
72
|
+
private qualityAgent: QualityAgent;
|
|
73
|
+
private documentationAgent: DocumentationAgent;
|
|
74
|
+
private inventoryAgent: InventoryAgent;
|
|
75
|
+
private pythonBridge: PythonBridge;
|
|
76
|
+
|
|
77
|
+
// Domain Agents
|
|
78
|
+
private cmsAgent: CMSAgent;
|
|
79
|
+
private seoAgent: SEOAgent;
|
|
80
|
+
private productionControlAgent: ProductionControlAgent;
|
|
81
|
+
private routeAgent: RouteAgent;
|
|
82
|
+
|
|
83
|
+
constructor(context: ProjectContext, config: AgentConfig = DEFAULT_CONFIG) {
|
|
84
|
+
this.context = context;
|
|
85
|
+
this.config = config;
|
|
86
|
+
this.taskAnalyzer = new TaskAnalyzerAgent();
|
|
87
|
+
this.memory = new MemorySystem(config.memoryPath, config.maxMemoryEntries);
|
|
88
|
+
this.feedbackCollector = new FeedbackCollector(config.memoryPath);
|
|
89
|
+
this.pythonBridge = new PythonBridge();
|
|
90
|
+
|
|
91
|
+
// Inicializar todos os agentes com memória
|
|
92
|
+
this.frontendAgent = new FrontEndAgent(config.memoryPath);
|
|
93
|
+
this.securityAgent = new SecurityAgent(config.memoryPath);
|
|
94
|
+
this.architectureAgent = new ArchitectureAgent(config.memoryPath);
|
|
95
|
+
this.qualityAgent = new QualityAgent(config.memoryPath);
|
|
96
|
+
this.documentationAgent = new DocumentationAgent(config.memoryPath);
|
|
97
|
+
this.inventoryAgent = new InventoryAgent(process.cwd());
|
|
98
|
+
|
|
99
|
+
// Inicializar agentes de domínio
|
|
100
|
+
this.cmsAgent = new CMSAgent(config.memoryPath);
|
|
101
|
+
this.seoAgent = new SEOAgent(config.memoryPath);
|
|
102
|
+
this.productionControlAgent = new ProductionControlAgent(config.memoryPath);
|
|
103
|
+
this.routeAgent = new RouteAgent(config.memoryPath);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Orquestra uma tarefa completa com aprendizado
|
|
108
|
+
*/
|
|
109
|
+
async orchestrateTask(taskDescription: string): Promise<ExecutionResult> {
|
|
110
|
+
console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
111
|
+
console.log('🎯 ORQUESTRADOR INTELIGENTE');
|
|
112
|
+
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
113
|
+
|
|
114
|
+
const taskId = this.generateTaskId();
|
|
115
|
+
|
|
116
|
+
// 1. Analisar tarefa
|
|
117
|
+
console.log('📊 Fase 1: Análise da Tarefa\n');
|
|
118
|
+
const analysis = await this.taskAnalyzer.analyzeTask(taskDescription, this.config);
|
|
119
|
+
|
|
120
|
+
// 2. Selecionar melhores agentes baseado em memória
|
|
121
|
+
console.log('\n🤖 Fase 2: Seleção Inteligente de Agentes\n');
|
|
122
|
+
const selectedAgents = await this.selectBestAgents(analysis);
|
|
123
|
+
|
|
124
|
+
// 3. Executar com agentes selecionados (EM PARALELO)
|
|
125
|
+
console.log('\n⚙️ Fase 3: Execução com Agentes\n');
|
|
126
|
+
|
|
127
|
+
// Agrupar agentes para execução paralela
|
|
128
|
+
const agentGroups = AgentParallelizer.groupAgents(selectedAgents);
|
|
129
|
+
const timeEstimate = AgentParallelizer.estimateTimeReduction(selectedAgents);
|
|
130
|
+
|
|
131
|
+
console.log(`📊 Agentes agrupados em ${agentGroups.length} grupo(s) paralelo(s)`);
|
|
132
|
+
console.log(`⏱️ Redução estimada de tempo: ${timeEstimate.reduction}% (${timeEstimate.sequential}s → ${timeEstimate.parallel}s)\n`);
|
|
133
|
+
|
|
134
|
+
const reports: AgentReport[] = [];
|
|
135
|
+
const blockers: string[] = [];
|
|
136
|
+
let success = true;
|
|
137
|
+
|
|
138
|
+
// VERIFICAÇÃO ANTI-DUPLICAÇÃO PROATIVA
|
|
139
|
+
await this.checkDuplicationBeforeExecution(taskDescription);
|
|
140
|
+
|
|
141
|
+
// Executar cada grupo em paralelo
|
|
142
|
+
for (let i = 0; i < agentGroups.length; i++) {
|
|
143
|
+
const group = agentGroups[i];
|
|
144
|
+
|
|
145
|
+
if (group.length === 1) {
|
|
146
|
+
console.log(`\n🔹 Grupo ${i + 1}: Executando ${group[0].agentName}`);
|
|
147
|
+
} else {
|
|
148
|
+
console.log(`\n🔸 Grupo ${i + 1}: Executando ${group.length} agentes em paralelo:`);
|
|
149
|
+
group.forEach(a => console.log(` - ${a.agentName}`));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Executar agentes do grupo em paralelo
|
|
153
|
+
const groupReports = await Promise.all(
|
|
154
|
+
group.map(assignment => this.executeWithAgent(assignment, analysis))
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
reports.push(...groupReports);
|
|
158
|
+
|
|
159
|
+
// Verificar se houve erro crítico
|
|
160
|
+
const hasError = groupReports.some(r => r.status === 'error');
|
|
161
|
+
if (hasError) {
|
|
162
|
+
success = false;
|
|
163
|
+
groupReports.forEach(r => {
|
|
164
|
+
if (r.blockers) blockers.push(...r.blockers);
|
|
165
|
+
});
|
|
166
|
+
console.log('\n❌ Erro crítico detectado, parando execução');
|
|
167
|
+
break; // Para na primeira falha crítica
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// 4. Decisão final
|
|
172
|
+
const status = success ? 'GO' : 'NO-GO';
|
|
173
|
+
|
|
174
|
+
console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
175
|
+
console.log(`${success ? '✅ GO' : '❌ NO-GO'} - Execução ${success ? 'concluída' : 'bloqueada'}`);
|
|
176
|
+
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
177
|
+
|
|
178
|
+
// 5. Coletar feedback (se habilitado)
|
|
179
|
+
if (this.config.feedbackEnabled) {
|
|
180
|
+
await this.collectFeedbackForTask(taskId, selectedAgents, taskDescription);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
success,
|
|
185
|
+
status,
|
|
186
|
+
reports,
|
|
187
|
+
blockers,
|
|
188
|
+
taskId,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Seleciona melhores agentes baseado em histórico
|
|
194
|
+
*/
|
|
195
|
+
private async selectBestAgents(analysis: TaskAnalysis): Promise<AgentAssignment[]> {
|
|
196
|
+
const selectedAgents: AgentAssignment[] = [];
|
|
197
|
+
|
|
198
|
+
console.log('🔍 Analisando histórico de performance dos agentes...\n');
|
|
199
|
+
|
|
200
|
+
for (const assignment of analysis.agentAssignments) {
|
|
201
|
+
const stats = this.memory.getStats(assignment.agentName);
|
|
202
|
+
|
|
203
|
+
console.log(`📊 ${assignment.agentName}:`);
|
|
204
|
+
console.log(` Taxa de sucesso: ${(stats.successRate * 100).toFixed(1)}%`);
|
|
205
|
+
console.log(` Total de tarefas: ${stats.totalTasks}`);
|
|
206
|
+
|
|
207
|
+
// Sempre incluir, mas mostrar confiança
|
|
208
|
+
if (stats.successRate >= 0.7 || stats.totalTasks === 0) {
|
|
209
|
+
console.log(` ✅ Selecionado (alta confiança)\n`);
|
|
210
|
+
selectedAgents.push(assignment);
|
|
211
|
+
} else if (stats.successRate >= 0.5) {
|
|
212
|
+
console.log(` ⚠️ Selecionado (confiança média)\n`);
|
|
213
|
+
selectedAgents.push(assignment);
|
|
214
|
+
} else {
|
|
215
|
+
console.log(` ⚠️ Selecionado (baixa confiança - monitorar)\n`);
|
|
216
|
+
selectedAgents.push(assignment);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return selectedAgents;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Executa tarefa com um agente específico
|
|
225
|
+
*/
|
|
226
|
+
private async executeWithAgent(
|
|
227
|
+
assignment: AgentAssignment,
|
|
228
|
+
analysis: TaskAnalysis
|
|
229
|
+
): Promise<AgentReport> {
|
|
230
|
+
console.log(`━━━ ${assignment.agentName} ━━━`);
|
|
231
|
+
console.log(`Subtarefa: ${assignment.subtask}\n`);
|
|
232
|
+
|
|
233
|
+
try {
|
|
234
|
+
const context: TaskContext = {
|
|
235
|
+
files: this.extractFilesForAgent(assignment.agentName, analysis),
|
|
236
|
+
areas: analysis.detectedAreas,
|
|
237
|
+
complexity: analysis.complexity,
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
let result: TaskResult;
|
|
241
|
+
|
|
242
|
+
// Executar com timeout e retry
|
|
243
|
+
result = await RetryUtility.executeWithTimeoutAndRetry(
|
|
244
|
+
async () => {
|
|
245
|
+
// Executar com o agente apropriado
|
|
246
|
+
switch (assignment.agentName) {
|
|
247
|
+
case 'frontend-agent':
|
|
248
|
+
return await this.frontendAgent.executeWithMemory(assignment.subtask, context);
|
|
249
|
+
|
|
250
|
+
case 'security-agent':
|
|
251
|
+
return await this.securityAgent.executeWithMemory(assignment.subtask, context);
|
|
252
|
+
|
|
253
|
+
case 'architecture-agent':
|
|
254
|
+
return await this.architectureAgent.executeWithMemory(assignment.subtask, context);
|
|
255
|
+
|
|
256
|
+
case 'quality-agent':
|
|
257
|
+
return await this.qualityAgent.executeWithMemory(assignment.subtask, context);
|
|
258
|
+
|
|
259
|
+
case 'documentation-agent':
|
|
260
|
+
return await this.documentationAgent.executeWithMemory(assignment.subtask, context);
|
|
261
|
+
|
|
262
|
+
case 'inventory-agent':
|
|
263
|
+
return await this.inventoryAgent.executeTask(assignment.subtask, context);
|
|
264
|
+
|
|
265
|
+
case 'cms-agent':
|
|
266
|
+
return await this.cmsAgent.executeWithMemory(assignment.subtask, context);
|
|
267
|
+
|
|
268
|
+
case 'seo-agent':
|
|
269
|
+
return await this.seoAgent.executeWithMemory(assignment.subtask, context);
|
|
270
|
+
|
|
271
|
+
case 'production-control-agent':
|
|
272
|
+
return await this.productionControlAgent.executeWithMemory(assignment.subtask, context);
|
|
273
|
+
|
|
274
|
+
case 'route-agent':
|
|
275
|
+
return await this.routeAgent.executeWithMemory(assignment.subtask, context);
|
|
276
|
+
|
|
277
|
+
case 'pentesting-agent':
|
|
278
|
+
// Executar agente Python de pentesting
|
|
279
|
+
const pentestResult = await this.pythonBridge.executePentesting({
|
|
280
|
+
target: 'http://localhost:3000', // Em produção, usar URL do projeto
|
|
281
|
+
testSqlInjection: true,
|
|
282
|
+
testXss: true,
|
|
283
|
+
testPasswords: true,
|
|
284
|
+
testHeaders: true
|
|
285
|
+
});
|
|
286
|
+
return this.pythonBridge.convertToAgentResult(pentestResult);
|
|
287
|
+
|
|
288
|
+
default:
|
|
289
|
+
// Agente não implementado ainda
|
|
290
|
+
return {
|
|
291
|
+
success: true,
|
|
292
|
+
details: `Agente ${assignment.agentName} ainda não implementado`,
|
|
293
|
+
warnings: ['Agente em desenvolvimento'],
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
30000, // 30 segundos de timeout
|
|
298
|
+
{
|
|
299
|
+
maxRetries: 2,
|
|
300
|
+
initialDelay: 2000,
|
|
301
|
+
backoffMultiplier: 2
|
|
302
|
+
},
|
|
303
|
+
assignment.agentName
|
|
304
|
+
);
|
|
305
|
+
|
|
306
|
+
const status = result.success ? 'success' : 'error';
|
|
307
|
+
|
|
308
|
+
console.log(`${result.success ? '✅' : '❌'} ${assignment.agentName} concluído\n`);
|
|
309
|
+
|
|
310
|
+
return {
|
|
311
|
+
agentName: assignment.agentName,
|
|
312
|
+
stepNumber: assignment.priority,
|
|
313
|
+
status,
|
|
314
|
+
summary: result.success ? 'Tarefa concluída com sucesso' : 'Tarefa falhou',
|
|
315
|
+
details: result.details,
|
|
316
|
+
blockers: result.issues,
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
} catch (error) {
|
|
320
|
+
console.error(`❌ Erro ao executar ${assignment.agentName}:`, error);
|
|
321
|
+
|
|
322
|
+
return {
|
|
323
|
+
agentName: assignment.agentName,
|
|
324
|
+
stepNumber: assignment.priority,
|
|
325
|
+
status: 'error',
|
|
326
|
+
summary: 'Erro na execução',
|
|
327
|
+
details: error instanceof Error ? error.message : 'Erro desconhecido',
|
|
328
|
+
blockers: ['Erro crítico na execução'],
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Verifica duplicação de recursos antes da execução
|
|
335
|
+
*/
|
|
336
|
+
private async checkDuplicationBeforeExecution(taskDescription: string): Promise<void> {
|
|
337
|
+
console.log('🛡️ Consulando Almoxarifado (Inventory Agent) para evitar duplicações...');
|
|
338
|
+
|
|
339
|
+
// Simular contexto para o Inventory Agent
|
|
340
|
+
const context: TaskContext = {
|
|
341
|
+
files: [],
|
|
342
|
+
areas: ['inventory'],
|
|
343
|
+
complexity: 'low'
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
const result = await this.inventoryAgent.executeTask(`check duplication for "${taskDescription}"`, context);
|
|
347
|
+
|
|
348
|
+
if (result.warnings && result.warnings.length > 0) {
|
|
349
|
+
console.log('\n⚠️ ALERTA DE DUPLICAÇÃO DETECTADO:');
|
|
350
|
+
result.warnings.forEach(w => console.log(` - ${w}`));
|
|
351
|
+
if (result.recommendations) {
|
|
352
|
+
console.log('\n💡 Sugestões do Almoxarifado:');
|
|
353
|
+
result.recommendations.forEach(r => console.log(` - ${r}`));
|
|
354
|
+
}
|
|
355
|
+
console.log('\n');
|
|
356
|
+
} else {
|
|
357
|
+
console.log('✅ Nenhuma duplicação óbvia detectada. Prosseguindo...\n');
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Extrai arquivos relevantes para um agente
|
|
363
|
+
*/
|
|
364
|
+
private extractFilesForAgent(agentName: string, analysis: TaskAnalysis): string[] {
|
|
365
|
+
// Implementação simplificada - em produção seria mais sofisticado
|
|
366
|
+
// Por enquanto, retorna lista vazia (agentes usarão arquivos do contexto geral)
|
|
367
|
+
return [];
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Coleta feedback para a tarefa
|
|
372
|
+
*/
|
|
373
|
+
private async collectFeedbackForTask(
|
|
374
|
+
taskId: string,
|
|
375
|
+
agents: AgentAssignment[],
|
|
376
|
+
taskDescription: string
|
|
377
|
+
): Promise<void> {
|
|
378
|
+
console.log('\n📝 Feedback habilitado - aguardando feedback do usuário');
|
|
379
|
+
console.log(' Use feedbackCollector.provideFeedback() para fornecer feedback\n');
|
|
380
|
+
|
|
381
|
+
// Em produção, isso seria um prompt interativo
|
|
382
|
+
// Por enquanto, apenas informamos que o feedback está disponível
|
|
383
|
+
for (const agent of agents) {
|
|
384
|
+
await this.feedbackCollector.collectFeedback(
|
|
385
|
+
taskId,
|
|
386
|
+
agent.agentName,
|
|
387
|
+
taskDescription
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Fornece feedback manualmente
|
|
394
|
+
*/
|
|
395
|
+
async provideFeedback(taskId: string, agentName: string, feedback: Omit<UserFeedback, 'taskId' | 'agentName' | 'timestamp'>): Promise<void> {
|
|
396
|
+
const fullFeedback: UserFeedback = {
|
|
397
|
+
taskId,
|
|
398
|
+
agentName,
|
|
399
|
+
...feedback,
|
|
400
|
+
timestamp: new Date(),
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
await this.feedbackCollector.provideFeedback(fullFeedback);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Gera relatório de feedback de um agente
|
|
408
|
+
*/
|
|
409
|
+
getFeedbackReport(agentName: string): string {
|
|
410
|
+
return this.feedbackCollector.generateFeedbackReport(agentName);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Gera ID único para tarefa
|
|
415
|
+
*/
|
|
416
|
+
private generateTaskId(): string {
|
|
417
|
+
return `task-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Método legado para compatibilidade
|
|
422
|
+
*/
|
|
423
|
+
async analyzeBeforeExecution(taskDescription: string): Promise<TaskAnalysis> {
|
|
424
|
+
return await this.taskAnalyzer.analyzeTask(taskDescription, this.config);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Método legado para compatibilidade
|
|
429
|
+
*/
|
|
430
|
+
async executePlan(plan: ImplementationPlan): Promise<ExecutionResult> {
|
|
431
|
+
// Converter plano para descrição de tarefa
|
|
432
|
+
const taskDescription = `${plan.title}: ${plan.description}`;
|
|
433
|
+
return await this.orchestrateTask(taskDescription);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// Manter compatibilidade com código existente
|
|
438
|
+
export { IntelligentOrchestrator as AgentsOrchestrator };
|