From fc6e91186622ef8e005f836cf56b3615ca0e48b8 Mon Sep 17 00:00:00 2001 From: Antigravity Date: Sun, 10 May 2026 00:56:28 -0300 Subject: [PATCH] Fix syntax error by pre-quoting task before sending to Hermes API --- core_tools.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core_tools.py b/core_tools.py index 86bdef6..dcc0bc8 100644 --- a/core_tools.py +++ b/core_tools.py @@ -490,13 +490,16 @@ def delegate_to_hermes(task: str) -> str: import urllib.request import json + safe_task = shlex.quote(task) + # Tentativa 1: Via API HTTP Interna do Coolify para o novo Hermes url = "http://qfduyd1pvznx1z53mxbj46ee-hermes:8642/chat" headers = { "Content-Type": "application/json", "Authorization": "Bearer hermes-vps-513d26e0-secure-key" } - data = json.dumps({"message": task, "text": task}).encode("utf-8") + # Envia a string já encapada com aspas simples (safe_task) para evitar erro de /bin/sh no destino + data = json.dumps({"message": safe_task, "text": safe_task}).encode("utf-8") try: req = urllib.request.Request(url, data=data, headers=headers, method="POST") @@ -505,7 +508,6 @@ def delegate_to_hermes(task: str) -> str: return res_data.get("reply", res_data.get("response", str(res_data))) except Exception as api_err: # Tentativa 2: Fallback via docker exec no container do Coolify - safe_task = shlex.quote(task) # Primeiro, pegamos o ID exato do container do hermes no Coolify get_id_cmd = "docker ps -q -f name=qfduyd1pvznx1z53mxbj46ee-hermes" container_id = run_bash(get_id_cmd).strip()