m64_8a809e3131db / start.sh
55 lines, 2.7 KBraw
1#!/usr/bin/env bash2# opencode-qwen36-gb10 entrypoint. Runs inside the container; takes no arguments.3# opencode serve on 0.0.0.0:4096, then the control gateway on $M64_PORT. Port 4096 is4# [runtime.app]: m64 exposes it (the full opencode web UI and API) on a second front5# port. 0.0.0.0 is inside the container: only the gate can reach its internal network.6set -eu78echo '{"phase":"loading","detail":"vLLM: loading Qwen3.6-35B-A3B NVFP4"}' >> "$M64_STATUS"9mkdir -p /scratch/cache10export HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1 VLLM_NO_USAGE_STATS=1 DO_NOT_TRACK=111export XDG_CACHE_HOME=/scratch/cache VLLM_CACHE_ROOT=/scratch/cache/vllm TRITON_CACHE_DIR=/scratch/cache/triton12# The LLM: gx10 agents/sandbox.sh qwen36-35b profile (util 0.85, ctx 262144), on loopback.13vllm serve /weights/model --host 127.0.0.1 --port 9000 \14 --served-model-name qwen36-35b \15 --quantization compressed-tensors \16 --moe-backend marlin \17 --kv-cache-dtype fp8 \18 --max-model-len 262144 \19 --gpu-memory-utilization 0.85 \20 --max-num-seqs 4 \21 --max-num-batched-tokens 4096 \22 --enforce-eager \23 --enable-auto-tool-choice \24 --tool-call-parser qwen3_coder \25 --reasoning-parser qwen3 \26 --enable-prefix-caching &27VLLM_PID=$!28export AGENT_PROVIDER=local-vllm AGENT_MODEL=qwen36-35b2930# HOME is the run's /scratch: opencode's DB, caches and every session dir go with the run.31export HOME=/scratch/home32export WORK_DIR=/scratch/work33mkdir -p "$HOME" "$WORK_DIR/sessions"34# Packages opencode installs on first start, warmed at build time (at run time there is no35# network unless the run is granted some).36cp -rn /opt/opencode-capsule/. "$HOME/"3738export OPENCODE_CONFIG=/capsule/opencode.json39# opencode is a Bun binary; its provider is the local vLLM on 127.0.0.1 (NO_PROXY), so nothing40# goes through the m64 gate unless the agent's own tools reach out (and the run allows it).41# Run from $WORK_DIR: the web UI's (and `opencode attach`'s) project is the run's scratch42# workspace. The gateway still gives each of its sessions a directory under sessions/.43cd "$WORK_DIR"44opencode serve --hostname 0.0.0.0 --port 4096 --pure &45OPENCODE_PID=$!4647# If opencode dies, take the container down so m64 reports the error. $$ is the gateway48# after the exec below. The gateway never reaps opencode, so a dead opencode lingers as a49# zombie (state Z): test the state, not just whether the pid exists.50alive() { [ -r "/proc/$1/stat" ] && [ "$(cut -d')' -f2 "/proc/$1/stat" | cut -d' ' -f2)" != Z ]; }51( while alive "$OPENCODE_PID" && alive "$VLLM_PID"; do sleep 5; done52 echo '{"phase":"error","detail":"opencode or vLLM exited"}' >> "$M64_STATUS"53 kill -TERM $$ ) &5455exec python3 /capsule/agent_gateway.py