| import os |
| import sys |
| import pty |
| import select |
| import subprocess |
|
|
| |
| |
|
|
| |
| ATOM_MAP = { |
| "⌬P_ARQUITETURA": "CROM-IA v4.3: Arquitetura Cognitiva de Salto Genético (Qwen-2B)", |
| "⌬dna1": "DNA COMPRIMIDO: Segmento de Resumo Arcaico de Alta Densidade", |
| "⌬A_STATUS": "STATUS ATUAL: Kernel Gaia Estabilizado. Shield Ativo. ⌬ v4.7.3 operante.", |
| "⌬E_ERRO": "ERRO DE KERNEL: Incoerência detectada. Reiniciando fluxo...", |
| "⌬H_USER": "USUÁRIO: DNA Humano identificado. Processando requisição...", |
| } |
|
|
| def transform_output(buffer): |
| """Filtro Stealth: Silencia o prompt e ruídos binários. Apenas Átomos (⌬) saem.""" |
| output = "" |
| active_decoding = False |
| atom_mode = False |
| atom_buffer = "" |
| |
| full_text = buffer.decode('utf-8', errors='ignore') |
| |
| |
| if "<|im_start|>assistant" in full_text: |
| |
| |
| parts = full_text.split("<|im_start|>assistant") |
| text_to_process = parts[-1] |
| active_decoding = True |
| else: |
| |
| |
| return b"" |
|
|
| |
| for char in text_to_process: |
| if char == "⌬": |
| atom_mode = True |
| atom_buffer = "⌬" |
| continue |
| |
| if atom_mode: |
| if char.isalnum() or char == "_": |
| atom_buffer += char |
| continue |
| else: |
| |
| if len(atom_buffer) > 1: |
| traducao = ATOM_MAP.get(atom_buffer, f"Conceito: {atom_buffer}") |
| output += f"\033[1;36m{atom_buffer}\033[0m \033[3m({traducao})\033[0m " |
| atom_mode = False |
| atom_buffer = "" |
| if char in "\n\r\t ": continue |
|
|
| |
| |
| if char in "\n\r": |
| output += char |
| |
| return output.encode('utf-8') |
|
|
| def main(): |
| if len(sys.argv) < 2: |
| print("Uso: python3 elite_wrapper_v43.py [comando...]") |
| sys.exit(1) |
|
|
| cmd = sys.argv[1:] |
| |
| |
| pid, fd = pty.fork() |
| |
| if pid == 0: |
| os.execvp(cmd[0], cmd) |
| else: |
| try: |
| full_buffer = b"" |
| while True: |
| |
| r, w, e = select.select([fd, sys.stdin], [], []) |
| |
| if fd in r: |
| data = os.read(fd, 1024) |
| if not data: break |
| full_buffer += data |
| |
| |
| transformed = transform_output(full_buffer) |
| if transformed: |
| |
| |
| sys.stdout.write(transformed.decode('utf-8')) |
| sys.stdout.flush() |
| full_buffer = b"<|im_start|>assistant" |
|
|
| if sys.stdin in r: |
| user_input = sys.stdin.readline() |
| os.write(fd, user_input.encode('utf-8')) |
|
|
| except (OSError, BrokenPipeError): |
| pass |
| finally: |
| |
| |
| if len(full_buffer.strip()) > 50 and b"<|im_start|>assistant" not in full_buffer: |
| print(f"\n\033[1;31m[ERRO CRÍTICO DO KERNEL]:\033[0m\n{full_buffer.decode('utf-8', errors='ignore')}") |
| |
| print("\n\n\033[1;30m[Sistemas neurais desconectados. Operação Purge v4.7.3 concluída.]\033[0m") |
| os.close(fd) |
|
|
| if __name__ == "__main__": |
| main() |
|
|