#!/usr/bin/env bash
set -euo pipefail
# Run from the checkout being tested, with its dev server already running on a fresh T3 home.
# Usage: bash driver.sh <project-directory> <wrapper-executable>
project=$1
wrapper=$2
mkdir -p "$project"
git -C "$project" init --quiet
node apps/server/src/bin.ts project add "$project" --base-dir .t3 --title 'Hermes proof'
python3 - "$wrapper" <<'PY'
import json,pathlib,sys
p=pathlib.Path('.t3/userdata/settings.json')
s=json.loads(p.read_text())
s.setdefault('providerInstances',{})['hermes_wrapper']={'driver':'acpRegistry','displayName':'Hermes wrapper','enabled':True,'config':{'source':'local','commandPath':sys.argv[1],'commandArgs':[]}}
p.write_text(json.dumps(s))
PY
# Wait for the app's provider status to refresh before starting the turn.
node apps/server/src/bin.ts thread start "$project" 'Use terminal with background=true and notify_on_complete=true to run python3 -c "import time; time.sleep(30); print(\"DONE\")". Immediately reply "Started it in the background." and end your turn without polling or waiting. When the completion notification arrives, reply "The background command printed DONE." in this same thread.' --base-dir .t3 --provider hermes_wrapper --model default --title 'Hermes background reply' --json
# Open /<environmentId>/<threadId> in the paired browser and record the completion interval.
# The environmentId comes from /.well-known/t3/environment; threadId is printed above.
