from __future__ import annotations

"""CLI entry point for agentrspy."""

import argparse
import asyncio

from dotenv import load_dotenv

from .config import load_runtime_from_yaml


async def _async_main() -> int:
    parser = argparse.ArgumentParser(description="Run an agentrspy runtime from YAML.")
    parser.add_argument("--config", help="Path to a runtime YAML file")
    parser.add_argument("--input", help="Input prompt to send to the runtime")
    args = parser.parse_args()
    load_dotenv()
    if not args.config or not args.input:
        parser.print_help()
        return 0
    runtime = await load_runtime_from_yaml(args.config)
    output = await runtime.run(args.input)
    print(output.text)
    return 0


def main() -> None:
    raise SystemExit(asyncio.run(_async_main()))


if __name__ == "__main__":
    main()
