#!/usr/bin/env bash # hermes-glmflash-openrouter-gb10 entrypoint. Runs inside the container; takes no arguments. # Three processes, all in this container: # 127.0.0.1:9000 llm_relay.py OpenAI-compatible; forces the model, goes out via the gate # 127.0.0.1:4096 cli_shim.py runs `hermes -z` once per prompt # 0.0.0.0:$M64_PORT agent_gateway.py the agent.session API m64's front proxies to set -eu echo '{"phase":"loading","detail":"starting hermes"}' >> "$M64_STATUS" export HOME=/scratch/home export WORK_DIR=/scratch/work export SHIM_HOMES=/scratch/homes mkdir -p "$HOME" "$WORK_DIR/sessions" "$SHIM_HOMES" export AGENT_HARNESS=hermes export AGENT_HARNESS_TITLE="Hermes Agent v2026.9.21 (NousResearch)" export AGENT_MODEL=glm-5.3-flash # the name the harness uses export UPSTREAM_MODEL=z-ai/glm-5.3-flash # what the relay sends to OpenRouter export AGENT_CONTEXT=1310720 # GLM 5.3 Flash: 1.3M context export AGENT_VISION=1 export LLM_BASE_URL=http://127.0.0.1:9000/v1 export RELAY_TITLE="m64 hermes-glmflash-openrouter-gb10" python3 -u /capsule/llm_relay.py & RELAY_PID=$! python3 -u /capsule/cli_shim.py & SHIM_PID=$! # If the relay or the shim dies, take the container down so m64 reports the error ($$ is # the gateway after the exec below). A dead child lingers as a zombie: test its state. alive() { [ -r "/proc/$1/stat" ] && [ "$(cut -d')' -f2 "/proc/$1/stat" | cut -d' ' -f2)" != Z ]; } ( while alive "$RELAY_PID" && alive "$SHIM_PID"; do sleep 5; done echo '{"phase":"error","detail":"the LLM relay or the hermes shim exited"}' >> "$M64_STATUS" kill -TERM $$ ) & exec /opt/gateway/bin/python /capsule/agent_gateway.py