#!/usr/bin/env bash
set -euo pipefail

repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
cd "$repo_root/ai/runtime"

if [[ ! -f dist/client.js ]]; then
  ../../node_modules/.bin/tsc -p tsconfig.json >/dev/null
fi

if [[ "${AI_RUNTIME_REQUEST_SH_SUPPRESS_DEPRECATION:-false}" != "true" ]]; then
  printf 'DEPRECATED: ai/runtime/request.sh is compatibility-only; use node ai/runtime/dist/cli.js request|batch instead.\n' >&2
fi

exec node dist/client.js "$@"
