#!/usr/bin/env bash
# Run from either checkout. All state must belong to this reproduction.
# Provider setup and question submission use the real app UI (see reproduction.md).
set -eu
phase=${1:?Use start or restart or resume}
case "$phase" in
  start)
    : "${GOOGLE_GEMINI_BASE_URL:?Set the available Gemini API endpoint}"
    T3CODE_DEV_SEED=0 vp run dev
    ;;
  restart)
    # The dev watcher terminates the hosting server and launches a new process.
    touch apps/server/src/bin.ts
    ;;
  resume)
    : "${THREAD_ID:?Use the thread id from the app URL}"
    node apps/server/src/bin.ts thread send --base-dir "${T3_DATA_DIR:-.t3}" "$THREAD_ID" 'Leave the earlier question unanswered. Call your native ask_question tool again now. Ask exactly: Second question after restart? Offer choices Gamma and Delta. Do not inspect files or use other tools. Wait for my answer.'
    ;;
  *) exit 2 ;;
esac
