PureOne's picture
Release EWECZKA specialist compression research prototype v3.1
297df1b verified
Raw History Blame Contribute Delete
1.6 kB
#!/usr/bin/env python3
"""Offline agent integration example; runs from any working directory."""
from __future__ import annotations
import argparse
import json
import sys
from pathlib import Path
REPOSITORY = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPOSITORY))
import agent_tools
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--fixture", type=Path,
default=REPOSITORY / "fixtures" / "hidden-forks-rank-12.bin")
options = parser.parse_args()
try:
result = agent_tools.assess_file(options.fixture)
result["example"] = {
"name": "bounded one-file assessment",
"repository_resolved_from_script": str(REPOSITORY),
"next_action": "retain exact byte and digest verification when evaluating another file"}
print(json.dumps({"schema_version": agent_tools.SCHEMA_VERSION, "ok": True,
"command": "agent_quickstart",
"packaging_version": agent_tools.PACKAGING_VERSION,
"codec_archive_version": 3, "result": result},
sort_keys=True, allow_nan=False))
return 0
except (OSError, ValueError, RuntimeError, AssertionError) as error:
print(json.dumps({"schema_version": agent_tools.SCHEMA_VERSION, "ok": False,
"command": "agent_quickstart",
"error": {"type": type(error).__name__, "message": str(error)}}))
return 2
if __name__ == "__main__":
sys.exit(main())