#!/usr/bin/env bash
# Run each checkout with fresh dev state and the real Claude Code 2.1.335 CLI.
# Arguments: checkout, synthetic project directory, thread id (for the send step).
# Configure CLAUDE_CONFIG_DIR/settings.json with the existing hub credentials and
# ANTHROPIC_BASE_URL=http://127.0.0.1:18991. Never upload that settings file.
# Start network.mjs beside an empty file named online; it transparently forwards
# real requests to the hub configured in ~/.claude/settings.json.
# Start each app (retain its terminal):
# T3CODE_DEV_SEED=0 CLAUDE_CONFIG_DIR=<isolated-config> \
# CLAUDE_CODE_MAX_RETRIES=400 CLAUDE_CODE_RETRY_WATCHDOG=1 vp run dev
set -eu
cd "$1"
case "${4:-start}" in
start)
 node apps/server/src/bin.ts project add "$2" --title 'Retry budget proof' --base-dir .t3
 node apps/server/src/bin.ts thread start "$2" 'Reply with just the word hi.' --provider claudeAgent --model claude-haiku-5-5 --title 'Retry budget proof' --base-dir .t3 --json
 ;;
send)
 # After the real online reply, remove the network gate's online file.
 node apps/server/src/bin.ts thread send "$3" 'Reply with just the word ok.' --base-dir .t3 --json
 ;;
show)
 node apps/server/src/bin.ts thread show "$3" --base-dir .t3 --json
 ;;
esac
# Pair a browser using the printed URL, navigate to this thread, hide the sidebar
# and thread details, and record 1280x800/light. Keep offline for >10 minutes.
# Recreate online to restore the genuine upstream connection; observe recovery.
