#!/usr/bin/env bash
set -euo pipefail
# Run from either checkout after starting its fresh T3 server with T3CODE_DEV_SEED=0.
# Prerequisite: Pi 1.6.0 and npm:pi-subagents@0.89.1 in an isolated
# PI_CODING_AGENT_DIR, and an enabled Pi provider instance named pi.
# Coordinator: dated Haiku 4.5. Children: undated alias rejected by the test hub.
# This uses real Pi RPC and native pi-subagents, never ACP replay or T3 delegation.
workspace="$1"
t3_home="$2"
prompt_file="$(dirname "$0")/prompt.txt"
node apps/server/src/bin.ts project add "$workspace" --base-dir "$t3_home"
node apps/server/src/bin.ts thread start "$workspace" - \
 --title 'Pi async race capture' --provider pi \
 --model anthropic/claude-haiku-4-5-20251001 \
 --base-dir "$t3_home" --json < "$prompt_file"
# Open the returned thread in the web client; let native completion notices finish.
# Expand Worked for... if present, then the 6 subagents group.
# Base intermittently retains Running rows and Waiting on N subagents.
# Head records all six Failed rows and clears the waiting banner.
