comparison mrjunejune/inference_stack.sh @ 282:6bd4a3990696 default tip

Add cross-platform canvas orchestration and typed composer Enable native ARM dependencies, macOS Copilot orchestration, portable service supervision, CPU dictation, and a shared N-key speak-or-type composer. Co-authored-by: Copilot <[email protected]> Copilot-Session: f68442b1-fa8f-46a0-9689-81710613bbd4
author MrJuneJune <me@mrjunejune.com>
date Thu, 20 Aug 2026 20:45:25 -0700
parents 13d61401c57d
children
comparison
equal deleted inserted replaced
281:c57149ad216e 282:6bd4a3990696
1 #!/usr/bin/env bash 1 #!/usr/bin/env bash
2 set -euo pipefail 2 set -euo pipefail
3 3
4 server="$(realpath "$1")" 4 resolve_path() {
5 sidecar_launcher="$(realpath "$2")" 5 local path="$1"
6 sidecar_zip="$(realpath "$3")" 6 local directory
7 copilot_cli="$(realpath "$4")" 7 directory="$(cd "$(dirname "$path")" && pwd -P)"
8 litellm_zip="$(realpath "$5")" 8 printf '%s/%s\n' "$directory" "$(basename "$path")"
9 litellm_config="$(realpath "$6")" 9 }
10 python="$(realpath "$7")" 10
11 server="$(resolve_path "$1")"
12 sidecar_launcher="$(resolve_path "$2")"
13 sidecar_zip="$(resolve_path "$3")"
14 copilot_cli="$(resolve_path "$4")"
15 litellm_zip="$(resolve_path "$5")"
16 litellm_config="$(resolve_path "$6")"
17 python="$(resolve_path "$7")"
11 mock_sidecar="${8:-}" 18 mock_sidecar="${8:-}"
12 if (( $# >= 8 )); then 19 if (( $# >= 8 )); then
13 shift 8 20 shift 8
14 else 21 else
15 shift 7 22 shift 7
39 "/etc/mrjunejune/.config" \ 46 "/etc/mrjunejune/.config" \
40 "${HOME:-}/.config/mrjunejune/.config"; do 47 "${HOME:-}/.config/mrjunejune/.config"; do
41 [[ "$candidate" != /mrjunejune/.config ]] || continue 48 [[ "$candidate" != /mrjunejune/.config ]] || continue
42 [[ "$candidate" != /.config/mrjunejune/.config ]] || continue 49 [[ "$candidate" != /.config/mrjunejune/.config ]] || continue
43 if [[ -f "$candidate" ]]; then 50 if [[ -f "$candidate" ]]; then
44 realpath "$candidate" 51 resolve_path "$candidate"
45 return 0 52 return 0
46 fi 53 fi
47 done 54 done
48 return 1 55 return 1
49 } 56 }
134 fi 141 fi
135 142
136 cleanup() { 143 cleanup() {
137 for pid in "$server_pid" "$litellm_pid"; do 144 for pid in "$server_pid" "$litellm_pid"; do
138 if [[ -n "$pid" ]]; then 145 if [[ -n "$pid" ]]; then
139 kill -- "-$pid" 2>/dev/null || true 146 kill "$pid" 2>/dev/null || true
140 fi 147 fi
141 done 148 done
142 for pid in "$server_pid" "$litellm_pid"; do 149 for pid in "$server_pid" "$litellm_pid"; do
143 [[ -n "$pid" ]] || continue 150 [[ -n "$pid" ]] || continue
144 for _ in $(seq 1 30); do 151 for _ in $(seq 1 30); do
145 if ! kill -0 -- "-$pid" 2>/dev/null; then 152 if ! kill -0 "$pid" 2>/dev/null; then
146 break 153 break
147 fi 154 fi
148 sleep 0.1 155 sleep 0.1
149 done 156 done
150 if kill -0 -- "-$pid" 2>/dev/null; then 157 if kill -0 "$pid" 2>/dev/null; then
151 kill -KILL -- "-$pid" 2>/dev/null || true 158 kill -KILL "$pid" 2>/dev/null || true
152 fi 159 fi
153 wait "$pid" 2>/dev/null || true 160 wait "$pid" 2>/dev/null || true
154 done 161 done
155 } 162 }
156 trap cleanup EXIT INT TERM 163 trap cleanup EXIT INT TERM
204 echo "GitHub Copilot is not authenticated for LiteLLM." >&2 211 echo "GitHub Copilot is not authenticated for LiteLLM." >&2
205 echo "Run: bazel run //mrjunejune:run_inference_stack -- --authenticate" >&2 212 echo "Run: bazel run //mrjunejune:run_inference_stack -- --authenticate" >&2
206 exit 1 213 exit 1
207 fi 214 fi
208 215
209 setsid "$python" "$litellm_zip" \ 216 "$python" "$litellm_zip" \
210 --config "$litellm_config" \ 217 --config "$litellm_config" \
211 --host "$litellm_host" \ 218 --host "$litellm_host" \
212 --port "$litellm_port" & 219 --port "$litellm_port" &
213 litellm_pid=$! 220 litellm_pid=$!
214 221
251 export SERVER_HOST="${SERVER_HOST:-127.0.0.1}" 258 export SERVER_HOST="${SERVER_HOST:-127.0.0.1}"
252 export AUTH_DEV_INSECURE_COOKIE="${AUTH_DEV_INSECURE_COOKIE:-true}" 259 export AUTH_DEV_INSECURE_COOKIE="${AUTH_DEV_INSECURE_COOKIE:-true}"
253 fi 260 fi
254 261
255 export MRJUNEJUNE_CONFIG_PATH="$config_file" 262 export MRJUNEJUNE_CONFIG_PATH="$config_file"
256 setsid "$server" & 263 "$server" &
257 server_pid=$! 264 server_pid=$!
258 while true; do 265 while true; do
259 if ! kill -0 "$server_pid" 2>/dev/null; then 266 if ! kill -0 "$server_pid" 2>/dev/null; then
260 set +e 267 set +e
261 wait "$server_pid" 268 wait "$server_pid"