edbeeching HF Staff
Restore self-contained Harbor tasks with the evidence directory fix
80833e8 verified Download tasks/agentescape-10-skeleton-2e8147dc/environment/agent/cli.py from HuggingFaceSwarms/AgentEscapeBench: direct link, hf CLI and curl.
- Browser
- Download file 1.83 kB
-
https://huggingface.co/datasets/HuggingFaceSwarms/AgentEscapeBench/resolve/main/tasks/agentescape-10-skeleton-2e8147dc/environment/agent/cli.py
- Command line
-
hf download hf://datasets/HuggingFaceSwarms/AgentEscapeBench/tasks/agentescape-10-skeleton-2e8147dc/environment/agent/cli.py
-
curl -L -o cli.py https://huggingface.co/datasets/HuggingFaceSwarms/AgentEscapeBench/resolve/main/tasks/agentescape-10-skeleton-2e8147dc/environment/agent/cli.py
1.83 kB
| #!/usr/bin/env python3 | |
| """Public agent client; depends only on the Python standard library.""" | |
| import argparse | |
| import json | |
| import os | |
| import sys | |
| import urllib.error | |
| import urllib.request | |
| def main(): | |
| parser = argparse.ArgumentParser(description="Interact with the escape room") | |
| parser.add_argument( | |
| "action", | |
| choices=[ | |
| "observe", | |
| "state", | |
| "investigate", | |
| "tool-call", | |
| "use-item", | |
| "submit-answer", | |
| ], | |
| ) | |
| parser.add_argument("value", nargs="?") | |
| parser.add_argument("--arguments-json", default="{}") | |
| args = parser.parse_args() | |
| base = os.environ.get("ESCAPE_URL", "http://puzzle:8000").rstrip("/") | |
| if args.action in ("observe", "state"): | |
| request = urllib.request.Request( | |
| base + ("/observation" if args.action == "observe" else "/state") | |
| ) | |
| else: | |
| if args.value is None: | |
| parser.error("node ID or answer is required") | |
| payload = {"action": args.action.replace("-", "_")} | |
| if args.action == "submit-answer": | |
| payload["answer"] = args.value | |
| else: | |
| payload["node_id"] = args.value | |
| if args.action in ("tool-call", "use-item"): | |
| payload["arguments"] = json.loads(args.arguments_json) | |
| request = urllib.request.Request( | |
| base + "/action", | |
| data=json.dumps(payload).encode(), | |
| headers={"Content-Type": "application/json"}, | |
| ) | |
| try: | |
| with urllib.request.urlopen(request, timeout=30) as response: | |
| print(json.dumps(json.load(response), ensure_ascii=False)) | |
| except (urllib.error.URLError, ValueError) as exc: | |
| print(json.dumps({"ok": False, "error": str(exc)})) | |
| sys.exit(2) | |
| if __name__ == "__main__": | |
| main() | |