"""Smart-turn endpoint detection — finish turns early via ONNX classifier.

By default ``TurnManager`` waits ``end_of_turn_silence_ms`` (0.8 s) of silence
before ending the turn. Smart-turn classifies captured audio with a ~8 MB
Whisper-Tiny ONNX model and ends early when confident.

Setup: export OPENAI_API_KEY=...; uv sync --extra quickstart --group dev  # Smart Turn included
       uv run easycat doctor
       uv run easycat doctor --env-file .env  # if keys live in .env
       uv run easycat doctor --env-file .env --json  # for parseable checks
Run:   uv run python examples/smart_turn_demo.py
       uv run --env-file .env python examples/smart_turn_demo.py  # if keys live in .env
"""

try:
    from agents import Agent  # type: ignore[import-untyped]
except ImportError as exc:
    raise SystemExit(
        "openai-agents is required. For an app, run: "
        "uv add 'easycat[quickstart]'. In this repo, run: uv sync --extra quickstart --group dev"
    ) from exc

from easycat import EasyConfig, SmartTurnConfig, run

run(
    EasyConfig.mic(
        agent=Agent(name="assistant", instructions="You are a helpful voice assistant."),
        smart_turn=SmartTurnConfig(enabled=True, threshold=0.5),
    )
)
