#!/bin/sh # Full Sandbox workstation setup: binaries, cross-agent skill, and detected MCP CLIs. set -eu umask 077 fail() { printf '%s\n' "sandbox setup: $*" >&2 exit 1 } BASE_URL=${SANDBOX_INSTALL_BASE_URL:-https://tools.yshubham.com} INSTALL_SKILL=${SANDBOX_SETUP_SKILL:-1} CONFIGURE_MCP=${SANDBOX_SETUP_MCP:-${SANDBOX_SETUP_CODEX_MCP:-1}} usage() { printf '%s\n' 'usage: setup.sh [--no-skill] [--no-mcp]' printf '%s\n' ' --no-codex-mcp remains as a deprecated alias for --no-mcp' } while [ "$#" -gt 0 ]; do case "$1" in --no-skill) INSTALL_SKILL=0 ;; --no-mcp|--no-codex-mcp) CONFIGURE_MCP=0 ;; -h|--help) usage; exit 0 ;; *) usage >&2; fail "unknown option: $1" ;; esac shift done case "$INSTALL_SKILL" in 0|1) ;; *) fail "SANDBOX_SETUP_SKILL must be 0 or 1" ;; esac case "$CONFIGURE_MCP" in 0|1) ;; *) fail "SANDBOX_SETUP_MCP must be 0 or 1" ;; esac case "$BASE_URL" in https://*) ;; *) fail "SANDBOX_INSTALL_BASE_URL must use HTTPS" ;; esac command -v curl >/dev/null 2>&1 || fail "missing required command: curl" command -v mktemp >/dev/null 2>&1 || fail "missing required command: mktemp" if [ "$INSTALL_SKILL" = 1 ]; then command -v npx >/dev/null 2>&1 || fail "npx is required for the agent skill; install Node.js or rerun with --no-skill" fi temporary=$(mktemp -d "${TMPDIR:-/tmp}/sandbox-setup.XXXXXX") trap 'rm -rf "$temporary"' EXIT INT TERM curl --fail --location --proto '=https' --proto-redir '=https' --silent --show-error \ --output "$temporary/install.sh" -- "${BASE_URL%/}/sandbox/install.sh" /bin/sh "$temporary/install.sh" /dev/null 2>&1; then detected_mcp_clients=$((detected_mcp_clients + 1)) if codex mcp get sandbox /dev/null 2>&1; then printf '%s\n' "Codex MCP entry 'sandbox' already exists; leaving it unchanged" else codex mcp add sandbox -- "$install_dir/sandbox-mcp" /dev/null 2>&1; then detected_mcp_clients=$((detected_mcp_clients + 1)) if claude mcp get sandbox /dev/null 2>&1; then printf '%s\n' "Claude Code MCP entry 'sandbox' already exists; leaving it unchanged" else claude mcp add --scope user --transport stdio sandbox -- "$install_dir/sandbox-mcp" /dev/null 2>&1; then detected_mcp_clients=$((detected_mcp_clients + 1)) gemini_mcp_list=$(gemini mcp list /dev/null || true) case "$gemini_mcp_list" in *sandbox*) printf '%s\n' "Gemini CLI MCP entry 'sandbox' already exists; leaving it unchanged" ;; *) gemini mcp add sandbox "$install_dir/sandbox-mcp" --scope user