Update Hermes integration

This commit is contained in:
Antigravity
2026-05-10 00:37:18 -03:00
parent 7b31435895
commit 8b577242ff
3 changed files with 54 additions and 12 deletions

View File

@@ -485,12 +485,40 @@ class BrowserCloudTools:
# ============================================================
def delegate_to_hermes(task: str) -> str:
"""Delega uma tarefa complexa para o Hermes Agent (MiniMax 2.7) resolver na VPS."""
"""Delega uma tarefa complexa para o NOVO Hermes Agent no Coolify."""
import shlex
safe_task = shlex.quote(task)
# Executa o hermes no modo oneshot (-z), com timeout estendido de 5 min
command = f"hermes -z {safe_task}"
return run_bash(command, timeout=300)
import urllib.request
import json
# 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")
try:
req = urllib.request.Request(url, data=data, headers=headers, method="POST")
with urllib.request.urlopen(req, timeout=300) as response:
res_data = json.loads(response.read().decode())
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()
if container_id and not "ERRO" in container_id:
# Tenta rodar o CLI dentro do container
exec_cmd = f"docker exec {container_id} hermes -z {safe_task}"
res = run_bash(exec_cmd, timeout=300)
if "not found" not in res.lower() and "no such file" not in res.lower():
return res
# Tentativa 3: Fallback para o CLI antigo do host (Antigravity original)
return run_bash(f"hermes -z {safe_task}", timeout=300)
# ============================================================
# REGISTRY CENTRALIZADO