#!/usr/bin/env bash
# Install the tiny local TypeScript runtime on first run, then create an
# E2B sandbox and mount AIMem at /workspace.

set -euo pipefail

SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
cd "${SCRIPT_DIR}"

if [ ! -x node_modules/.bin/tsx ] || [ ! -d node_modules/e2b ]; then
    npm install --no-package-lock
fi

exec npm run sandbox
