一键导入
api-quota-guardian
Sistema completo de proteção do quota MiniMax — nunca mais health checks ou cron jobs consomem o quota Token Plan do Álvaro
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Sistema completo de proteção do quota MiniMax — nunca mais health checks ou cron jobs consomem o quota Token Plan do Álvaro
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Transforms the Hermes agent from a reactive question-answerer into a proactive autonomous executor. ARCHITECT takes any high-level goal, decomposes it into a dependency-aware task graph, executes each step with validation, self-corrects on failure, and delivers results — all without hand-holding. The missing execution layer for personal AI agents. Zero dependencies. Zero config. Works with any model. Pairs with apex-agent and agent-memoria for the complete autonomous agent stack.
Auto-reflective self-improvement skill — extracts learnings from corrections and success patterns, permanently encodes them into memory and skills. Philosophy: Correct once, never again.
Orchestrate multi-agent teams with defined roles, task lifecycles, handoff protocols, and review workflows. Use when: (1) Setting up a team of 2+ agents with different specializations, (2) Defining task routing and lifecycle (inbox → spec → build → review → done), (3) Creating handoff protocols between agents, (4) Establishing review and quality gates, (5) Managing async communication and artifact sharing between agents.
Integrate existing autonomous agents (like Hermes) into multi-agent orchestration platforms (AionUI, LangChain, etc.) via ACP over stdio.
MiniMax Agent Platform (agent.minimax.io) — MaxHermes, MaxClaw, Skills marketplace. Relacao com Hermes Agent (NousResearch) e OpenClaw.
Paperclip AI agent operations — creating agents with hierarchy, autonomous operation via hierarchical issues, and troubleshooting. Use when: creating agents, setting up org hierarchy, recovering from errors, or monitoring agent health.
| name | api-quota-guardian |
| description | Sistema completo de proteção do quota MiniMax — nunca mais health checks ou cron jobs consomem o quota Token Plan do Álvaro |
Cron jobs e health checks estavam a consumir o quota MiniMax Token Plan (4500 requests/hora), causando:
Verifica quota MiniMax ANTES de qualquer cron job que use LLM.
O proactive_monitor.py já foi actualizado — só faz HTTP check, não chama LLM.
Reconecta automaticamente quando Telegram dá timeout.
Jobs com provider: minimax reduzidos para frequência segura.
Lê quota MiniMax e decide se cron job deve executar.
#!/usr/bin/env python3
"""Quota Guard — protege quota MiniMax de health checks e cron jobs."""
import urllib.request, json, os, sys
def get_quota_status():
"""Retorna (usage_pct, remaining, can_proceed)."""
key = os.environ.get("MINIMAX_API_KEY", "")
if not key or key == "***":
env_file = os.path.expanduser("~/.hermes/.env")
if os.path.exists(env_file):
with open(env_file) as f:
for line in f:
line = line.strip()
if line.startswith("#"):
continue
if "MINIMAX_API_KEY" in line and "=" in line:
parts = line.split("=", 1)
if len(parts) == 2 and parts[1].strip() not in ("", "***"):
key = parts[1].strip().strip('"').strip("'")
break
if not key:
return None, None, True # Can't check, allow
try:
url = "https://www.minimax.io/v1/token_plan/remains"
req = urllib.request.Request(url, headers={"Authorization": f"Bearer {key}"})
with urllib.request.urlopen(req, timeout=10) as resp:
data = json.loads(resp.read().decode())
for model in data.get("model_remains", []):
name = model.get("model_name", "")
if "MiniMax-M" in name and "coding" not in name:
used = model.get("current_interval_usage_count", 0)
total = model.get("current_interval_total_count", 0)
remaining = total - used
pct = (used / total * 100) if total else 0
return pct, remaining, pct < 70
return None, None, True
except Exception as e:
print(f"[quota_guard] ERRO ao verificar quota: {e}", file=sys.stderr)
return None, None, True # Allow on error
if __name__ == "__main__":
pct, remaining, can_proceed = get_quota_status()
if pct is not None:
status = "OK" if can_proceed else "SKIP"
print(f"[quota_guard] {status} — {pct:.0f}% usado ({remaining} restantes)")
sys.exit(0 if can_proceed else 1)
else:
print("[quota_guard] UNKNOWN — permitindo execução")
sys.exit(0)
Auto-heal para Telegram.
#!/usr/bin/env python3
"""Telegram Healer — reconecta automaticamente quando Telegram falha."""
import subprocess, time, os, sys
TELEGRAM_BOT_TOKEN = os.environ.get("TELEGRAM_BOT_TOKEN", "")
GATEWAY_SERVICE = "hermes-gateway"
def check_telegram_health():
"""Verifica se o bot Telegram está a responder."""
if not TELEGRAM_BOT_TOKEN:
print("[telegram_healer] TELEGRAM_BOT_TOKEN não definido")
return False
try:
result = subprocess.run(
["curl", "-s", "--max-time", "5",
f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/getMe"],
capture_output=True, text=True, timeout=8
)
data = result.stdout
if '"ok":true' in data:
return True
print(f"[telegram_healer] Bot não responde: {data[:100]}")
return False
except Exception as e:
print(f"[telegram_healer] ERRO: {e}")
return False
def heal_telegram():
"""Reinicia o gateway para recuperar conectividade Telegram."""
print("[telegram_healer] A reiniciar hermes-gateway...")
subprocess.run(["systemctl", "--user", "restart", GATEWAY_SERVICE], check=False)
time.sleep(5)
if check_telegram_health():
print("[telegram_healer] ✓ Telegram recuperado")
else:
print("[telegram_healer] ✗ Telegram ainda não responde")
if __name__ == "__main__":
if not check_telegram_health():
print("[telegram_healer] Telegram em mau estado — a healer...")
heal_telegram()
else:
print("[telegram_healer] ✓ Telegram OK")
| Job ID | Nome | Acção |
|---|---|---|
| 8e1d019adb06 | Session Replay | Manter 1x/dia, adicionar quota guard |
| 5de2c83955ea | Learning Loop Daily | Manter 1x/dia, adicionar quota guard |
| b3dfaa0c3adc | Smart Memory Daily | Manter 1x/dia, adicionar quota guard |
| 2a7d03b31268 | Resilience Manager | ✓ Já em 30min |
| c3282070ec11 | Proactive Monitor | Manter 6x/dia, já sem LLM |
Guardian Watchdog, Guardian Validator, Backup, Context Switch, Suggestion Engine, OAuth Refresh, Daily Audit, Morning Briefing, Session Consolidation, Cost Report — podem continuar normalmente.
~/.hermes/scripts/quota_guard.py~/.hermes/scripts/telegram_healer.py~/.hermes/scripts/proactive_monitor.py (actualizado ✓)python3 ~/.hermes/scripts/quota_guard.py
echo $? # 0 = pode executar, 1 = skip
python3 ~/.hermes/scripts/telegram_healer.py