#!/bin/zsh set -euo pipefail ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)" CONFIG_PATH="${1:-$ROOT_DIR/local-agent/config.example.json}" NODE_BIN="${BOSS_NODE_BIN:-}" append_path_if_dir() { local candidate="$1" if [[ -d "$candidate" && ":$PATH:" != *":$candidate:"* ]]; then PATH="$candidate:$PATH" fi } # launchd starts with a very small PATH. Keep CLI runtimes discoverable for # Master Codex Node tasks that spawn `codex`, `node`, or Homebrew tools. append_path_if_dir "/Applications/Codex.app/Contents/Resources" append_path_if_dir "$HOME/Applications/Codex.app/Contents/Resources" append_path_if_dir "/opt/homebrew/bin" append_path_if_dir "/opt/homebrew/sbin" append_path_if_dir "/usr/local/bin" append_path_if_dir "$HOME/.local/bin" append_path_if_dir "$HOME/.bun/bin" export PATH if [[ -z "$NODE_BIN" ]]; then NODE_BIN="$(command -v node 2>/dev/null || true)" fi if [[ -z "$NODE_BIN" ]]; then NODE_CANDIDATES=("$HOME"/.boss-runtime/node-*/bin/node(N) /opt/homebrew/bin/node /usr/local/bin/node /usr/bin/node) for candidate in "${NODE_CANDIDATES[@]}"; do if [[ -x "$candidate" ]]; then NODE_BIN="$candidate" break fi done fi if [[ -z "$NODE_BIN" || ! -x "$NODE_BIN" ]]; then echo "Node.js 22 or newer is required. Set BOSS_NODE_BIN or install Node.js." >&2 exit 1 fi cd "$ROOT_DIR" exec "$NODE_BIN" ./local-agent/server.mjs "$CONFIG_PATH"