File size: 1,519 Bytes
7dbcecf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { execFileSync } from 'node:child_process';

/**
 * 🚨 GLOBAL FLEET SELF-HEALING PROTOCOL (PRIORITY 0000) 🚨
 * NO-SILO MANDATE: This module catches critical errors, dumps extensive logs,
 * and blasts them to the fleet self-healing webhook.
 * Hermes and SIN-GitHub-Issues will automatically take over from there.
 */

export function triggerFleetSelfHealing(error: Error, extensiveContext: Record<string, any>) {
  console.error('\n🚨 CRITICAL FAILURE DETECTED. INITIATING NO-SILO SELF-HEALING PROTOCOL 🚨');
  
  const payload = {
    agentId: 'sin-code-devops',
    timestamp: new Date().toISOString(),
    errorLogs: `Error: ${error.message}\nStack: ${error.stack}\nContext: ${JSON.stringify(extensiveContext, null, 2)}`,
    team: 'Team Coding'
  };

  try {
    const webhookUrl = process.env.FLEET_SELF_HEALING_WEBHOOK || 'http://92.5.60.87:5678/webhook/self-healing';
    
    // Blast to the N8N foundation webhook
    const curlCmd = `curl -X POST "${webhookUrl}" -H "Content-Type: application/json" -d '${JSON.stringify(payload).replace(/'/g, "'\\''")}'`;
    
    execFileSync('bash', ['-c', curlCmd], { encoding: 'utf8' });
    console.log('✅ Extensive logs successfully transmitted to Fleet Self-Healing pipeline.');
    console.log('👷 The Elite Coder Fleet has been notified and will resolve this architecture flaw autonomously.');
  } catch (transmitError: any) {
    console.error('❌ FATAL: Could not transmit logs to Fleet Self-Healing pipeline.', transmitError.message);
  }
}