"""Subprocess protocol double, used only in a disposable test checkout. No model/network.""" import json from pathlib import Path import subprocess import sys import time args = sys.argv[1:] if args[0] == 'exec': prompt = sys.stdin.read() if Path('simulate-interruption').exists(): sys.exit(17) if Path('simulate-timeout').exists(): time.sleep(60) if '--sandbox' not in args or args[args.index('--sandbox') + 1] != 'workspace-write': sys.exit(18) checkpoint = 'work' Path('result.txt').write_text('subprocess worker output', encoding='utf-8') Path('observed-prompt.txt').write_text(prompt, encoding='utf-8') result = dict(outcome='complete', summary='synthetic subprocess', blockers=[], requestedApprovals=[], checkpoint=checkpoint) Path(args[args.index('--output-last-message') + 1]).write_text(json.dumps(result), encoding='utf-8') print(json.dumps(dict(type='thread.started', thread_id='synthetic-thread-id'))) print(json.dumps(dict(type='turn.completed'))) elif args[0] == 'sandbox': # Remove known sandbox switches; execute the real deterministic check in the disposable repo. index = 1 while args[index] in ('-C', '-c'): index += 2 sys.exit(subprocess.run(args[index:], cwd=Path.cwd()).returncode) else: sys.exit(19)