#!/usr/bin/env bash
set -euo pipefail
# Run once in each commit checkout. Supply the same available Codex model privately.
: "${PROOF_MODEL:?Set the available Codex model}"
: "${PROOF_WORKSPACE:?Set an empty synthetic project directory}"
vp i
mkdir -p "$PROOF_WORKSPACE"
git -C "$PROOF_WORKSPACE" init -q
T3CODE_DEV_SEED=0 vp run dev > server-private.log 2>&1 &
server_pid=$!
trap 'kill -INT "$server_pid" 2>/dev/null || true' EXIT
# Wait for the startup pairing URL, then pair the browser with that URL.
read -r -p 'Press Enter once the fresh server is ready and the browser paired.'
node apps/server/src/bin.ts project add --base-dir .t3 --title 'Delegate goal proof' "$PROOF_WORKSPACE"
node apps/server/src/bin.ts thread start --base-dir .t3 --provider codex --model "$PROOF_MODEL" --title 'Delegated word' "$PROOF_WORKSPACE" - <<'PROMPT'
/goal Report the word printed by a delegated child task. Step 1: call the T3 delegate_task tool once (same provider and model as you, no worktree) with the task "Run the shell command `sleep 240 && echo PINEAPPLE` and reply with its output only." Do not wait for it and do not call task_status. Step 2: end your turn immediately; T3 wakes you with the child's result when it completes. When the child completes, report the word and mark the goal complete.
PROMPT
# Open the returned thread in the paired web client (1280x800, light theme).
# Record while the child runs. On base, repeated parent turns consume goal tokens.
# On head, the goal pauses; wait for the child to finish and the parent to report its result.
# Hide model and environment labels before capturing; do not publish server-private.log.
read -r -p 'Press Enter after capturing and stopping the reproduction.'
