#!/bin/sh # Harbor — the terminal agent for Droplet. # # curl -fsSL https://harbor.tidesi.org/install.sh | sh # # On Apple Silicon (MLX) or Linux with an NVIDIA GPU (CUDA) this sets up everything locally: # Harbor, the Tide engine, the Droplet model (~3 GB), and the engine as a background service, so # afterwards you only run `harbor`. Elsewhere it installs Harbor alone (point it at a Tide server). # # ... | sh -s -- --harbor-only just Harbor (you have a Tide server elsewhere) # ... | sh -s -- --no-service local setup, but start the engine yourself (tide-server serve) # # Everything goes through uv (installed first if missing). Undo the service: tide-server service uninstall set -eu BASE="${HARBOR_DIST:-https://harbor.tidesi.org/dist}" MODEL="${TIDE_MODEL:-droplet-0.3-harbor-slerp}" LOCAL=auto SERVICE="${HARBOR_SERVICE:-1}" for a in "$@"; do case "$a" in --harbor-only) LOCAL=0 ;; --local) LOCAL=1 ;; --no-service) SERVICE=0 ;; esac done E=$(printf '\033') B="$E[1m" D="$E[2m" R="$E[0m" SKY="$E[38;2;125;211;252m" ICE="$E[38;2;224;242;254m" RED="$E[38;2;229;72;77m" WHT="$E[38;2;240;249;255m" SEA="$E[38;2;3;105;161m" SEA2="$E[38;2;56;189;248m" ROCK="$E[38;2;71;85;105m" GLOW="$E[38;2;253;230;138m" say() { printf ' %s~%s %s\n' "$SKY" "$R" "$1"; } note() { printf ' %s%s%s\n' "$D" "$1" "$R"; } die() { printf ' %sx%s %s\n' "$RED" "$R" "$1" >&2; exit 1; } case "$(uname -s)" in Darwin|Linux) ;; *) die "Harbor runs on macOS and Linux." ;; esac # --- intro: a lighthouse whose beam sweeps left to right -------------------------------------- beam() { # beam -> 18 chars of light, brightest next to the lantern n=$2 out="" i=0 while [ $i -lt 18 ]; do d=$i; [ "$1" = l ] && d=$((17 - i)) # distance from the lantern lvl=$((n * 5 - d)) if [ $lvl -ge 13 ]; then c="█"; col="$ICE" elif [ $lvl -ge 9 ]; then c="▓"; col="$SKY" elif [ $lvl -ge 5 ]; then c="▒"; col="$SEA2" elif [ $lvl -ge 1 ]; then c="░"; col="$SEA" else c=" "; col=""; fi out="$out$col$c"; i=$((i + 1)) done printf '%s%s' "$out" "$R" } draw() { # draw printf '%s\n' " ${RED}▄▄▄${R}" printf ' %s %s▐%s█%s▌%s %s\n' "$(beam l "$1")" "$GLOW" "$WHT" "$GLOW" "$R" "$(beam r "$2")" printf '%s\n' " ${ROCK}▀▀▀▀▀${R}" printf '%s\n' " ${WHT}███${R}" printf '%s\n' " ${RED}███${R}" printf '%s\n' " ${WHT}█████${R}" printf '%s\n' " ${RED}█████${R}" printf '%s\n' " ${ROCK}▟█████▙${R}" if [ "$3" = 0 ]; then printf ' %s~ ~~ ~~~ ~ ~~ ~~~ %s~ ~~ ~ ~~~ ~ ~~%s\n' "$SEA" "$SEA2" "$R" else printf ' %s ~~ ~ ~~~ ~ ~~ ~ %s~~ ~~~ ~ ~~ ~~~ %s\n' "$SEA" "$SEA2" "$R"; fi } intro() { printf '\n' # left side fades in, swings through the lantern, out to the right set -- "1 0" "2 0" "3 0" "4 0" "4 0" "4 0" "3 1" "2 2" "1 3" "0 4" "0 4" "0 4" "0 3" "0 2" "0 1" "0 0" f=0 for pair in "$@"; do [ $f -gt 0 ] && printf '%s[9A' "$E" draw ${pair% *} ${pair#* } $((f % 2)) sleep 0.11 f=$((f + 1)) done printf '\n %sHarbor%s %sa safe place to run our models · tidesi.org%s\n\n' "$B$ICE" "$R" "$D" "$R" } if [ -t 1 ] && [ -z "${NO_ANIM:-}" ]; then printf '%s[?25l' "$E"; trap 'printf "%s[?25h" "$E"' EXIT INT TERM intro printf '%s[?25h' "$E" fi # --- what to set up ---------------------------------------------------------------------------- extra="" case "$(uname -s)-$(uname -m)" in Darwin-arm64) extra="mlx" ;; Linux-x86_64|Linux-aarch64) command -v nvidia-smi >/dev/null 2>&1 && extra="cuda" ;; esac if [ "$LOCAL" = 1 ] && [ -z "$extra" ]; then die "Running Droplet locally needs Apple Silicon (M1 or newer) or Linux with an NVIDIA GPU." fi if [ "$LOCAL" = auto ]; then if [ -z "$extra" ]; then LOCAL=0 note "This machine can't run Droplet itself (needs Apple Silicon or an NVIDIA GPU): installing Harbor only." elif { exec 3/dev/null; then printf ' %sWhat should I set up?%s\n' "$B" "$R" printf ' %s1%s Harbor + Droplet on this machine %srecommended · ~3 GB · runs offline%s\n' "$SKY" "$R" "$D" "$R" printf ' %s2%s Harbor only %sconnect to a Tide server elsewhere%s\n' "$SKY" "$R" "$D" "$R" printf ' %s›%s ' "$SKY" "$R" read -r ans <&3 || ans="" exec 3<&- case "$ans" in 2*) LOCAL=0 ;; *) LOCAL=1 ;; esac printf '\n' else LOCAL=1 # no terminal to ask (CI, scripts): do the full local setup fi fi if ! command -v uv >/dev/null 2>&1; then say "Installing uv" curl -LsSf https://astral.sh/uv/install.sh | sh >/dev/null 2>&1 || die "Couldn't install uv (https://docs.astral.sh/uv)." PATH="$HOME/.local/bin:$PATH"; export PATH fi latest="$(curl -fsSL "$BASE/latest")" || die "Can't reach $BASE — check your connection." pick() { printf '%s\n' "$latest" | sed -n "s/^$1=//p"; } HARBOR_WHL="$(pick harbor)"; ENGINE_WHL="$(pick engine)" [ -n "$HARBOR_WHL" ] || die "Release index at $BASE/latest is missing the harbor package." say "Installing Harbor" uv tool install -q --force --python 3.13 "tide-harbor @ $BASE/$HARBOR_WHL" >/dev/null uv tool update-shell >/dev/null 2>&1 || true if [ "$LOCAL" = 0 ]; then printf '\n' say "Done. Point Harbor at your Tide server:" note "HARBOR_SERVER= harbor" note "(open a new shell first if the command is not found)" exit 0 fi say "Installing the Tide engine ($extra)" uv tool install -q --force --python 3.12 "tide-engine[$extra] @ $BASE/$ENGINE_WHL" >/dev/null ENGINE_PY="$(uv tool dir)/tide-engine/bin/python" TIDE_SERVER="$(uv tool dir --bin 2>/dev/null || printf '%s' "$HOME/.local/bin")/tide-server" say "Downloading Droplet (~3 GB, once)" "$ENGINE_PY" - "$MODEL" <<'PY' || die "Couldn't download Droplet. Check your connection and rerun the installer." import sys from tide_engine.models import load_registry from tide_engine.model_files import resolve_model_dir resolve_model_dir(load_registry()[sys.argv[1]].weights) PY printf '\n' if [ "$SERVICE" = 1 ]; then say "Starting Droplet in the background (starts again at login)" TIDE_MODELS="$MODEL" "$TIDE_SERVER" service --models "$MODEL" install >/dev/null 2>&1 \ || die "Couldn't set up the background service. Start it yourself: TIDE_MODELS=$MODEL tide-server serve" printf '\n' say "Done. Run: harbor" note "Droplet runs at 127.0.0.1:8000 · stop it: tide-server service uninstall" else say "Done. Start Droplet: TIDE_MODELS=$MODEL tide-server serve" note "then, in a new tab: harbor" fi note "(open a new shell first if the command is not found)"