#!/usr/bin/env bash set -euo pipefail test -f scripts/e2e/telegram-user-driver.py node_bin="$(command -v node)" corepack_bin="$(command -v corepack)" corepack_root="$(dirname "$(dirname "$(readlink -f "$corepack_bin")")")" uv_bin="$(command -v uv)" recorder_user="$(id -un)" toolchain_build="${RUNNER_TEMP}/mantis-toolchain-build" mkdir -p "$toolchain_build/scripts/e2e" node_modules/.bin/esbuild scripts/e2e/telegram-mantis-lane.ts \ --bundle --platform=node --format=esm --target=node24 \ --outfile="$toolchain_build/scripts/e2e/telegram-mantis-lane.mjs" node_modules/.bin/esbuild scripts/e2e/telegram-bot-api-proxy.ts \ --bundle --platform=node --format=esm --target=node24 \ --outfile="$toolchain_build/scripts/e2e/telegram-bot-api-proxy.mjs" node_modules/.bin/esbuild scripts/e2e/mock-openai-server.mjs \ --bundle --platform=node --format=esm --target=node24 \ --outfile="$toolchain_build/scripts/e2e/mock-openai-server.mjs" node_modules/.bin/esbuild scripts/e2e/telegram-desktop-recorder.ts \ --bundle --platform=node --format=esm --target=node24 \ --outfile="$toolchain_build/scripts/e2e/telegram-desktop-recorder.mjs" cp scripts/windows-cmd-helpers.mjs "$toolchain_build/scripts/windows-cmd-helpers.mjs" sudo groupadd --system mantis-proof sudo usermod -aG mantis-proof "$recorder_user" sudo useradd --system --create-home --home-dir /var/lib/mantis-sut \ --shell /usr/sbin/nologin --gid mantis-proof mantis-sut session_root="/tmp/openclaw-mantis-proof-sessions-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" sudo install -d -m 2770 -o mantis-sut -g mantis-proof "$session_root" sudo setfacl -m "u:${recorder_user}:rwx,u:mantis-sut:rwx" "$session_root" sudo setfacl -d -m "u:${recorder_user}:rwx,u:mantis-sut:rwx" "$session_root" "$node_bin" "$corepack_bin" pnpm --version >/dev/null cat >"${RUNNER_TEMP}/mantis-pnpm" <"${RUNNER_TEMP}/telegram-user-driver" <"${RUNNER_TEMP}/openclaw-telegram-user-driver" <"${RUNNER_TEMP}/telegram-desktop-recorder-exec" <"${RUNNER_TEMP}/openclaw-telegram-desktop-recorder" <"${RUNNER_TEMP}/telegram-mantis-lane" <"${RUNNER_TEMP}/openclaw-telegram-mantis-lane" </dev/null runtime_parent="/tmp/openclaw-mantis-sut-runtime-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" sudo install -d -m 0711 -o root -g root "$runtime_parent" sudo install -d -m 0700 -o root -g root "$runtime_parent/attestations" printf '%s\n' "$runtime_parent" | sudo tee /etc/openclaw-mantis-sut-runtime-root >/dev/null sudo chmod 0444 /etc/openclaw-mantis-sut-worktrees /etc/openclaw-mantis-sut-runtime-root sudo -u mantis-sut /usr/local/lib/mantis-toolchain/telegram-mantis-lane --help >/dev/null