"""
Day 1: Minimal Agent Workflow Example
Run:
  python3 -m venv .venv
  source .venv/bin/activate  # Windows: .venv\\Scripts\\activate
  pip install -r requirements.txt
  python day1.py
"""
from typing import List, Dict


def web_search(query: str) -> List[Dict[str, str]]:
    # TODO: replace with real search API
    return [
        {"title": "AI News A", "url": "https://example.com/a", "snippet": "model release and benchmarks"},
        {"title": "AI News B", "url": "https://example.com/b", "snippet": "agent workflow case study"},
        {"title": "AI News C", "url": "https://example.com/c", "snippet": "new tool calling patterns"},
    ]


def summarize(text: str) -> str:
    # TODO: replace with LLM summarize call
    return text[:80] + "..."


def validate(item: Dict[str, str]) -> bool:
    return item.get("url", "").startswith("https://")


def run_daily_briefing(topic: str = "latest AI news") -> List[Dict[str, str]]:
    results = web_search(topic)
    filtered = [r for r in results if validate(r)]
    top3 = filtered[:3]

    report = []
    for item in top3:
        report.append({
            "title": item["title"],
            "summary": summarize(item["snippet"]),
            "url": item["url"],
        })
    return report


if __name__ == "__main__":
    rows = run_daily_briefing()
    print("=== Daily AI Briefing ===")
    for i, row in enumerate(rows, 1):
        print(f"{i}. {row['title']}")
        print(f"   - {row['summary']}")
        print(f"   - {row['url']}\n")
