"""
agent_templates.py — Bundled agent template definitions.

Templates are read-only. Installing a template pre-fills the New Agent
modal so the user can review and save it as a normal agent.
"""
from __future__ import annotations

TEMPLATES: list[dict] = [
    {
        "id": "daily-briefing",
        "name": "Daily Briefing",
        "description": "Reads your calendar and weather each morning and sends a summary via Pushover.",
        "category": "productivity",
        "prompt": (
            "Good morning! Please do the following:\n"
            "1. List my calendar events for today using the caldav tool.\n"
            "2. Fetch the weather forecast for my location using the web tool (yr.no or met.no).\n"
            "3. Send me a concise morning briefing via Pushover with today's schedule and weather highlights."
        ),
        "suggested_schedule": "0 7 * * *",
        "suggested_tools": ["caldav", "web", "pushover"],
        "prompt_mode": "system_only",
        "model": "claude-haiku-4-5-20251001",
    },
    {
        "id": "email-monitor",
        "name": "Email Monitor",
        "description": "Checks your inbox for unread emails and sends a summary via Pushover.",
        "category": "productivity",
        "prompt": (
            "Check my inbox for unread emails. Summarise any important or actionable messages "
            "and send me a Pushover notification with a brief digest. If there is nothing important, "
            "send a short 'Inbox clear' notification."
        ),
        "suggested_schedule": "0 */4 * * *",
        "suggested_tools": ["email", "pushover"],
        "prompt_mode": "system_only",
        "model": "claude-haiku-4-5-20251001",
    },
    {
        "id": "brain-capture",
        "name": "Brain Capture (Telegram)",
        "description": "Captures thoughts sent via Telegram into your 2nd Brain. Use as a Telegram trigger agent.",
        "category": "brain",
        "prompt": (
            "The user has sent you a thought or note to capture. "
            "Save it to the 2nd Brain using the brain tool's capture operation. "
            "Confirm with a brief friendly acknowledgement."
        ),
        "suggested_schedule": "",
        "suggested_tools": ["brain"],
        "prompt_mode": "system_only",
        "model": "claude-haiku-4-5-20251001",
    },
    {
        "id": "weekly-digest",
        "name": "Weekly Digest",
        "description": "Every Sunday evening: summarises the week's calendar events and sends a Pushover digest.",
        "category": "productivity",
        "prompt": (
            "It's the end of the week. Please:\n"
            "1. Fetch calendar events from the past 7 days.\n"
            "2. Look ahead at next week's calendar.\n"
            "3. Send a weekly digest via Pushover with highlights from this week and a preview of next week."
        ),
        "suggested_schedule": "0 18 * * 0",
        "suggested_tools": ["caldav", "pushover"],
        "prompt_mode": "system_only",
        "model": "claude-haiku-4-5-20251001",
    },
    {
        "id": "web-researcher",
        "name": "Web Researcher",
        "description": "General-purpose research agent. Give it a topic and it searches the web and reports back.",
        "category": "utility",
        "prompt": (
            "You are a research assistant. The user will give you a topic or question. "
            "Search the web for relevant, up-to-date information and provide a clear, "
            "well-structured summary with sources."
        ),
        "suggested_schedule": "",
        "suggested_tools": ["web"],
        "prompt_mode": "combined",
        "model": "claude-sonnet-5",
    },
    {
        "id": "download-stats",
        "name": "Download Stats Reporter",
        "description": "Fetches release download stats from a Gitea/Forgejo API and emails a report.",
        "category": "utility",
        "prompt": (
            "Fetch release download statistics from your Gitea/Forgejo instance using the bash tool "
            "and the curl command. Compile the results into a clear HTML email showing downloads per "
            "release and total downloads, then send it via email."
        ),
        "suggested_schedule": "0 8 * * 1",
        "suggested_tools": ["bash", "email"],
        "prompt_mode": "system_only",
        "model": "claude-haiku-4-5-20251001",
    },
]

_by_id = {t["id"]: t for t in TEMPLATES}


def list_templates() -> list[dict]:
    return TEMPLATES


def get_template(template_id: str) -> dict | None:
    return _by_id.get(template_id)
