#!/usr/bin/env bash # pi-gpt6luna-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 `pi -p --mode json` 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 pi"}' >> "$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=pi export AGENT_HARNESS_TITLE="pi coding agent 0.73.1 (badlogic/pi-mono)" export AGENT_MODEL=gpt-6-luna # the name the harness uses export UPSTREAM_MODEL=openai/gpt-6-luna # what the relay sends to OpenRouter export AGENT_CONTEXT=1050000 # GPT-6 Luna: 1.05M context export AGENT_VISION=1 export LLM_BASE_URL=http://127.0.0.1:9000/v1 # Node (the harness) sends its own web requests through HTTP(S)_PROXY, the m64 gate (as gx10 does). export NODE_USE_ENV_PROXY=1 export RELAY_TITLE="m64 pi-gpt6luna-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 pi shim exited"}' >> "$M64_STATUS" kill -TERM $$ ) & exec /opt/gateway/bin/python /capsule/agent_gateway.py