import subprocess, sys
from pathlib import Path
session, side, output = sys.argv[1:]
out = Path(output)
out.mkdir(parents=True, exist_ok=True)
def run(*args):
    subprocess.run(['agent-device', *args, '--session', session], check=True)
run('record', 'start', str(out / f'{side}-thread-tap.mp4'), '--hide-touches')
try:
    name = 'work&report.pdf' if side == 'base' else '&report.pdf'
    run('press', f'label="{name}, PDF Report"', '--settle')
    subprocess.run([sys.executable, str(Path(__file__).with_name('capture-stable.py')), session, f'{side}-thread-pdf', output], check=True)
finally:
    run('record', 'stop')
