# Run from either checkout after starting T3CODE_DEV_SEED=0 vp run dev.
# Creates the same synthetic image and invokes the real Claude provider via T3 CLI.
import pathlib,struct,zlib,random,subprocess,sys,sqlite3,json
workspace=pathlib.Path(sys.argv[1]).resolve()
workspace.mkdir(parents=True,exist_ok=True)
r=random.Random(49136)
raw=b''.join(b'\0'+bytes(r.randrange(256) for _ in range(320*3)) for y in range(260))
def chunk(t,d):return struct.pack('>I',len(d))+t+d+struct.pack('>I',zlib.crc32(t+d)&0xffffffff)
(workspace/'sample-read.png').write_bytes(b'\x89PNG\r\n\x1a\n'+chunk(b'IHDR',struct.pack('>IIBBBBB',320,260,8,2,0,0,0))+chunk(b'IDAT',zlib.compress(raw))+chunk(b'IEND',b''))
subprocess.run(['git','init','-q',str(workspace)],check=True)
def cli(*args):subprocess.run(['node','apps/server/src/bin.ts',*args,'--base-dir','.t3'],check=True)
cli('project','add',str(workspace),'--title','image-read-demo')
cli('thread','start',str(workspace),'Use the Read tool on sample-read.png and describe the image in one sentence.','--title','Image Read proof','--provider','claudeAgent','--model','claude-haiku-5-5','--wait','--json')
c=sqlite3.connect('file:.t3/userdata/statev2.sqlite?mode=ro',uri=True)
for (payload,) in c.execute("select payload_json from orchestration_v2_projection_turn_items where json_extract(payload_json,'$.toolName')='Read'"):
 v=json.loads(payload);s=v['output']['content'][0]['source']
 print(json.dumps({'projectionBytes':len(payload.encode()),'contentBase64Characters':len(s.get('data','')),'sizeBytes':s.get('sizeBytes'),'hasViewedImagePath':bool(v.get('viewedImagePath'))}))
# Browser: open returned thread directly; click Worked for, Read 1 file,
# then the role=button with aria-label='Read demo-ws/sample-read.png'.
# Inspect images inside region[aria-label='Tool calls'], not the separate summary thumbnail.
