m64_c5ba407b7aba / start.sh
39 lines, 2.2 KBraw
1#!/usr/bin/env bash2# opencode-inkling2mini-iq4nl-strixhalo entrypoint. Runs inside the container; takes no arguments.3# 127.0.0.1:9000 llama-server (llama.cpp 75d911f, Vulkan): Inkling-2-Mini IQ4_NL (ggml-org), f16 KV, CONTEXT ctx (default 262144)4# 0.0.0.0:4096 opencode serve: [runtime.app], opencode's own web UI and API on a second front port5# 0.0.0.0:$M64_PORT agent_gateway.py: the agent.session API6set -eu7export HOME=/scratch/home WORK_DIR=/scratch/work8mkdir -p "$HOME" "$WORK_DIR/sessions" /scratch/cache9export XDG_CACHE_HOME=/scratch/cache10CTX=${CONTEXT:-262144}1112echo '{"phase":"loading","detail":"llama.cpp: loading Inkling-2-Mini"}' >> "$M64_STATUS"13# The engine settings and sampling are pi17-inkling2mini-iq4nl-strixhalo's, measured on a Radeon 8060S: -ub 2048,14# f16 KV (q8_0 is no faster at 32K depth and 64 GiB holds f16 at 262144), weights offloaded whole, and the GGUF's own15# sampling defaults (greedy decoding sent Inkling into a degenerate loop).16/opt/llama/bin/llama-server \17 -m /weights/inkling/Inkling-2-Mini-IQ4_NL.gguf \18 --mmproj /weights/inkling/mmproj-Inkling-2-Mini-BF16.gguf \19 -c "$CTX" -np 1 -ngl 999 -fa on -b 2048 -ub 2048 -lm none --jinja --no-ui --metrics \20 --alias inkling-2-mini-iq4_nl --host 127.0.0.1 --port 9000 &21LLM_PID=$!22export AGENT_PROVIDER=local-llamacpp AGENT_MODEL=inkling-2-mini-iq4_nl2324# Packages opencode installs on first start, warmed at build time (no network at run time unless granted).25cp -rn /opt/opencode-capsule/. "$HOME/"26export OPENCODE_CONFIG=/capsule/opencode.json27# The provider is llama-server on 127.0.0.1: nothing goes through the m64 gate unless the agent's own tools reach out.28cd "$WORK_DIR"29opencode serve --hostname 0.0.0.0 --port 4096 --pure &30OPENCODE_PID=$!3132# If opencode or llama-server dies, take the container down so m64 reports the error. A dead child lingers as a33# zombie (state Z): test the state, not just whether the pid exists.34alive() { [ -r "/proc/$1/stat" ] && [ "$(cut -d')' -f2 "/proc/$1/stat" | cut -d' ' -f2)" != Z ]; }35( while alive "$OPENCODE_PID" && alive "$LLM_PID"; do sleep 5; done36 echo '{"phase":"error","detail":"opencode or llama-server exited"}' >> "$M64_STATUS"37 kill -TERM $$ ) &3839exec /opt/gateway/bin/python3 /capsule/agent_gateway.py