#!/usr/bin/env bash
set -euo pipefail
# Run from each checkout after starting T3CODE_DEV_SEED=0 vp run dev.
# Usage: bash drive.sh <synthetic-project-folder> [thread-id-for-control]
project_folder=$1
if [ "$#" -eq 1 ]; then
  node apps/server/src/bin.ts project add --base-dir .t3 --title 'Thinking status proof' "$project_folder"
  node apps/server/src/bin.ts thread start --base-dir .t3 --provider claudeAgent --model claude-sonnet-5-5 --option effort=max --title 'Stopped thinking' --json "$project_folder" 'Do not use any tools. Solve this entirely by careful reasoning: enumerate every positive integer triple a <= b <= c with 1/a + 1/b + 1/c = 1/13. Derive finite bounds, enumerate systematically by a and b, and verify every triple exactly. Work through all candidate pairs without code or tools before giving the full list.'
  # Open the returned thread at /<environmentId>/<threadId> in the paired browser.
  # Begin recording, wait for growing reasoning/running/streaming=true, then click Stop generation.
  # Query while streaming and again after Stop:
  sqlite3 -readonly .t3/userdata/statev2.sqlite "select turn_item_id,status,json_extract(payload_json,'$.streaming'),length(json_extract(payload_json,'$.text')),updated_at from orchestration_v2_projection_turn_items where type='reasoning';"
else
  node apps/server/src/bin.ts thread send --base-dir .t3 --wait --json "$2" 'Abandon the previous enumeration. No tools. Derive the sum of the first 100 positive integers and give the numeric answer. Keep your final response to one sentence.'
fi
