"""abp run entrypoint for: {{ ir.name }}"""
# Generated by agent-blueprint — DO NOT EDIT
# This file is regenerated on every `abp run`. Customise main.py instead.

import os
import sys

# Load .env if present
try:
    from dotenv import load_dotenv
    load_dotenv(override=False)
except ImportError:
    pass

from main import run

THREAD_ID = os.environ.get("ABP_THREAD_ID", "{{ thread_id }}")


def _single_shot(user_input: str) -> None:
    response = run(user_input, thread_id=THREAD_ID)
    print(response)


def _interactive() -> None:
    print("{{ ir.name }} — agent ready. Type your message, Ctrl+C or Ctrl+D to exit.\n")
    while True:
        try:
            user_input = input("You: ").strip()
        except (KeyboardInterrupt, EOFError):
            print("\nGoodbye.")
            break
        if not user_input:
            continue
        try:
            response = run(user_input, thread_id=THREAD_ID)
            print(f"Agent: {response}\n")
        except Exception as e:
            print(f"[error] {e}\n", file=sys.stderr)


if __name__ == "__main__":
    if len(sys.argv) > 1:
        _single_shot(" ".join(sys.argv[1:]))
    else:
        _interactive()
