#!/usr/bin/env bash
# netabrowser-cli wrapper for Unix
# Resolves CLI entrypoint relative to this script (skill dir → monorepo root → packages/netabrowser-cli)
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CLI_JS="$SCRIPT_DIR/../../../../netabrowser-cli/dist/bin/main.js"

# Ensure Chromium binary is present (auto-download on first run)
node "$SCRIPT_DIR/ensure-chromium.cjs"

if [ ! -f "$CLI_JS" ]; then
  echo "ERROR: netabrowser-cli not built. Run: pnpm --filter @neta/netabrowser-cli build" >&2
  exit 1
fi
exec node "$CLI_JS" "$@"
