#!/usr/bin/env bash
# Thin launcher for `amico-pasqal`: resolve node, exec the bundled Pasqal connector
# launcher. No logic lives here (mirror of launcher/amico-run). See src/pasqal_cli.ts —
# the secret travels ONLY in the child env the bundle builds; nothing here touches it.
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-pasqal: node >= 20 not found on PATH (install node or fix PATH; see provisioning runbook)" >&2
  exit 64
fi
exec node "$DIR/../dist/amico-pasqal.js" "$@"
