#!/usr/bin/env bash
# Thin launcher: resolve node, exec the bundled orchestrator. No logic lives here.
set -euo pipefail
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do                       # resolve symlink chains (node_modules/.bin)
  DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
  SOURCE="$(readlink "$SOURCE")"
  [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
if ! command -v node >/dev/null 2>&1; then
  echo "amico-run: node >= 20 not found on PATH (install node or fix PATH; see provisioning runbook)" >&2
  exit 64
fi
exec node "$DIR/../dist/amico-run.js" "$@"
