#!/usr/bin/env python3
"""Run from either checkout with its isolated server running.
Usage: python3 driver.py PROJECT THREAD PHASE
Create PROJECT via `t3 project add`; create THREAD using OpenCode 2,
model openai/gpt-6-luna, with the initial prompt "Reply READY only."
Open the thread in the web client, hide thread details, start recording,
then run phase wait. After it ends, capture Waiting/Running and run clear.
Each side uses a fresh database (T3CODE_DEV_SEED=0), light theme, 1280x800.
"""
import subprocess, sys
project, thread, phase = sys.argv[1:]
prompts = {
"wait": "Start a native background shell running sleep 600 followed by echo VALIDATION_DONE. Use the shell tool background option, not shell ampersand. Then call t3_background_wait with the exact returned shell ID and waiting:true. Do not wait synchronously, poll, or stop the shell. After registration, end your turn with a short report of the tool result. This is an explicit request to end while awaiting background validation.",
"clear": "Call t3_background_wait for the same shell ID with waiting:false now. Leave the shell running: do not stop, poll, or wait on it. End your turn after reporting the result."
}
subprocess.run(["node", "apps/server/src/bin.ts", "thread", "send", "--base-dir", ".t3", thread, prompts[phase], "--json"], check=True)
