#!/usr/bin/env bash
# Run from the commit's checkout, after vp i.
# Start in another terminal: T3CODE_DEV_SEED=0 node scripts/dev-runner.ts dev:server --home-dir "$PROOF_HOME" --no-seed --port "$PROOF_PORT"
set -euo pipefail
: "${PROOF_HOME:?fresh server home}" "${PROOF_WORKSPACE:?empty synthetic git repo}" "${PROOF_ASSETS:?directory containing these uploaded files}"
node apps/server/src/bin.ts project add "$PROOF_WORKSPACE" --title 'Truncation proof' --base-dir "$PROOF_HOME"
launched=$(node apps/server/src/bin.ts thread start "$PROOF_WORKSPACE" - --title 'Truncation proof' --provider devReplay --model multi-turn --json --base-dir "$PROOF_HOME" < "$PROOF_ASSETS/message.txt")
thread_id=$(printf '%s' "$launched" | python3 -c 'import json,sys; print(json.load(sys.stdin)["threadId"])')
cp "$PROOF_ASSETS/read-driver.ts" apps/server/proof-driver.ts
node apps/server/proof-driver.ts "$PROOF_HOME" "$thread_id"
