#!/bin/sh set -e BOLD="\033[1m" GREEN="\033[32m" RED="\033[31m" CYAN="\033[36m" DIM="\033[2m" RESET="\033[0m" BINARY_NAME="inspatial" BASE_URL="https://inspati.ai" DOWNLOAD_PREFIX="/download" main() { detect_platform detect_arch resolve_target if [ "$OS" = "windows" ]; then INSTALL_DIR="${HOME:-/tmp}/.local/bin" else INSTALL_DIR="/usr/local/bin" fi INSPATIAL_INSTALL_DIR="${INSPATIAL_INSTALL_DIR:-$INSTALL_DIR}" mkdir -p "$INSPATIAL_INSTALL_DIR" print_banner download verify echo "" printf '%b\n' " ${DIM}──────────────────────────────────────────────────────────────────────────────${RESET}" printf '%b\n' " ${GREEN}✓${RESET} $BINARY_NAME installed to $INSPATIAL_INSTALL_DIR/$BINARY_NAME" echo " Run: inspatial ai --version" setup_path printf '%b\n' " ${DIM}──────────────────────────────────────────────────────────────────────────────${RESET}" echo "" } detect_platform() { OS="$(uname -s)" case "$OS" in Linux*) OS="linux" ;; Darwin*) OS="darwin" ;; MINGW*|MSYS*|CYGWIN*) OS="windows" ;; *) printf '%b\n' "${RED}Error: unsupported platform: $OS${RESET}" exit 1 ;; esac } detect_arch() { ARCH="$(uname -m)" case "$ARCH" in x86_64|amd64) ARCH="x86_64" ;; aarch64|arm64) ARCH="aarch64" ;; *) printf '%b\n' "${RED}Error: unsupported architecture: $ARCH${RESET}" exit 1 ;; esac } resolve_target() { case "$OS-$ARCH" in linux-x86_64) TARGET="inspatial-linux-x64" ;; darwin-aarch64) TARGET="inspatial-darwin-arm64" ;; darwin-x86_64) TARGET="inspatial-darwin-x64" ;; windows-x86_64) TARGET="inspatial.exe" ;; *) printf '%b\n' "${RED}Error: no binary available for $OS-$ARCH${RESET}" printf '%b\n' "${DIM}Build from source: deno task compile:cli${RESET}" exit 1 ;; esac } print_banner() { echo "" printf '%b\n' " ▇▇▇▇▇▇▇▇▇▇ " printf '%b\n' " ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ " printf '%b\n' " ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ " printf '%b\n' " ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ " printf '%b\n' " ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ " printf '%b\n' " ▇▇▇▇▇▇ ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ " printf '%b\n' " ▇▇▇▇▇⣿⣿▇▇▇▇▇ ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ ▇▇▇▇▇▇ " printf '%b\n' " ▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇▇ ▇▇▇▇▇▇▇▇▇▇▇▇▇▇ ▇▇▇▇▇▇▇▇▇▇▇▇ " printf '%b\n' " ▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇▇ ▇▇▇▇▇▇▇▇ ▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿▇▇▇▇ " printf '%b\n' " ▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇▇ ▇▇ ▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇ " printf '%b\n' " ▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇ ▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇ " printf '%b\n' " ▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇▇ ▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇ " printf '%b\n' " ▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇▇ ▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇ " printf '%b\n' " ▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇▇ ▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇ " printf '%b\n' " ▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇▇ ▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇ " printf '%b\n' " ▇▇▇⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇▇ ▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇ " printf '%b\n' " ▇▇▇⣿⣿⣿⣿▇▇▇▇▇ ▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇ " printf '%b\n' " ▇▇▇▇▇▇▇▇ ▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇ " printf '%b\n' " ▇▇▇ ▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇ " printf '%b\n' " ▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇ " printf '%b\n' " ▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇▇ ▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇ " printf '%b\n' " ▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇ ▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇ " printf '%b\n' " ▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇ ▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇ " printf '%b\n' " ▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇ ▇▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇ " printf '%b\n' " ▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇ ▇▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇ " printf '%b\n' " ▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇ ▇▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇ " printf '%b\n' " ▇▇▇▇⣿⣿⣿⣿⣿⣿▇▇▇▇▇▇▇ ▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇ " printf '%b\n' " ▇▇▇▇▇▇▇▇▇▇▇ ▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇▇ " printf '%b\n' " ▇▇▇▇▇ ▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇▇ " printf '%b\n' " ▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇▇ " printf '%b\n' " ▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇▇ " printf '%b\n' " ▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇▇ " printf '%b\n' " ▇▇▇▇▇▇▇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿▇▇▇▇▇▇ " printf '%b\n' " ▇▇▇▇▇▇⣿⣿⣿⣿⣿▇▇▇▇▇▇ " printf '%b\n' " ▇▇▇▇▇▇▇▇▇▇ " echo "" printf '%b\n' " ${DIM}──────────────────────────────────────────────────────────────────────────────${RESET}" printf '%b\n' " ${CYAN}${BOLD}InSpatial AI ${RESET}" printf '%b\n' " ${DIM}The AI toolkit for building multi-agent systems${RESET}" printf '%b\n' " ${DIM}──────────────────────────────────────────────────────────────────────────────${RESET}" echo " Platform: $OS ($ARCH)" echo " Target: $TARGET" echo " Install: $INSPATIAL_INSTALL_DIR/$BINARY_NAME" echo "" } download() { DOWNLOAD_URL="$BASE_URL$DOWNLOAD_PREFIX/$TARGET" printf '%b\n' " ${DIM}Downloading $DOWNLOAD_URL ...${RESET}" if command -v curl > /dev/null 2>&1; then curl -fsSL "$DOWNLOAD_URL" -o "$INSPATIAL_INSTALL_DIR/$BINARY_NAME" elif command -v wget > /dev/null 2>&1; then wget -qO "$INSPATIAL_INSTALL_DIR/$BINARY_NAME" "$DOWNLOAD_URL" else printf '%b\n' "${RED}Error: curl or wget required${RESET}" exit 1 fi chmod +x "$INSPATIAL_INSTALL_DIR/$BINARY_NAME" } verify() { if [ ! -f "$INSPATIAL_INSTALL_DIR/$BINARY_NAME" ]; then printf '%b\n' "${RED}Error: binary not found at $INSPATIAL_INSTALL_DIR/$BINARY_NAME${RESET}" exit 1 fi VERSION="$("$INSPATIAL_INSTALL_DIR/$BINARY_NAME" ai --version 2>/dev/null || echo "")" if [ -z "$VERSION" ]; then printf '%b\n' " ${RED}Warning: could not determine version — binary may be corrupt${RESET}" else echo " Version: $VERSION" fi } setup_path() { if [ "$OS" != "windows" ] && [ "$INSPATIAL_INSTALL_DIR" = "/usr/local/bin" ]; then return fi PATH_FILE="$INSPATIAL_INSTALL_DIR/.inspatial-path" echo "export PATH=\"$INSPATIAL_INSTALL_DIR:\$PATH\"" > "$PATH_FILE" 2>/dev/null || true PATH_ADDED=0 RC_FILE="" case "${SHELL}" in *zsh*) RC_FILE="${HOME}/.zshrc" ;; *) RC_FILE="${HOME}/.bashrc" ;; esac if [ -n "$RC_FILE" ]; then if [ ! -f "$RC_FILE" ]; then echo 'source "'"$PATH_FILE"'"' > "$RC_FILE" 2>/dev/null && PATH_ADDED=1 elif ! grep -q '.inspatial-path' "$RC_FILE" 2>/dev/null; then echo "" >> "$RC_FILE" echo 'source "'"$PATH_FILE"'"' >> "$RC_FILE" PATH_ADDED=1 fi fi echo "" printf '%b\n' " ${DIM}To use in this terminal (run once):${RESET}" printf '%b\n' " ${BOLD} source $PATH_FILE${RESET}" if [ "$PATH_ADDED" = "1" ]; then printf '%b\n' " ${DIM}PATH added to $RC_FILE. New terminals will have $BINARY_NAME on PATH.${RESET}" else printf '%b\n' " ${DIM}To make permanent: echo \"source $PATH_FILE\" >> ~/.bashrc${RESET}" fi } main