from __future__ import annotations

import json
import sys
from pathlib import Path

from cleveragents.actor.config import ActorConfiguration


def main() -> None:
    if len(sys.argv) < 2:
        raise SystemExit("config path required")

    config_path = Path(sys.argv[1])
    try:
        config = ActorConfiguration.from_file(path=config_path)
    except FileNotFoundError:
        print(f"Error: Config file not found at '{config_path}'", file=sys.stderr)
        sys.exit(1)
    payload = {
        "provider": config.provider,
        "model": config.model,
        "unsafe": config.unsafe,
        "graph_keys": sorted(config.graph_descriptor.keys())
        if config.graph_descriptor
        else [],
        "options": config.options,
    }
    print(json.dumps(payload))


if __name__ == "__main__":
    main()
