#!/bin/zsh
set -euo pipefail
export PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
STATE_DIR="$HOME/Library/Application Support/r5d"
CONFIG_FILE="$STATE_DIR/executor.json"
if [[ ! -f "$CONFIG_FILE" || -L "$CONFIG_FILE" ]]; then
  print -u2 "This VM needs its installation's private executor configuration at: $CONFIG_FILE"
  print -u2 "Have the installation operator provision the executor and its matching workspace and manager services."
  exit 1
fi
print "Starting configured r5d executor (__WORKER_LABEL__)"
print "Keep this Terminal open while this execution service is in use."
exec r5d-worker executor "$CONFIG_FILE"
