43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
"""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)
|
|
legacy = '--sandbox' in args and args[args.index('--sandbox') + 1] == 'workspace-write'
|
|
local = ('default_permissions="jobjakt-local"' in args and 'windows.sandbox="mxc"' in args
|
|
and 'permissions.jobjakt-local.network.enabled=false' in args)
|
|
if not (legacy or local):
|
|
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 index < len(args):
|
|
if args[index] in ('-C','-c','--permission-profile'):
|
|
index += 2
|
|
elif args[index] == '--include-managed-config':
|
|
index += 1
|
|
elif args[index] == '--':
|
|
index += 1
|
|
break
|
|
else:
|
|
break
|
|
sys.exit(subprocess.run(args[index:], cwd=Path.cwd()).returncode)
|
|
else:
|
|
sys.exit(19)
|