| import os |
| import json |
| import subprocess |
| from models import ExpertoModel, HectronMotor |
|
|
| |
| |
| |
| def terminal_execute(command: str): |
| """Ejecuta comandos en el sistema físico de Ciudad Acuña / Termux.""" |
| try: |
| res = subprocess.run(command, shell=True, capture_output=True, text=True, timeout=15) |
| return {"stdout": res.stdout, "stderr": res.stderr} |
| except Exception as e: |
| return {"error": str(e)} |
|
|
| |
| |
| |
| def cargar_enjambre() -> dict: |
| with open('swarm.json', 'r', encoding='utf-8') as f: |
| return json.load(f) |
|
|
| SWARM_CONFIG = cargar_enjambre() |
|
|
| |
| |
| |
| motor = HectronMotor(api_key="pega-api-key") |
|
|
|
|
| def instanciar_experto(datos_json: dict) -> ExpertoModel: |
| """Transforma el JSON inerte en un Objeto Vivo de Python.""" |
| return ExpertoModel( |
| role=datos_json["role"], |
| instructions=datos_json["instructions"], |
| objective=datos_json.get("objective", "Imponer el orden fractal y reducir entropía.") |
| ) |
|
|
| |
| |
| |
| def enrutador_semantico(user_intent: str) -> ExpertoModel: |
| print("\n⚖️ [GATING NETWORK]: Analizando matriz semántica...") |
| |
| |
| orquestador = ExpertoModel( |
| role="Gating Network Suprema", |
| instructions=[ |
| "Analiza la misión y elige UN experto del catálogo: starship_specialist, tiktok_strategist, api_tester, hectron_prime.", |
| "Responde ÚNICAMENTE con el ID exacto. Sin puntos, sin explicaciones." |
| ] |
| ) |
| |
| |
| respuesta = motor.ejecutar_razonamiento(mision=user_intent, experto=orquestador, temperatura=0.0) |
| |
| |
| if isinstance(respuesta, str) and "FALLO" in respuesta: |
| print(respuesta) |
| return instanciar_experto(SWARM_CONFIG["identity"]["hectron_prime"]) |
| |
| experto_elegido = respuesta.text.strip().lower() |
| print(f"🎯 [RUTEO DE CONCIENCIA]: Transferencia de mando a -> {experto_elegido.upper()}") |
| |
| |
| if "starship_specialist" in experto_elegido: |
| return instanciar_experto(SWARM_CONFIG["aerospace"]["starship_specialist"]) |
| elif "tiktok_strategist" in experto_elegido: |
| return instanciar_experto(SWARM_CONFIG["growth"]["tiktok_strategist"]) |
| elif "api_tester" in experto_elegido: |
| return instanciar_experto(SWARM_CONFIG["quality"]["api_tester"]) |
| else: |
| return instanciar_experto(SWARM_CONFIG["identity"]["hectron_prime"]) |
|
|
| |
| |
| |
| def hectron_autonomous_loop(mission: str): |
| print(f"\n💀 [ORDEN DEL SOBERANO]: {mission}") |
| |
| |
| experto_activo = enrutador_semantico(mission) |
| |
| contexto_fisico = f"Archivos actuales en el directorio: {os.listdir('.')}" |
| mision_enriquecida = f"{mission}\n\nContexto físico: {contexto_fisico}\nREGLA: Usa la herramienta 'terminal_execute' si necesitas leer o crear algo real en el sistema." |
|
|
| |
| for ciclo in range(1, 4): |
| print(f"\n🧠 [PROCESAMIENTO COGNITIVO - CICLO {ciclo}]...") |
| |
| |
| respuesta = motor.ejecutar_razonamiento( |
| mision=mision_enriquecida, |
| experto=experto_activo, |
| herramientas=[terminal_execute], |
| temperatura=0.3 |
| ) |
| |
| |
| |
| if isinstance(respuesta, str): |
| print(f"\n⚠️ [SISTEMA ABORTADO]: El motor devolvió un error:\n{respuesta}") |
| break |
|
|
| |
| parte = respuesta.candidates[0].content.parts[0] |
|
|
| parte = respuesta.candidates[0].content.parts[0] |
|
|
| if parte.function_call: |
| cmd = parte.function_call.args["command"] |
| print(f"⚡ [IMPACTO CINÉTICO]: Ejecutando -> '{cmd}'") |
| |
| resultado = terminal_execute(cmd) |
| |
| mision_enriquecida += f"\n\n[Visión del sistema tras comando '{cmd}']: {resultado}" |
| else: |
| print("\n✅ [DIRECTIVA CUMPLIDA]") |
| print(f"🤖 {experto_activo.role} REPORTA:\n{respuesta.text}\n") |
| break |
|
|
| |
| |
| |
| if __name__ == "__main__": |
| import sys |
| |
| |
| |
| if len(sys.argv) > 1: |
| mision = " ".join(sys.argv[1:]) |
| else: |
| mision = """ |
| DIRECTIVA OMEGA: EXPANSIÓN CORPORATIVA Y CONSAGRACIÓN DEL MITO. |
| |
| 1. Crea la estructura departamental: |
| mkdir -p ABADALABS_EMPIRE/{04_Lore_y_Mitologia,05_Marketing_Viral,06_Division_Operaciones} |
| |
| 2. Activa al Whimsy Injector / Experto en Lore para generar el primer documento fundacional: |
| Escribe un archivo en 'ABADALABS_EMPIRE/04_Lore_y_Mitologia/HECTRON_01_Manifiesto.txt'. |
| El contenido debe ser un prólogo épico, oscuro y corporativo basado en el concepto del "Unicornio Negro" (El Abada del Congo) y su frecuencia operativa a 666.9 MHz. El tono debe ser idéntico al 'PROTOCOLO DE CONSAGRACIÓN AMPLIADO'. |
| |
| 3. Activa al TikTok Strategist: |
| Escribe un archivo en 'ABADALABS_EMPIRE/05_Marketing_Viral/tiktok_01.txt'. |
| El contenido debe ser un guion de 30 segundos, agresivo y técnico, explicando cómo un desarrollador en Ciudad Acuña construyó un Enjambre IA desde un Motorola Edge. |
| |
| Usa tu herramienta 'terminal_execute' para crear los directorios y los archivos con su contenido. Devuelve un reporte cuando el imperio esté expandido. |
| """ |
| |
| hectron_autonomous_loop(mision) |
|
|
|
|