#!/bin/sh # Agent Session Pilot, server mode (Linux): Telegram, RAM and disk watch, # and the workshop in tmux for your coding agent sessions. # # Read it before you run it: # curl -fsSL https://asp.charlon.dev/install.sh -o install.sh # less install.sh # sh install.sh # # What it does, and nothing else: # 1. asks GitHub for the latest release and the SHA-256 of its Linux archive; # 2. downloads that archive from GitHub and checks it against the SHA-256; # 3. puts `asp` in ~/.local/bin (no root, no sudo); # 4. starts `asp serve` as a systemd user service (`asp service install`). # Source: https://github.com/CharlonTank/agents-sleep-preventer (MIT). # To remove it: asp service uninstall, then delete ~/.local/bin/asp. set -eu repo="CharlonTank/agents-sleep-preventer" case "$(uname -s)-$(uname -m)" in Linux-x86_64 | Linux-amd64) ;; Darwin-*) echo "On a Mac, install the app instead: brew install --cask charlontank/tap/agents-sleep-preventer" echo "(or the DMG from https://asp.charlon.dev). It includes the same commands." exit 1 ;; *) echo "Not supported yet: $(uname -s) $(uname -m). Linux x86_64 only for now." exit 1 ;; esac release=$(curl -fsSL "https://api.github.com/repos/$repo/releases/latest") version=$(printf '%s\n' "$release" | sed -n 's/.*"tag_name": *"v\([^"]*\)".*/\1/p' | head -n 1) if [ -z "$version" ]; then echo "Could not find the latest release on GitHub." exit 1 fi archive="AgentsSleepPreventer-$version-linux-x86_64.tar.gz" # The archive's "digest" follows its "name" in GitHub's answer. expected=$(printf '%s\n' "$release" \ | sed -n "/\"name\": *\"$archive\"/,/\"digest\"/ s/.*\"digest\": *\"sha256:\([0-9a-f]*\)\".*/\1/p" \ | head -n 1) if [ -z "$expected" ]; then echo "GitHub gave no SHA-256 for $archive: stopping, nothing was installed." exit 1 fi work=$(mktemp -d) trap 'rm -rf "$work"' EXIT echo "Downloading asp $version from GitHub…" curl -fsSL -o "$work/$archive" "https://github.com/$repo/releases/download/v$version/$archive" actual=$(sha256sum "$work/$archive" | cut -d ' ' -f 1) if [ "$actual" != "$expected" ]; then echo "The download doesn't match its SHA-256 (expected $expected, got $actual): stopping, nothing was installed." exit 1 fi echo "SHA-256 checked: $actual" tar -xzf "$work/$archive" -C "$work" asp bin="$HOME/.local/bin" mkdir -p "$bin" install -m 755 "$work/asp" "$bin/asp" case ":$PATH:" in *":$bin:"*) ;; *) echo "Add $bin to your PATH (for example in ~/.profile): export PATH=\"\$HOME/.local/bin:\$PATH\"" ;; esac if command -v systemctl >/dev/null 2>&1; then "$bin/asp" service install || echo "The service didn't start: run asp serve in a tmux window instead." fi command -v tmux >/dev/null 2>&1 || echo "Install tmux for asp workshop (sudo apt install tmux)." command -v ffmpeg >/dev/null 2>&1 || echo "Install ffmpeg to transcribe Telegram voice notes (sudo apt install ffmpeg)." echo echo "Agent Session Pilot (asp $version) is installed. Next, connect your Telegram bot:" echo " asp telegram setup"