motif64

m64_0e0eeb59993e / start.sh

52 lines, 2.7 KBraw
1#!/usr/bin/env bash2# opencode-inkling2mini-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 Inkling 2 Mini"}' >> "$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: vLLM's DGX Spark recipe for Inkling 2 Mini (as the inkling-2-mini-gb10 capsule), on loopback.13vllm serve /weights/model --host 127.0.0.1 --port 9000 \14    --served-model-name inkling-2-mini \15    --tensor-parallel-size 1 \16    --max-model-len 262144 \17    --gpu-memory-utilization 0.85 \18    --max-num-seqs 4 \19    --reasoning-parser inkling \20    --enable-auto-tool-choice \21    --tool-call-parser inkling \22    --speculative-config '{"method":"dspark","num_speculative_tokens":7,"draft_sample_method":"probabilistic"}' \23    --enable-prefix-caching &24VLLM_PID=$!25export AGENT_PROVIDER=local-vllm AGENT_MODEL=inkling-2-mini2627# HOME is the run's /scratch: opencode's DB, caches and every session dir go with the run.28export HOME=/scratch/home29export WORK_DIR=/scratch/work30mkdir -p "$HOME" "$WORK_DIR/sessions"31# Packages opencode installs on first start, warmed at build time (at run time there is no32# network unless the run is granted some).33cp -rn /opt/opencode-capsule/. "$HOME/"3435export OPENCODE_CONFIG=/capsule/opencode.json36# opencode is a Bun binary; its provider is the local vLLM on 127.0.0.1 (NO_PROXY), so nothing37# goes through the m64 gate unless the agent's own tools reach out (and the run allows it).38# Run from $WORK_DIR: the web UI's (and `opencode attach`'s) project is the run's scratch39# workspace. The gateway still gives each of its sessions a directory under sessions/.40cd "$WORK_DIR"41opencode serve --hostname 0.0.0.0 --port 4096 --pure &42OPENCODE_PID=$!4344# If opencode dies, take the container down so m64 reports the error. $$ is the gateway45# after the exec below. The gateway never reaps opencode, so a dead opencode lingers as a46# zombie (state Z): test the state, not just whether the pid exists.47alive() { [ -r "/proc/$1/stat" ] && [ "$(cut -d')' -f2 "/proc/$1/stat" | cut -d' ' -f2)" != Z ]; }48( while alive "$OPENCODE_PID" && alive "$VLLM_PID"; do sleep 5; done49  echo '{"phase":"error","detail":"opencode or vLLM exited"}' >> "$M64_STATUS"50  kill -TERM $$ ) &5152exec python3 /capsule/agent_gateway.py