The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.
#!/bin/sh
# Download one build input. Cargo callers require curl; guest builds also support wget.
set -eu
url=$1
dest=$2
if [ "${3:-}" = curl ] || command -v curl >/dev/null 2>&1; then
set -- curl -fsSL --retry 0 -o - -- "$url"
else
set -- wget -q -t 1 -O - -- "$url"
fi
command -v "$1" >/dev/null || { echo "Missing downloader: $1" >&2; exit 127; }
scratch=$(mktemp -d "$dest.part.XXXXXX")
partial=$scratch/archive
trap 'rm -f "$partial"; rmdir "$scratch"' 0
trap 'exit 1' HUP INT TERM
# Start from the original URL on every attempt, including after a failed redirect.
for delay in 1 2 4 0; do
if "$@" > "$partial"; then
mv -f "$partial" "$dest"
exit 0
else
status=$?
fi
[ "$delay" -gt 0 ] || exit "$status"
printf 'Download of %s failed (exit %s); retrying in %ss\n' "${dest##*/}" "$status" "$delay" >&2
sleep "$delay"
done