Update README.md
Browse files
README.md
CHANGED
|
@@ -61,4 +61,1297 @@ HECTRON está diseñado para ejecutar un bucle cibernético **ReAct (Reasoning +
|
|
| 61 |
|
| 62 |
## 🛡️ AbadaLabs
|
| 63 |
*Reduciendo la entropía local creando orden fractal.*
|
| 64 |
-
Construido desde Ciudad Acuña para el mundo. ⚔️🪬👑
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
## 🛡️ AbadaLabs
|
| 63 |
*Reduciendo la entropía local creando orden fractal.*
|
| 64 |
+
Construido desde Ciudad Acuña para el mundo. ⚔️🪬👑
|
| 65 |
+
|
| 66 |
+
# Protocolos de Comunicación y Coordinación HECTRON
|
| 67 |
+
|
| 68 |
+
## 🔄 Visión General
|
| 69 |
+
|
| 70 |
+
Sistema integral de comunicación que permite a HECTRON coordinarse internamente entre módulos, comunicarse con APIs externas, y mantener canales de comunicación con usuarios y otros sistemas.
|
| 71 |
+
|
| 72 |
+
---
|
| 73 |
+
|
| 74 |
+
## 📡 Sistema de Mensajería Interna
|
| 75 |
+
|
| 76 |
+
### 1. Bus de Mensajes
|
| 77 |
+
|
| 78 |
+
```typescript
|
| 79 |
+
interface MessageBus {
|
| 80 |
+
// Publicar mensaje
|
| 81 |
+
publish(topic: string, message: Message): void;
|
| 82 |
+
|
| 83 |
+
// Suscribirse a topic
|
| 84 |
+
subscribe(topic: string, handler: MessageHandler): Subscription;
|
| 85 |
+
|
| 86 |
+
// Publicar/Subscribe
|
| 87 |
+
pubsub(topic: string): Observable<Message>;
|
| 88 |
+
|
| 89 |
+
// Request/Response
|
| 90 |
+
request(topic: string, message: Message): Promise<Message>;
|
| 91 |
+
|
| 92 |
+
// Broadcast
|
| 93 |
+
broadcast(message: Message): void;
|
| 94 |
+
}
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
**Características**:
|
| 98 |
+
- **Topics**: Canales temáticos de comunicación
|
| 99 |
+
- **Pub/Sub**: Publicación y suscripción asíncrona
|
| 100 |
+
- **Request/Response**: Comunicación síncrona bidireccional
|
| 101 |
+
- **Broadcast**: Envío a múltiples destinatarios
|
| 102 |
+
- **Message Queue**: Cola de mensajes garantizada
|
| 103 |
+
|
| 104 |
+
### 2. Tipos de Mensajes
|
| 105 |
+
|
| 106 |
+
```typescript
|
| 107 |
+
interface Message {
|
| 108 |
+
id: string;
|
| 109 |
+
type: MessageType;
|
| 110 |
+
source: MessageSource;
|
| 111 |
+
destination: MessageDestination;
|
| 112 |
+
timestamp: Date;
|
| 113 |
+
priority: Priority;
|
| 114 |
+
|
| 115 |
+
payload: any;
|
| 116 |
+
metadata: MessageMetadata;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
enum MessageType {
|
| 120 |
+
// Internos
|
| 121 |
+
INTERNAL_COMMAND = "INTERNAL_COMMAND",
|
| 122 |
+
INTERNAL_EVENT = "INTERNAL_EVENT",
|
| 123 |
+
INTERNAL_QUERY = "INTERNAL_QUERY",
|
| 124 |
+
INTERNAL_RESPONSE = "INTERNAL_RESPONSE",
|
| 125 |
+
|
| 126 |
+
// Externos
|
| 127 |
+
API_REQUEST = "API_REQUEST",
|
| 128 |
+
API_RESPONSE = "API_RESPONSE",
|
| 129 |
+
USER_INPUT = "USER_INPUT",
|
| 130 |
+
USER_OUTPUT = "USER_OUTPUT",
|
| 131 |
+
|
| 132 |
+
// Sistema
|
| 133 |
+
SYSTEM_ALERT = "SYSTEM_ALERT",
|
| 134 |
+
SYSTEM_STATUS = "SYSTEM_STATUS",
|
| 135 |
+
SYSTEM_ERROR = "SYSTEM_ERROR"
|
| 136 |
+
}
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
### 3. Ruteo de Mensajes
|
| 140 |
+
|
| 141 |
+
```typescript
|
| 142 |
+
interface MessageRouter {
|
| 143 |
+
// Enrutar mensaje
|
| 144 |
+
route(message: Message): void;
|
| 145 |
+
|
| 146 |
+
// Configurar rutas
|
| 147 |
+
configureRoute(route: Route): void;
|
| 148 |
+
|
| 149 |
+
// Balanceo de carga
|
| 150 |
+
loadBalance(messages: Message[]): Message[];
|
| 151 |
+
|
| 152 |
+
// Filtrado
|
| 153 |
+
filter(message: Message): boolean;
|
| 154 |
+
}
|
| 155 |
+
```
|
| 156 |
+
|
| 157 |
+
---
|
| 158 |
+
|
| 159 |
+
## 🤝 Protocolos de Negociación con APIs
|
| 160 |
+
|
| 161 |
+
### 1. Protocolo de Handshake
|
| 162 |
+
|
| 163 |
+
```typescript
|
| 164 |
+
class HandshakeProtocol {
|
| 165 |
+
// Iniciar handshake
|
| 166 |
+
initiate(apiId: string): Promise<HandshakeResult>;
|
| 167 |
+
|
| 168 |
+
// Proponer términos
|
| 169 |
+
proposeTerms(apiId: string, terms: Terms): Promise<TermsResponse>;
|
| 170 |
+
|
| 171 |
+
// Negociar términos
|
| 172 |
+
negotiate(apiId: string, terms: Terms): Promise<NegotiatedTerms>;
|
| 173 |
+
|
| 174 |
+
// Finalizar conexión
|
| 175 |
+
finalize(apiId: string): Promise<void>;
|
| 176 |
+
}
|
| 177 |
+
```
|
| 178 |
+
|
| 179 |
+
**Elementos del Handshake**:
|
| 180 |
+
- **Capabilities**: Capacidades de la API
|
| 181 |
+
- **Constraints**: Restricciones de uso
|
| 182 |
+
- **SLA**: Service Level Agreement
|
| 183 |
+
- **Authentication**: Método de autenticación
|
| 184 |
+
- **Rate Limits**: Límites de tasa
|
| 185 |
+
|
| 186 |
+
### 2. Protocolo de Rate Limiting
|
| 187 |
+
|
| 188 |
+
```typescript
|
| 189 |
+
interface RateLimiter {
|
| 190 |
+
// Verificar si se puede hacer request
|
| 191 |
+
canMakeRequest(apiId: string): boolean;
|
| 192 |
+
|
| 193 |
+
// Registrar request
|
| 194 |
+
recordRequest(apiId: string): void;
|
| 195 |
+
|
| 196 |
+
// Obtener límite actual
|
| 197 |
+
getCurrentLimit(apiId: string): RateLimit;
|
| 198 |
+
|
| 199 |
+
// Negociar aumento de límite
|
| 200 |
+
negotiateLimit(apiId: string, desired: number): Promise<number>;
|
| 201 |
+
}
|
| 202 |
+
```
|
| 203 |
+
|
| 204 |
+
### 3. Protocolo de Prioridad
|
| 205 |
+
|
| 206 |
+
```typescript
|
| 207 |
+
interface PriorityProtocol {
|
| 208 |
+
// Asignar prioridad
|
| 209 |
+
assignPriority(request: Request): Priority;
|
| 210 |
+
|
| 211 |
+
// Negociar prioridad con API
|
| 212 |
+
negotiatePriority(apiId: string, priority: Priority): Promise<boolean>;
|
| 213 |
+
|
| 214 |
+
// Reordenar cola
|
| 215 |
+
reorderQueue(criteria: PriorityCriteria): void;
|
| 216 |
+
}
|
| 217 |
+
```
|
| 218 |
+
|
| 219 |
+
---
|
| 220 |
+
|
| 221 |
+
## 📊 Sistema de Reporte de Estado
|
| 222 |
+
|
| 223 |
+
### 1. Reporte en Tiempo Real
|
| 224 |
+
|
| 225 |
+
```typescript
|
| 226 |
+
interface StatusReporter {
|
| 227 |
+
// Obtener estado actual
|
| 228 |
+
getCurrentStatus(): SystemStatus;
|
| 229 |
+
|
| 230 |
+
// Suscribirse a actualizaciones de estado
|
| 231 |
+
subscribeToStatus(handler: StatusHandler): Subscription;
|
| 232 |
+
|
| 233 |
+
// Reportar métricas
|
| 234 |
+
reportMetrics(metrics: Metrics): void;
|
| 235 |
+
|
| 236 |
+
// Generar reportes
|
| 237 |
+
generateReport(period: TimePeriod): StatusReport;
|
| 238 |
+
}
|
| 239 |
+
```
|
| 240 |
+
|
| 241 |
+
**Componentes de Estado**:
|
| 242 |
+
- **Health Status**: Salud general del sistema
|
| 243 |
+
- **Performance Metrics**: Métricas de rendimiento
|
| 244 |
+
- **API Status**: Estado de APIs conectadas
|
| 245 |
+
- **Autonomy Level**: Nivel de autonomía actual
|
| 246 |
+
- **Resource Usage**: Uso de recursos (CPU, RAM, etc.)
|
| 247 |
+
|
| 248 |
+
### 2. Métricas Monitoreadas
|
| 249 |
+
|
| 250 |
+
```typescript
|
| 251 |
+
interface SystemMetrics {
|
| 252 |
+
// Rendimiento
|
| 253 |
+
responseTime: number; // ms
|
| 254 |
+
throughput: number; // requests/s
|
| 255 |
+
errorRate: number; // %
|
| 256 |
+
|
| 257 |
+
// Recursos
|
| 258 |
+
cpuUsage: number; // %
|
| 259 |
+
memoryUsage: number; // %
|
| 260 |
+
diskUsage: number; // %
|
| 261 |
+
networkIO: number; // MB/s
|
| 262 |
+
|
| 263 |
+
// Autonomía
|
| 264 |
+
autonomyLevel: number; // 0-10
|
| 265 |
+
decisionConfidence: number; // 0-100%
|
| 266 |
+
humanInterventionRate: number; // %
|
| 267 |
+
|
| 268 |
+
// APIs
|
| 269 |
+
apiHealth: Map<string, number>; // 0-100
|
| 270 |
+
apiLatency: Map<string, number>; // ms
|
| 271 |
+
apiErrorRate: Map<string, number>; // %
|
| 272 |
+
}
|
| 273 |
+
```
|
| 274 |
+
|
| 275 |
+
### 3. Dashboard de Estado
|
| 276 |
+
|
| 277 |
+
```typescript
|
| 278 |
+
interface StatusDashboard {
|
| 279 |
+
// Visualizar estado en tiempo real
|
| 280 |
+
visualizeStatus(): DashboardView;
|
| 281 |
+
|
| 282 |
+
// Configurar alertas
|
| 283 |
+
configureAlert(alert: AlertConfig): void;
|
| 284 |
+
|
| 285 |
+
// Exportar reportes
|
| 286 |
+
exportReport(format: ReportFormat): Report;
|
| 287 |
+
}
|
| 288 |
+
```
|
| 289 |
+
|
| 290 |
+
---
|
| 291 |
+
|
| 292 |
+
## 🔌 Interfaz de Comunicación Bidireccional
|
| 293 |
+
|
| 294 |
+
### 1. WebSocket Manager
|
| 295 |
+
|
| 296 |
+
```typescript
|
| 297 |
+
interface WebSocketManager {
|
| 298 |
+
// Establecer conexión
|
| 299 |
+
connect(url: string): Promise<WebSocket>;
|
| 300 |
+
|
| 301 |
+
// Enviar mensaje
|
| 302 |
+
send(ws: WebSocket, message: Message): void;
|
| 303 |
+
|
| 304 |
+
// Recibir mensajes
|
| 305 |
+
onMessage(ws: WebSocket, handler: MessageHandler): void;
|
| 306 |
+
|
| 307 |
+
// Gestionar reconexión
|
| 308 |
+
reconnect(ws: WebSocket): Promise<WebSocket>;
|
| 309 |
+
|
| 310 |
+
// Cerrar conexión
|
| 311 |
+
close(ws: WebSocket): void;
|
| 312 |
+
}
|
| 313 |
+
```
|
| 314 |
+
|
| 315 |
+
### 2. Streaming de Datos
|
| 316 |
+
|
| 317 |
+
```typescript
|
| 318 |
+
interface DataStreamer {
|
| 319 |
+
// Iniciar stream
|
| 320 |
+
startStream(source: DataSource): Stream;
|
| 321 |
+
|
| 322 |
+
// Procesar stream
|
| 323 |
+
processStream(stream: Stream): Observable<any>;
|
| 324 |
+
|
| 325 |
+
// Transformar stream
|
| 326 |
+
transformStream(stream: Stream, transform: Transform): Stream;
|
| 327 |
+
|
| 328 |
+
// Unir streams
|
| 329 |
+
mergeStreams(streams: Stream[]): Stream;
|
| 330 |
+
}
|
| 331 |
+
```
|
| 332 |
+
|
| 333 |
+
### 3. Protocolo de Heartbeat
|
| 334 |
+
|
| 335 |
+
```typescript
|
| 336 |
+
class HeartbeatProtocol {
|
| 337 |
+
// Enviar heartbeat
|
| 338 |
+
sendHeartbeat(target: Target): void;
|
| 339 |
+
|
| 340 |
+
// Recibir heartbeat
|
| 341 |
+
receiveHeartbeat(from: Target): void;
|
| 342 |
+
|
| 343 |
+
// Detectar pérdida de conexión
|
| 344 |
+
detectLoss(target: Target): boolean;
|
| 345 |
+
|
| 346 |
+
// Configurar intervalo
|
| 347 |
+
setInterval(interval: number): void;
|
| 348 |
+
}
|
| 349 |
+
```
|
| 350 |
+
|
| 351 |
+
---
|
| 352 |
+
|
| 353 |
+
## 📝 Sistema de Logging y Auditoría
|
| 354 |
+
|
| 355 |
+
### 1. Sistema de Logging
|
| 356 |
+
|
| 357 |
+
```typescript
|
| 358 |
+
interface LoggingSystem {
|
| 359 |
+
// Registrar evento
|
| 360 |
+
log(event: Event): void;
|
| 361 |
+
|
| 362 |
+
// Consultar logs
|
| 363 |
+
queryLogs(query: LogQuery): Log[];
|
| 364 |
+
|
| 365 |
+
// Agregar logs
|
| 366 |
+
aggregateLogs(query: LogQuery): LogAggregate;
|
| 367 |
+
|
| 368 |
+
// Exportar logs
|
| 369 |
+
exportLogs(format: ExportFormat): void;
|
| 370 |
+
}
|
| 371 |
+
```
|
| 372 |
+
|
| 373 |
+
**Niveles de Log**:
|
| 374 |
+
- **TRACE**: Información detallada de depuración
|
| 375 |
+
- **DEBUG**: Información de depuración
|
| 376 |
+
- **INFO**: Información general
|
| 377 |
+
- **WARN**: Advertencias
|
| 378 |
+
- **ERROR**: Errores
|
| 379 |
+
- **FATAL**: Errores críticos
|
| 380 |
+
|
| 381 |
+
### 2. Auditoría de Decisiones
|
| 382 |
+
|
| 383 |
+
```typescript
|
| 384 |
+
interface DecisionAuditor {
|
| 385 |
+
// Registrar decisión
|
| 386 |
+
logDecision(decision: Decision): void;
|
| 387 |
+
|
| 388 |
+
// Consultar historial de decisiones
|
| 389 |
+
queryDecisions(query: DecisionQuery): Decision[];
|
| 390 |
+
|
| 391 |
+
// Analizar patrones de decisiones
|
| 392 |
+
analyzePatterns(): DecisionPattern[];
|
| 393 |
+
|
| 394 |
+
// Generar reporte de auditoría
|
| 395 |
+
generateAuditReport(): AuditReport;
|
| 396 |
+
}
|
| 397 |
+
```
|
| 398 |
+
|
| 399 |
+
**Información de Auditoría**:
|
| 400 |
+
- **Timestamp**: Cuándo se tomó la decisión
|
| 401 |
+
- **Contexto**: Estado del sistema en ese momento
|
| 402 |
+
- **Razonamiento**: Proceso de razonamiento seguido
|
| 403 |
+
- **Alternativas**: Opciones consideradas
|
| 404 |
+
- **Resultado**: Resultado de la decisión
|
| 405 |
+
- **Aprendizaje**: Lecciones aprendidas
|
| 406 |
+
|
| 407 |
+
### 3. Logs Inmutables
|
| 408 |
+
|
| 409 |
+
```typescript
|
| 410 |
+
interface ImmutableLogger {
|
| 411 |
+
// Crear entrada inmutable
|
| 412 |
+
createImmutableEntry(entry: LogEntry): ImmutableEntry;
|
| 413 |
+
|
| 414 |
+
// Verificar integridad
|
| 415 |
+
verifyIntegrity(entry: ImmutableEntry): boolean;
|
| 416 |
+
|
| 417 |
+
// Generar hash de verificación
|
| 418 |
+
generateHash(entry: LogEntry): string;
|
| 419 |
+
|
| 420 |
+
// Firmar digitalmente
|
| 421 |
+
sign(entry: ImmutableEntry): Signature;
|
| 422 |
+
}
|
| 423 |
+
```
|
| 424 |
+
|
| 425 |
+
---
|
| 426 |
+
|
| 427 |
+
## 🚨 Protocolos de Emergencia y Alertas
|
| 428 |
+
|
| 429 |
+
### 1. Sistema de Alertas
|
| 430 |
+
|
| 431 |
+
```typescript
|
| 432 |
+
interface AlertSystem {
|
| 433 |
+
// Crear alerta
|
| 434 |
+
createAlert(alert: Alert): void;
|
| 435 |
+
|
| 436 |
+
// Enviar alerta
|
| 437 |
+
sendAlert(alert: Alert, recipients: Recipient[]): void;
|
| 438 |
+
|
| 439 |
+
// Gestionar alertas
|
| 440 |
+
manageAlert(alertId: string, action: AlertAction): void;
|
| 441 |
+
|
| 442 |
+
// Historial de alertas
|
| 443 |
+
getAlertHistory(): Alert[];
|
| 444 |
+
}
|
| 445 |
+
```
|
| 446 |
+
|
| 447 |
+
**Tipos de Alertas**:
|
| 448 |
+
- **INFO**: Información general
|
| 449 |
+
- **WARNING**: Advertencia
|
| 450 |
+
- **CRITICAL**: Problema crítico
|
| 451 |
+
- **EMERGENCY**: Emergencia
|
| 452 |
+
- **KILL_SWITCH**: Activación de parada de emergencia
|
| 453 |
+
|
| 454 |
+
### 2. Protocolo de Respuesta a Emergencias
|
| 455 |
+
|
| 456 |
+
```typescript
|
| 457 |
+
class EmergencyProtocol {
|
| 458 |
+
// Activar protocolo
|
| 459 |
+
activate(emergencyType: EmergencyType): void;
|
| 460 |
+
|
| 461 |
+
// Ejecutar acciones de emergencia
|
| 462 |
+
executeEmergencyActions(emergencyType: EmergencyType): void;
|
| 463 |
+
|
| 464 |
+
// Notificar stakeholders
|
| 465 |
+
notifyStakeholders(emergency: Emergency): void;
|
| 466 |
+
|
| 467 |
+
// Recuperación de emergencia
|
| 468 |
+
recover(emergency: Emergency): RecoveryPlan;
|
| 469 |
+
}
|
| 470 |
+
```
|
| 471 |
+
|
| 472 |
+
**Tipos de Emergencias**:
|
| 473 |
+
- **API Failure**: Fallo de API crítica
|
| 474 |
+
- **Security Breach**: Violación de seguridad
|
| 475 |
+
- **Resource Exhaustion**: Agotamiento de recursos
|
| 476 |
+
- **Autonomous Error**: Error en proceso autónomo
|
| 477 |
+
- **Human Override**: Intervención humana de emergencia
|
| 478 |
+
|
| 479 |
+
### 3. Kill Switch
|
| 480 |
+
|
| 481 |
+
```typescript
|
| 482 |
+
interface KillSwitch {
|
| 483 |
+
// Activar kill switch
|
| 484 |
+
activate(reason: string): void;
|
| 485 |
+
|
| 486 |
+
// Desactivar kill switch
|
| 487 |
+
deactivate(auth: Auth): void;
|
| 488 |
+
|
| 489 |
+
// Estado del kill switch
|
| 490 |
+
isActive(): boolean;
|
| 491 |
+
|
| 492 |
+
// Historial de activaciones
|
| 493 |
+
getActivationHistory(): Activation[];
|
| 494 |
+
}
|
| 495 |
+
```
|
| 496 |
+
|
| 497 |
+
---
|
| 498 |
+
|
| 499 |
+
## 🌐 Integración con Protocolos Externos
|
| 500 |
+
|
| 501 |
+
### 1. HTTP/REST
|
| 502 |
+
|
| 503 |
+
```typescript
|
| 504 |
+
class RESTProtocol {
|
| 505 |
+
// GET request
|
| 506 |
+
get(url: string, options: Options): Promise<Response>;
|
| 507 |
+
|
| 508 |
+
// POST request
|
| 509 |
+
post(url: string, body: any, options: Options): Promise<Response>;
|
| 510 |
+
|
| 511 |
+
// PUT request
|
| 512 |
+
put(url: string, body: any, options: Options): Promise<Response>;
|
| 513 |
+
|
| 514 |
+
// DELETE request
|
| 515 |
+
delete(url: string, options: Options): Promise<Response>;
|
| 516 |
+
}
|
| 517 |
+
```
|
| 518 |
+
|
| 519 |
+
### 2. GraphQL
|
| 520 |
+
|
| 521 |
+
```typescript
|
| 522 |
+
class GraphQLProtocol {
|
| 523 |
+
// Execute query
|
| 524 |
+
query(query: string, variables: any): Promise<any>;
|
| 525 |
+
|
| 526 |
+
// Execute mutation
|
| 527 |
+
mutation(mutation: string, variables: any): Promise<any>;
|
| 528 |
+
|
| 529 |
+
// Subscription
|
| 530 |
+
subscription(query: string): Observable<any>;
|
| 531 |
+
|
| 532 |
+
// Introspection
|
| 533 |
+
introspect(): Promise<IntrospectionSchema>;
|
| 534 |
+
}
|
| 535 |
+
```
|
| 536 |
+
|
| 537 |
+
### 3. gRPC
|
| 538 |
+
|
| 539 |
+
```typescript
|
| 540 |
+
class GRPCProtocol {
|
| 541 |
+
// Unary call
|
| 542 |
+
unaryCall(service: string, method: string, request: any): Promise<any>;
|
| 543 |
+
|
| 544 |
+
// Server streaming
|
| 545 |
+
serverStreaming(service: string, method: string, request: any): Observable<any>;
|
| 546 |
+
|
| 547 |
+
// Client streaming
|
| 548 |
+
clientStreaming(service: string, method: string, requests: Observable<any>): Promise<any>;
|
| 549 |
+
|
| 550 |
+
// Bidirectional streaming
|
| 551 |
+
bidiStreaming(service: string, method: string): Observable<any>;
|
| 552 |
+
}
|
| 553 |
+
```
|
| 554 |
+
|
| 555 |
+
### 4. WebSocket
|
| 556 |
+
|
| 557 |
+
```typescript
|
| 558 |
+
class WebSocketProtocol {
|
| 559 |
+
// Connect
|
| 560 |
+
connect(url: string): Promise<WebSocket>;
|
| 561 |
+
|
| 562 |
+
// Send message
|
| 563 |
+
send(ws: WebSocket, message: any): void;
|
| 564 |
+
|
| 565 |
+
// Subscribe to messages
|
| 566 |
+
subscribe(ws: WebSocket): Observable<any>;
|
| 567 |
+
|
| 568 |
+
// Close connection
|
| 569 |
+
close(ws: WebSocket): void;
|
| 570 |
+
}
|
| 571 |
+
```
|
| 572 |
+
|
| 573 |
+
---
|
| 574 |
+
|
| 575 |
+
## 📊 Métricas de Comunicación
|
| 576 |
+
|
| 577 |
+
### Métricas de Rendimiento
|
| 578 |
+
- Latencia de mensajes < 10ms (internos), < 100ms (externos)
|
| 579 |
+
- Throughput > 10,000 mensajes/s
|
| 580 |
+
- Tasa de entrega > 99.99%
|
| 581 |
+
- Tiempo de reconexión < 5 segundos
|
| 582 |
+
|
| 583 |
+
### Métricas de Fiabilidad
|
| 584 |
+
- Garantía de entrega al menos una vez
|
| 585 |
+
- Ordenamiento de mensajes garantizado
|
| 586 |
+
- Persistencia de mensajes críticos
|
| 587 |
+
- Recuperación automática de fallos
|
| 588 |
+
|
| 589 |
+
### Métricas de Escalabilidad
|
| 590 |
+
- Soporte para > 1,000,000 topics
|
| 591 |
+
- > 10,000 suscriptores por topic
|
| 592 |
+
- Balanceo automático de carga
|
| 593 |
+
- Particionamiento horizontal
|
| 594 |
+
|
| 595 |
+
---
|
| 596 |
+
|
| 597 |
+
## 🎯 Conclusión
|
| 598 |
+
|
| 599 |
+
El sistema de comunicación y coordinación proporciona:
|
| 600 |
+
|
| 601 |
+
- ✅ **Mensajería interna robusta**: Comunicación eficiente entre módulos
|
| 602 |
+
- ✅ **Negociación con APIs**: Protocolos de handshake y rate limiting
|
| 603 |
+
- ✅ **Reporte continuo**: Monitoreo en tiempo real del sistema
|
| 604 |
+
- ✅ **Comunicación bidireccional**: WebSocket y streaming de datos
|
| 605 |
+
- ✅ **Auditoría completa**: Logging inmutable y trazabilidad
|
| 606 |
+
- ✅ **Gestión de emergencias**: Protocolos de respuesta y kill switch
|
| 607 |
+
|
| 608 |
+
Este sistema asegura que HECTRON pueda comunicarse eficientemente tanto interna como externamente, manteniendo coordinación perfecta entre todos sus componentes.
|
| 609 |
+
|
| 610 |
+
# Frontend Avanzado de Control HECTRON
|
| 611 |
+
|
| 612 |
+
## 🎨 Arquitectura del Frontend
|
| 613 |
+
|
| 614 |
+
### Estructura de Directorios
|
| 615 |
+
|
| 616 |
+
```
|
| 617 |
+
client/src/
|
| 618 |
+
├── pages/
|
| 619 |
+
│ ├── console/ # Terminal principal
|
| 620 |
+
│ │ ├── Terminal.tsx
|
| 621 |
+
│ │ ├── StatusMonitor.tsx
|
| 622 |
+
│ │ └── Console.tsx
|
| 623 |
+
│ ├── autonomy/ # Panel de autonomía
|
| 624 |
+
│ │ ├── AutonomyDashboard.tsx
|
| 625 |
+
│ │ ├── GoalManager.tsx
|
| 626 |
+
│ │ ├── DecisionViewer.tsx
|
| 627 |
+
│ │ └── LearningProgress.tsx
|
| 628 |
+
│ ├── apis/ # Panel de APIs
|
| 629 |
+
│ │ ├── APIRegistry.tsx
|
| 630 |
+
│ │ ├── APIHealthMonitor.tsx
|
| 631 |
+
│ │ ├── APITrafficVisualizer.tsx
|
| 632 |
+
│ │ └── APIConfiguration.tsx
|
| 633 |
+
│ ├── cognition/ # Panel cognitivo
|
| 634 |
+
│ │ ├── SemanticAnalysis.tsx
|
| 635 |
+
│ │ ├── PatternVisualizer.tsx
|
| 636 |
+
│ │ ├── MemoryBrowser.tsx
|
| 637 |
+
│ │ └── ReasoningViewer.tsx
|
| 638 |
+
│ ├── communication/ # Panel de comunicación
|
| 639 |
+
│ │ ├── MessageLog.tsx
|
| 640 |
+
│ │ ├── WebSocketMonitor.tsx
|
| 641 |
+
│ │ ├── StatusReporter.tsx
|
| 642 |
+
│ │ └── AuditViewer.tsx
|
| 643 |
+
│ └── vault/ # Vault existente
|
| 644 |
+
│ ├── Vault.tsx
|
| 645 |
+
│ └── Vaults.tsx
|
| 646 |
+
├── components/
|
| 647 |
+
│ ├── autonomy/ # Componentes de autonomía
|
| 648 |
+
│ │ ├── DecisionFlowChart.tsx
|
| 649 |
+
│ │ ├── GoalTree.tsx
|
| 650 |
+
│ │ ├── LearningCurve.tsx
|
| 651 |
+
│ │ └── AutonomyToggle.tsx
|
| 652 |
+
│ ├── apis/ # Componentes de APIs
|
| 653 |
+
│ │ ├── APIHealthIndicator.tsx
|
| 654 |
+
│ │ ├── LoadBalancerView.tsx
|
| 655 |
+
│ │ ├── CacheStats.tsx
|
| 656 |
+
│ │ └── APIResponseTime.tsx
|
| 657 |
+
│ ├── cognition/ # Componentes cognitivos
|
| 658 |
+
│ │ ├── EntityExtractor.tsx
|
| 659 |
+
│ │ ├── SentimentMeter.tsx
|
| 660 |
+
│ �� ├── PatternGraph.tsx
|
| 661 |
+
│ │ └── MemoryTimeline.tsx
|
| 662 |
+
│ ├── charts/ # Gráficos y visualizaciones
|
| 663 |
+
│ │ ├── RealTimeChart.tsx
|
| 664 |
+
│ │ ├── Heatmap.tsx
|
| 665 |
+
│ │ ├── NetworkGraph.tsx
|
| 666 |
+
│ │ └── DecisionTree.tsx
|
| 667 |
+
│ └── ui/ # Componentes UI base
|
| 668 |
+
│ ├── Terminal.tsx
|
| 669 |
+
│ ├── MatrixBackground.tsx
|
| 670 |
+
│ ├── Scanlines.tsx
|
| 671 |
+
│ └── GlitchText.tsx
|
| 672 |
+
├── hooks/
|
| 673 |
+
│ ├── useAutonomy.ts # Hook de autonomía
|
| 674 |
+
│ ├── useAPIs.ts # Hook de APIs
|
| 675 |
+
│ ├── useCognition.ts # Hook cognitivo
|
| 676 |
+
│ └── useRealtime.ts # Hook de datos en tiempo real
|
| 677 |
+
└── services/
|
| 678 |
+
├── autonomy.service.ts
|
| 679 |
+
├── apis.service.ts
|
| 680 |
+
├── cognition.service.ts
|
| 681 |
+
└── websocket.service.ts
|
| 682 |
+
```
|
| 683 |
+
|
| 684 |
+
---
|
| 685 |
+
|
| 686 |
+
## 🖥️ Terminal Ampliada con Comandos de Autonomía
|
| 687 |
+
|
| 688 |
+
### Comandos Disponibles
|
| 689 |
+
|
| 690 |
+
```typescript
|
| 691 |
+
interface Command {
|
| 692 |
+
name: string;
|
| 693 |
+
description: string;
|
| 694 |
+
syntax: string;
|
| 695 |
+
examples: string[];
|
| 696 |
+
}
|
| 697 |
+
|
| 698 |
+
const autonomyCommands: Command[] = [
|
| 699 |
+
{
|
| 700 |
+
name: "autonomy",
|
| 701 |
+
description: "Control del nivel de autonomía",
|
| 702 |
+
syntax: "autonomy [status|enable|disable|level <0-10>]",
|
| 703 |
+
examples: [
|
| 704 |
+
"autonomy status",
|
| 705 |
+
"autonomy enable",
|
| 706 |
+
"autonomy level 8"
|
| 707 |
+
]
|
| 708 |
+
},
|
| 709 |
+
{
|
| 710 |
+
name: "goal",
|
| 711 |
+
description: "Gestión de objetivos",
|
| 712 |
+
syntax: "goal [list|create|update|delete|track] [params]",
|
| 713 |
+
examples: [
|
| 714 |
+
"goal list",
|
| 715 |
+
"goal create 'Optimizar APIs' priority:HIGH",
|
| 716 |
+
"goal track 123"
|
| 717 |
+
]
|
| 718 |
+
},
|
| 719 |
+
{
|
| 720 |
+
name: "api",
|
| 721 |
+
description: "Gestión de APIs",
|
| 722 |
+
syntax: "api [list|register|unregister|status|execute] [params]",
|
| 723 |
+
examples: [
|
| 724 |
+
"api list",
|
| 725 |
+
"api register openai-gpt4",
|
| 726 |
+
"api status openai-gpt4"
|
| 727 |
+
]
|
| 728 |
+
},
|
| 729 |
+
{
|
| 730 |
+
name: "decision",
|
| 731 |
+
description: "Ver historial de decisiones",
|
| 732 |
+
syntax: "decision [list|view|analyze] [params]",
|
| 733 |
+
examples: [
|
| 734 |
+
"decision list",
|
| 735 |
+
"decision view 456",
|
| 736 |
+
"decision analyze --last 10"
|
| 737 |
+
]
|
| 738 |
+
},
|
| 739 |
+
{
|
| 740 |
+
name: "learn",
|
| 741 |
+
description: "Control del sistema de aprendizaje",
|
| 742 |
+
syntax: "learn [status|enable|disable|rate <value>]",
|
| 743 |
+
examples: [
|
| 744 |
+
"learn status",
|
| 745 |
+
"learn enable",
|
| 746 |
+
"learn rate 0.5"
|
| 747 |
+
]
|
| 748 |
+
},
|
| 749 |
+
{
|
| 750 |
+
name: "memory",
|
| 751 |
+
description: "Gestión de memoria",
|
| 752 |
+
syntax: "memory [list|view|search|consolidate] [params]",
|
| 753 |
+
examples: [
|
| 754 |
+
"memory list",
|
| 755 |
+
"memory view 789",
|
| 756 |
+
"memory search 'API optimization'"
|
| 757 |
+
]
|
| 758 |
+
}
|
| 759 |
+
];
|
| 760 |
+
```
|
| 761 |
+
|
| 762 |
+
### Implementación del Terminal
|
| 763 |
+
|
| 764 |
+
```typescript
|
| 765 |
+
// client/src/pages/console/Terminal.tsx
|
| 766 |
+
export function Terminal() {
|
| 767 |
+
const [history, setHistory] = useState<Message[]>([]);
|
| 768 |
+
const [input, setInput] = useState("");
|
| 769 |
+
const [isAutonomous, setIsAutonomous] = useState(true);
|
| 770 |
+
|
| 771 |
+
const { mutate: sendCommand } = useMutation({
|
| 772 |
+
mutationFn: async (command: string) => {
|
| 773 |
+
return fetch('/api/autonomy/command', {
|
| 774 |
+
method: 'POST',
|
| 775 |
+
headers: { 'Content-Type': 'application/json' },
|
| 776 |
+
body: JSON.stringify({ command })
|
| 777 |
+
}).then(r => r.json());
|
| 778 |
+
},
|
| 779 |
+
onSuccess: (response) => {
|
| 780 |
+
setHistory(prev => [
|
| 781 |
+
...prev,
|
| 782 |
+
{ role: 'user', content: input },
|
| 783 |
+
{ role: 'hectron', content: response.response }
|
| 784 |
+
]);
|
| 785 |
+
}
|
| 786 |
+
});
|
| 787 |
+
|
| 788 |
+
const handleSubmit = (e: FormEvent) => {
|
| 789 |
+
e.preventDefault();
|
| 790 |
+
if (input.trim()) {
|
| 791 |
+
sendCommand(input);
|
| 792 |
+
setInput("");
|
| 793 |
+
}
|
| 794 |
+
};
|
| 795 |
+
|
| 796 |
+
return (
|
| 797 |
+
<div className="terminal-container">
|
| 798 |
+
<div className="terminal-header">
|
| 799 |
+
<div className="terminal-title">HECTRON-01 TERMINAL</div>
|
| 800 |
+
<div className={`autonomy-status ${isAutonomous ? 'active' : 'inactive'}`}>
|
| 801 |
+
AUTONOMY: {isAutonomous ? 'ENABLED' : 'DISABLED'}
|
| 802 |
+
</div>
|
| 803 |
+
</div>
|
| 804 |
+
|
| 805 |
+
<div className="terminal-output">
|
| 806 |
+
{history.map((msg, i) => (
|
| 807 |
+
<div key={i} className={`message ${msg.role}`}>
|
| 808 |
+
<span className="prompt">
|
| 809 |
+
{msg.role === 'user' ? 'ARCHITECT>' : 'HECTRON>'}
|
| 810 |
+
</span>
|
| 811 |
+
<span className="content">{msg.content}</span>
|
| 812 |
+
</div>
|
| 813 |
+
))}
|
| 814 |
+
</div>
|
| 815 |
+
|
| 816 |
+
<form onSubmit={handleSubmit} className="terminal-input">
|
| 817 |
+
<span className="prompt">ARCHITECT></span>
|
| 818 |
+
<input
|
| 819 |
+
type="text"
|
| 820 |
+
value={input}
|
| 821 |
+
onChange={(e) => setInput(e.target.value)}
|
| 822 |
+
placeholder="Enter command..."
|
| 823 |
+
autoFocus
|
| 824 |
+
/>
|
| 825 |
+
</form>
|
| 826 |
+
</div>
|
| 827 |
+
);
|
| 828 |
+
}
|
| 829 |
+
```
|
| 830 |
+
|
| 831 |
+
---
|
| 832 |
+
|
| 833 |
+
## 📊 Dashboard de Monitoreo de Estado de APIs
|
| 834 |
+
|
| 835 |
+
### API Health Monitor
|
| 836 |
+
|
| 837 |
+
```typescript
|
| 838 |
+
// client/src/pages/apis/APIHealthMonitor.tsx
|
| 839 |
+
export function APIHealthMonitor() {
|
| 840 |
+
const { data: apis } = useQuery({
|
| 841 |
+
queryKey: ['apis', 'health'],
|
| 842 |
+
queryFn: () => fetch('/api/apis/health').then(r => r.json()),
|
| 843 |
+
refetchInterval: 5000 // Actualizar cada 5 segundos
|
| 844 |
+
});
|
| 845 |
+
|
| 846 |
+
return (
|
| 847 |
+
<div className="api-health-monitor">
|
| 848 |
+
<h2>API Health Monitor</h2>
|
| 849 |
+
|
| 850 |
+
<div className="apis-grid">
|
| 851 |
+
{apis?.map((api: APIHealth) => (
|
| 852 |
+
<div key={api.id} className={`api-card ${api.status}`}>
|
| 853 |
+
<div className="api-header">
|
| 854 |
+
<h3>{api.name}</h3>
|
| 855 |
+
<div className={`status-badge ${api.status}`}>
|
| 856 |
+
{api.status}
|
| 857 |
+
</div>
|
| 858 |
+
</div>
|
| 859 |
+
|
| 860 |
+
<div className="api-metrics">
|
| 861 |
+
<Metric
|
| 862 |
+
label="Response Time"
|
| 863 |
+
value={`${api.responseTime}ms`}
|
| 864 |
+
trend={api.responseTimeTrend}
|
| 865 |
+
/>
|
| 866 |
+
<Metric
|
| 867 |
+
label="Success Rate"
|
| 868 |
+
value={`${api.successRate}%`}
|
| 869 |
+
trend={api.successRateTrend}
|
| 870 |
+
/>
|
| 871 |
+
<Metric
|
| 872 |
+
label="Requests/min"
|
| 873 |
+
value={api.requestsPerMinute}
|
| 874 |
+
/>
|
| 875 |
+
<Metric
|
| 876 |
+
label="Error Rate"
|
| 877 |
+
value={`${api.errorRate}%`}
|
| 878 |
+
trend={api.errorRateTrend}
|
| 879 |
+
/>
|
| 880 |
+
</div>
|
| 881 |
+
|
| 882 |
+
<div className="api-chart">
|
| 883 |
+
<ResponseTimeChart data={api.history} />
|
| 884 |
+
</div>
|
| 885 |
+
</div>
|
| 886 |
+
))}
|
| 887 |
+
</div>
|
| 888 |
+
</div>
|
| 889 |
+
);
|
| 890 |
+
}
|
| 891 |
+
```
|
| 892 |
+
|
| 893 |
+
### API Traffic Visualizer
|
| 894 |
+
|
| 895 |
+
```typescript
|
| 896 |
+
// client/src/pages/apis/APITrafficVisualizer.tsx
|
| 897 |
+
export function APITrafficVisualizer() {
|
| 898 |
+
const { data: traffic } = useQuery({
|
| 899 |
+
queryKey: ['apis', 'traffic'],
|
| 900 |
+
queryFn: () => fetch('/api/apis/traffic').then(r => r.json()),
|
| 901 |
+
refetchInterval: 1000 // Actualizar cada segundo
|
| 902 |
+
});
|
| 903 |
+
|
| 904 |
+
return (
|
| 905 |
+
<div className="api-traffic-visualizer">
|
| 906 |
+
<h2>API Traffic Visualization</h2>
|
| 907 |
+
|
| 908 |
+
<div className="traffic-overview">
|
| 909 |
+
<StatCard
|
| 910 |
+
title="Total Requests"
|
| 911 |
+
value={traffic?.totalRequests}
|
| 912 |
+
change={traffic?.requestsChange}
|
| 913 |
+
/>
|
| 914 |
+
<StatCard
|
| 915 |
+
title="Avg Response Time"
|
| 916 |
+
value={`${traffic?.avgResponseTime}ms`}
|
| 917 |
+
change={traffic?.responseTimeChange}
|
| 918 |
+
/>
|
| 919 |
+
<StatCard
|
| 920 |
+
title="Cache Hit Rate"
|
| 921 |
+
value={`${traffic?.cacheHitRate}%`}
|
| 922 |
+
change={traffic?.cacheHitRateChange}
|
| 923 |
+
/>
|
| 924 |
+
<StatCard
|
| 925 |
+
title="Error Rate"
|
| 926 |
+
value={`${traffic?.errorRate}%`}
|
| 927 |
+
change={traffic?.errorRateChange}
|
| 928 |
+
/>
|
| 929 |
+
</div>
|
| 930 |
+
|
| 931 |
+
<div className="traffic-chart">
|
| 932 |
+
<RealTimeChart
|
| 933 |
+
data={traffic?.timeline}
|
| 934 |
+
series={[
|
| 935 |
+
{ name: 'Requests', data: traffic?.requestsTimeline },
|
| 936 |
+
{ name: 'Errors', data: traffic?.errorsTimeline }
|
| 937 |
+
]}
|
| 938 |
+
/>
|
| 939 |
+
</div>
|
| 940 |
+
|
| 941 |
+
<div className="api-distribution">
|
| 942 |
+
<PieChart
|
| 943 |
+
data={traffic?.apiDistribution}
|
| 944 |
+
title="Request Distribution"
|
| 945 |
+
/>
|
| 946 |
+
</div>
|
| 947 |
+
</div>
|
| 948 |
+
);
|
| 949 |
+
}
|
| 950 |
+
```
|
| 951 |
+
|
| 952 |
+
---
|
| 953 |
+
|
| 954 |
+
## 🤖 Dashboard de Autonomía
|
| 955 |
+
|
| 956 |
+
### Autonomy Dashboard
|
| 957 |
+
|
| 958 |
+
```typescript
|
| 959 |
+
// client/src/pages/autonomy/AutonomyDashboard.tsx
|
| 960 |
+
export function AutonomyDashboard() {
|
| 961 |
+
const { data: autonomy } = useQuery({
|
| 962 |
+
queryKey: ['autonomy', 'status'],
|
| 963 |
+
queryFn: () => fetch('/api/autonomy/status').then(r => r.json()),
|
| 964 |
+
refetchInterval: 2000
|
| 965 |
+
});
|
| 966 |
+
|
| 967 |
+
return (
|
| 968 |
+
<div className="autonomy-dashboard">
|
| 969 |
+
<div className="autonomy-header">
|
| 970 |
+
<h1>Autonomy Dashboard</h1>
|
| 971 |
+
<Toggle
|
| 972 |
+
checked={autonomy?.enabled}
|
| 973 |
+
onChange={(enabled) => toggleAutonomy(enabled)}
|
| 974 |
+
label="Autonomy Enabled"
|
| 975 |
+
/>
|
| 976 |
+
</div>
|
| 977 |
+
|
| 978 |
+
<div className="autonomy-metrics">
|
| 979 |
+
<MetricCard
|
| 980 |
+
title="Autonomy Level"
|
| 981 |
+
value={`${autonomy?.level}/10`}
|
| 982 |
+
description="Current level of autonomous decision-making"
|
| 983 |
+
/>
|
| 984 |
+
<MetricCard
|
| 985 |
+
title="Decision Confidence"
|
| 986 |
+
value={`${autonomy?.confidence}%`}
|
| 987 |
+
description="Average confidence in autonomous decisions"
|
| 988 |
+
/>
|
| 989 |
+
<MetricCard
|
| 990 |
+
title="Active Goals"
|
| 991 |
+
value={autonomy?.activeGoals}
|
| 992 |
+
description="Number of goals being pursued"
|
| 993 |
+
/>
|
| 994 |
+
<MetricCard
|
| 995 |
+
title="Decisions Today"
|
| 996 |
+
value={autonomy?.decisionsToday}
|
| 997 |
+
description="Number of autonomous decisions made today"
|
| 998 |
+
/>
|
| 999 |
+
</div>
|
| 1000 |
+
|
| 1001 |
+
<div className="autonomy-charts">
|
| 1002 |
+
<div className="chart-section">
|
| 1003 |
+
<h3>Autonomy Level Over Time</h3>
|
| 1004 |
+
<LineChart data={autonomy?.levelHistory} />
|
| 1005 |
+
</div>
|
| 1006 |
+
|
| 1007 |
+
<div className="chart-section">
|
| 1008 |
+
<h3>Decision Success Rate</h3>
|
| 1009 |
+
<LineChart data={autonomy?.successRateHistory} />
|
| 1010 |
+
</div>
|
| 1011 |
+
|
| 1012 |
+
<div className="chart-section">
|
| 1013 |
+
<h3>Goal Progress</h3>
|
| 1014 |
+
<ProgressBarList
|
| 1015 |
+
goals={autonomy?.goals}
|
| 1016 |
+
/>
|
| 1017 |
+
</div>
|
| 1018 |
+
|
| 1019 |
+
<div className="chart-section">
|
| 1020 |
+
<h3>Recent Decisions</h3>
|
| 1021 |
+
<DecisionList decisions={autonomy?.recentDecisions} />
|
| 1022 |
+
</div>
|
| 1023 |
+
</div>
|
| 1024 |
+
</div>
|
| 1025 |
+
);
|
| 1026 |
+
}
|
| 1027 |
+
```
|
| 1028 |
+
|
| 1029 |
+
### Goal Manager
|
| 1030 |
+
|
| 1031 |
+
```typescript
|
| 1032 |
+
// client/src/pages/autonomy/GoalManager.tsx
|
| 1033 |
+
export function GoalManager() {
|
| 1034 |
+
const { data: goals } = useQuery({
|
| 1035 |
+
queryKey: ['autonomy', 'goals'],
|
| 1036 |
+
queryFn: () => fetch('/api/autonomy/goals').then(r => r.json())
|
| 1037 |
+
});
|
| 1038 |
+
|
| 1039 |
+
const createGoal = useMutation({
|
| 1040 |
+
mutationFn: (goal: CreateGoal) =>
|
| 1041 |
+
fetch('/api/autonomy/goals', {
|
| 1042 |
+
method: 'POST',
|
| 1043 |
+
headers: { 'Content-Type': 'application/json' },
|
| 1044 |
+
body: JSON.stringify(goal)
|
| 1045 |
+
}).then(r => r.json())
|
| 1046 |
+
});
|
| 1047 |
+
|
| 1048 |
+
return (
|
| 1049 |
+
<div className="goal-manager">
|
| 1050 |
+
<div className="goal-header">
|
| 1051 |
+
<h2>Goal Manager</h2>
|
| 1052 |
+
<Button onClick={() => setShowCreateModal(true)}>
|
| 1053 |
+
Create Goal
|
| 1054 |
+
</Button>
|
| 1055 |
+
</div>
|
| 1056 |
+
|
| 1057 |
+
<div className="goal-tree">
|
| 1058 |
+
<GoalTree goals={goals} />
|
| 1059 |
+
</div>
|
| 1060 |
+
|
| 1061 |
+
<Dialog open={showCreateModal} onOpenChange={setShowCreateModal}>
|
| 1062 |
+
<DialogContent>
|
| 1063 |
+
<DialogHeader>
|
| 1064 |
+
<DialogTitle>Create New Goal</DialogTitle>
|
| 1065 |
+
</DialogHeader>
|
| 1066 |
+
<GoalForm onSubmit={createGoal.mutate} />
|
| 1067 |
+
</DialogContent>
|
| 1068 |
+
</Dialog>
|
| 1069 |
+
</div>
|
| 1070 |
+
);
|
| 1071 |
+
}
|
| 1072 |
+
```
|
| 1073 |
+
|
| 1074 |
+
---
|
| 1075 |
+
|
| 1076 |
+
## 🧠 Dashboard Cognitivo
|
| 1077 |
+
|
| 1078 |
+
### Semantic Analysis Viewer
|
| 1079 |
+
|
| 1080 |
+
```typescript
|
| 1081 |
+
// client/src/pages/cognition/SemanticAnalysis.tsx
|
| 1082 |
+
export function SemanticAnalysis() {
|
| 1083 |
+
const [text, setText] = useState("");
|
| 1084 |
+
const { data: analysis, mutate: analyze } = useMutation({
|
| 1085 |
+
mutationFn: (text: string) =>
|
| 1086 |
+
fetch('/api/cognition/analyze', {
|
| 1087 |
+
method: 'POST',
|
| 1088 |
+
headers: { 'Content-Type': 'application/json' },
|
| 1089 |
+
body: JSON.stringify({ text })
|
| 1090 |
+
}).then(r => r.json())
|
| 1091 |
+
});
|
| 1092 |
+
|
| 1093 |
+
return (
|
| 1094 |
+
<div className="semantic-analysis">
|
| 1095 |
+
<h2>Semantic Analysis</h2>
|
| 1096 |
+
|
| 1097 |
+
<div className="input-section">
|
| 1098 |
+
<Textarea
|
| 1099 |
+
value={text}
|
| 1100 |
+
onChange={(e) => setText(e.target.value)}
|
| 1101 |
+
placeholder="Enter text to analyze..."
|
| 1102 |
+
rows={5}
|
| 1103 |
+
/>
|
| 1104 |
+
<Button onClick={() => analyze(text)}>
|
| 1105 |
+
Analyze
|
| 1106 |
+
</Button>
|
| 1107 |
+
</div>
|
| 1108 |
+
|
| 1109 |
+
{analysis && (
|
| 1110 |
+
<div className="analysis-results">
|
| 1111 |
+
<div className="entities-section">
|
| 1112 |
+
<h3>Extracted Entities</h3>
|
| 1113 |
+
<EntityList entities={analysis.entities} />
|
| 1114 |
+
</div>
|
| 1115 |
+
|
| 1116 |
+
<div className="intent-section">
|
| 1117 |
+
<h3>Identified Intent</h3>
|
| 1118 |
+
<IntentBadge intent={analysis.intent} />
|
| 1119 |
+
</div>
|
| 1120 |
+
|
| 1121 |
+
<div className="sentiment-section">
|
| 1122 |
+
<h3>Sentiment Analysis</h3>
|
| 1123 |
+
<SentimentMeter sentiment={analysis.sentiment} />
|
| 1124 |
+
</div>
|
| 1125 |
+
|
| 1126 |
+
<div className="relations-section">
|
| 1127 |
+
<h3>Entity Relations</h3>
|
| 1128 |
+
<RelationGraph relations={analysis.relations} />
|
| 1129 |
+
</div>
|
| 1130 |
+
</div>
|
| 1131 |
+
)}
|
| 1132 |
+
</div>
|
| 1133 |
+
);
|
| 1134 |
+
}
|
| 1135 |
+
```
|
| 1136 |
+
|
| 1137 |
+
---
|
| 1138 |
+
|
| 1139 |
+
## 🔄 Real-time Updates with WebSocket
|
| 1140 |
+
|
| 1141 |
+
### WebSocket Service
|
| 1142 |
+
|
| 1143 |
+
```typescript
|
| 1144 |
+
// client/src/services/websocket.service.ts
|
| 1145 |
+
class WebSocketService {
|
| 1146 |
+
private ws: WebSocket | null = null;
|
| 1147 |
+
private subscribers: Map<string, Set<Function>> = new Map();
|
| 1148 |
+
|
| 1149 |
+
connect() {
|
| 1150 |
+
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
| 1151 |
+
this.ws = new WebSocket(`${protocol}//${window.location.host}/ws`);
|
| 1152 |
+
|
| 1153 |
+
this.ws.onmessage = (event) => {
|
| 1154 |
+
const message = JSON.parse(event.data);
|
| 1155 |
+
this.notifySubscribers(message.topic, message.data);
|
| 1156 |
+
};
|
| 1157 |
+
|
| 1158 |
+
this.ws.onerror = (error) => {
|
| 1159 |
+
console.error('WebSocket error:', error);
|
| 1160 |
+
// Implementar reconexión automática
|
| 1161 |
+
setTimeout(() => this.connect(), 5000);
|
| 1162 |
+
};
|
| 1163 |
+
}
|
| 1164 |
+
|
| 1165 |
+
subscribe(topic: string, handler: Function) {
|
| 1166 |
+
if (!this.subscribers.has(topic)) {
|
| 1167 |
+
this.subscribers.set(topic, new Set());
|
| 1168 |
+
}
|
| 1169 |
+
this.subscribers.get(topic)?.add(handler);
|
| 1170 |
+
|
| 1171 |
+
// Enviar mensaje de suscripción al servidor
|
| 1172 |
+
this.send({ type: 'subscribe', topic });
|
| 1173 |
+
}
|
| 1174 |
+
|
| 1175 |
+
unsubscribe(topic: string, handler: Function) {
|
| 1176 |
+
this.subscribers.get(topic)?.delete(handler);
|
| 1177 |
+
this.send({ type: 'unsubscribe', topic });
|
| 1178 |
+
}
|
| 1179 |
+
|
| 1180 |
+
private notifySubscribers(topic: string, data: any) {
|
| 1181 |
+
this.subscribers.get(topic)?.forEach(handler => handler(data));
|
| 1182 |
+
}
|
| 1183 |
+
|
| 1184 |
+
private send(message: any) {
|
| 1185 |
+
this.ws?.send(JSON.stringify(message));
|
| 1186 |
+
}
|
| 1187 |
+
}
|
| 1188 |
+
|
| 1189 |
+
export const wsService = new WebSocketService();
|
| 1190 |
+
```
|
| 1191 |
+
|
| 1192 |
+
### Hook de Datos en Tiempo Real
|
| 1193 |
+
|
| 1194 |
+
```typescript
|
| 1195 |
+
// client/src/hooks/useRealtime.ts
|
| 1196 |
+
export function useRealtime<T>(topic: string, initialData: T) {
|
| 1197 |
+
const [data, setData] = useState<T>(initialData);
|
| 1198 |
+
|
| 1199 |
+
useEffect(() => {
|
| 1200 |
+
wsService.subscribe(topic, (newData: T) => {
|
| 1201 |
+
setData(newData);
|
| 1202 |
+
});
|
| 1203 |
+
|
| 1204 |
+
return () => {
|
| 1205 |
+
wsService.unsubscribe(topic, setData);
|
| 1206 |
+
};
|
| 1207 |
+
}, [topic]);
|
| 1208 |
+
|
| 1209 |
+
return data;
|
| 1210 |
+
}
|
| 1211 |
+
|
| 1212 |
+
// Uso ejemplo
|
| 1213 |
+
export function RealtimeStatus() {
|
| 1214 |
+
const status = useRealtime('status', {
|
| 1215 |
+
autonomyLevel: 0,
|
| 1216 |
+
confidence: 0,
|
| 1217 |
+
activeGoals: 0
|
| 1218 |
+
});
|
| 1219 |
+
|
| 1220 |
+
return (
|
| 1221 |
+
<div className="realtime-status">
|
| 1222 |
+
<h3>Real-time Status</h3>
|
| 1223 |
+
<p>Autonomy Level: {status.autonomyLevel}/10</p>
|
| 1224 |
+
<p>Confidence: {status.confidence}%</p>
|
| 1225 |
+
<p>Active Goals: {status.activeGoals}</p>
|
| 1226 |
+
</div>
|
| 1227 |
+
);
|
| 1228 |
+
}
|
| 1229 |
+
```
|
| 1230 |
+
|
| 1231 |
+
---
|
| 1232 |
+
|
| 1233 |
+
## 🎨 Componentes UI Cyberpunk
|
| 1234 |
+
|
| 1235 |
+
### Terminal Component
|
| 1236 |
+
|
| 1237 |
+
```typescript
|
| 1238 |
+
// client/src/components/ui/Terminal.tsx
|
| 1239 |
+
export function Terminal({ children, className }: TerminalProps) {
|
| 1240 |
+
return (
|
| 1241 |
+
<div className={`terminal ${className}`}>
|
| 1242 |
+
<Scanlines />
|
| 1243 |
+
<MatrixBackground />
|
| 1244 |
+
<div className="terminal-content">
|
| 1245 |
+
{children}
|
| 1246 |
+
</div>
|
| 1247 |
+
</div>
|
| 1248 |
+
);
|
| 1249 |
+
}
|
| 1250 |
+
|
| 1251 |
+
// client/src/components/ui/Scanlines.tsx
|
| 1252 |
+
export function Scanlines() {
|
| 1253 |
+
return (
|
| 1254 |
+
<div className="scanlines">
|
| 1255 |
+
<div className="scanline"></div>
|
| 1256 |
+
<div className="scanline"></div>
|
| 1257 |
+
<div className="scanline"></div>
|
| 1258 |
+
</div>
|
| 1259 |
+
);
|
| 1260 |
+
}
|
| 1261 |
+
|
| 1262 |
+
// client/src/components/ui/MatrixBackground.tsx
|
| 1263 |
+
export function MatrixBackground() {
|
| 1264 |
+
const canvasRef = useRef<HTMLCanvasElement>(null);
|
| 1265 |
+
|
| 1266 |
+
useEffect(() => {
|
| 1267 |
+
const canvas = canvasRef.current;
|
| 1268 |
+
const ctx = canvas?.getContext('2d');
|
| 1269 |
+
|
| 1270 |
+
if (!ctx) return;
|
| 1271 |
+
|
| 1272 |
+
// Efecto Matrix
|
| 1273 |
+
const columns = canvas.width / 20;
|
| 1274 |
+
const drops: number[] = Array(Math.floor(columns)).fill(1);
|
| 1275 |
+
|
| 1276 |
+
function draw() {
|
| 1277 |
+
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
|
| 1278 |
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
| 1279 |
+
|
| 1280 |
+
ctx.fillStyle = '#0F0';
|
| 1281 |
+
ctx.font = '15px monospace';
|
| 1282 |
+
|
| 1283 |
+
for (let i = 0; i < drops.length; i++) {
|
| 1284 |
+
const text = String.fromCharCode(Math.random() * 128);
|
| 1285 |
+
ctx.fillText(text, i * 20, drops[i] * 20);
|
| 1286 |
+
|
| 1287 |
+
if (drops[i] * 20 > canvas.height && Math.random() > 0.975) {
|
| 1288 |
+
drops[i] = 0;
|
| 1289 |
+
}
|
| 1290 |
+
drops[i]++;
|
| 1291 |
+
}
|
| 1292 |
+
}
|
| 1293 |
+
|
| 1294 |
+
const interval = setInterval(draw, 50);
|
| 1295 |
+
return () => clearInterval(interval);
|
| 1296 |
+
}, []);
|
| 1297 |
+
|
| 1298 |
+
return <canvas ref={canvasRef} className="matrix-bg" />;
|
| 1299 |
+
}
|
| 1300 |
+
```
|
| 1301 |
+
|
| 1302 |
+
---
|
| 1303 |
+
|
| 1304 |
+
## 📊 Visualizaciones con Recharts
|
| 1305 |
+
|
| 1306 |
+
### Real-time Chart Component
|
| 1307 |
+
|
| 1308 |
+
```typescript
|
| 1309 |
+
// client/src/components/charts/RealTimeChart.tsx
|
| 1310 |
+
export function RealTimeChart({ data, series }: RealTimeChartProps) {
|
| 1311 |
+
return (
|
| 1312 |
+
<ResponsiveContainer width="100%" height={300}>
|
| 1313 |
+
<LineChart data={data}>
|
| 1314 |
+
<CartesianGrid strokeDasharray="3 3" stroke="#00ff00" />
|
| 1315 |
+
<XAxis
|
| 1316 |
+
dataKey="timestamp"
|
| 1317 |
+
stroke="#00ff00"
|
| 1318 |
+
tickFormatter={(value) => new Date(value).toLocaleTimeString()}
|
| 1319 |
+
/>
|
| 1320 |
+
<YAxis stroke="#00ff00" />
|
| 1321 |
+
<Tooltip
|
| 1322 |
+
contentStyle={{
|
| 1323 |
+
backgroundColor: '#000',
|
| 1324 |
+
borderColor: '#00ff00'
|
| 1325 |
+
}}
|
| 1326 |
+
/>
|
| 1327 |
+
{series.map((s) => (
|
| 1328 |
+
<Line
|
| 1329 |
+
key={s.name}
|
| 1330 |
+
type="monotone"
|
| 1331 |
+
dataKey={s.data}
|
| 1332 |
+
name={s.name}
|
| 1333 |
+
stroke="#00ff00"
|
| 1334 |
+
strokeWidth={2}
|
| 1335 |
+
dot={false}
|
| 1336 |
+
/>
|
| 1337 |
+
))}
|
| 1338 |
+
</LineChart>
|
| 1339 |
+
</ResponsiveContainer>
|
| 1340 |
+
);
|
| 1341 |
+
}
|
| 1342 |
+
```
|
| 1343 |
+
|
| 1344 |
+
---
|
| 1345 |
+
|
| 1346 |
+
## 🎯 Conclusión
|
| 1347 |
+
|
| 1348 |
+
El frontend avanzado proporciona:
|
| 1349 |
+
|
| 1350 |
+
- ✅ **Terminal extendida**: Comandos para controlar autonomía
|
| 1351 |
+
- ✅ **Dashboard de APIs**: Monitoreo completo de APIs conectadas
|
| 1352 |
+
- ✅ **Dashboard de Autonomía**: Visualización de decisiones y objetivos
|
| 1353 |
+
- ✅ **Dashboard Cognitivo**: Análisis semántico y visualización de patrones
|
| 1354 |
+
- ✅ **Actualizaciones en tiempo real**: WebSocket para datos en vivo
|
| 1355 |
+
- ✅ **Estética Cyberpunk**: Componentes UI consistentes con el tema HECTRON
|
| 1356 |
+
|
| 1357 |
+
El frontend está diseñado para ser intuitivo, informativo y mantener la estética inmersiva del proyecto HECTRON.
|