Download sample/tasks/hud/set_door.py from zero-trust-physics/zero-trust-physics-sample-group-2: direct link, hf CLI and curl.
- Browser
- Download file 1.58 kB
-
https://huggingface.co/datasets/zero-trust-physics/zero-trust-physics-sample-group-2/resolve/main/sample/tasks/hud/set_door.py
- Command line
-
hf download hf://datasets/zero-trust-physics/zero-trust-physics-sample-group-2/sample/tasks/hud/set_door.py
-
curl -L -o set_door.py https://huggingface.co/datasets/zero-trust-physics/zero-trust-physics-sample-group-2/resolve/main/sample/tasks/hud/set_door.py
1.58 kB
| """Point this HUD export at a keyed door, in your own copy, before you adapt or import it. | |
| python3 set_door.py --url https://YOUR-DOOR/mcp --key-file FILE FILE holds the key we give you at kickoff | |
| In every task it writes environment/.env (read by the proxy's service) and [verifier.env] in task.toml (read by the | |
| grader). The agent's sandbox sees neither: its root is the task image, which holds neither file. The pack ships no key. | |
| Do not commit or share the folder once this has run. Run it again with a new key to replace the old one. | |
| """ | |
| import argparse | |
| import glob | |
| import os | |
| import re | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--url", required=True) | |
| ap.add_argument("--key-file", required=True) | |
| a = ap.parse_args() | |
| key = open(a.key_file).read().strip() | |
| if not re.fullmatch(r"[A-Za-z0-9_.-]+", key) or not re.fullmatch(r"https?://[^\s\"']+", a.url): | |
| raise SystemExit("the key or the URL holds characters a key or a URL does not") | |
| tomls = glob.glob(os.path.join(os.path.dirname(os.path.abspath(__file__)), "tasks", "*", "task.toml")) | |
| for toml in tomls: | |
| with open(os.path.join(os.path.dirname(toml), "environment", ".env"), "w") as f: | |
| f.write("ZTP_VERIFIER_URL=%s\nZTP_API_KEY=%s\n" % (a.url, key)) | |
| text = re.sub(r"\n\[verifier\.env\]\n(?:[^\n]*\n)*?(?=\n\[|\Z)", "\n", open(toml).read()) | |
| text = text.replace("\n[environment]\n", '\n[verifier.env]\nZTP_VERIFIER_URL = "%s"\nZTP_API_KEY = "%s"\n\n[environment]\n' % (a.url, key), 1) | |
| with open(toml, "w") as f: | |
| f.write(text) | |
| print("%d tasks point at %s" % (len(tomls), a.url)) | |