"""Pre-TTS output processors: pronunciation fixes and phone-number pacing.

  * ``PhoneticReplacementProcessor`` rewrites hard-to-pronounce names
    (``Siobhan`` → ``shi-vawn``).
  * ``PauseProcessor`` inserts pauses between digits in phone numbers
    using provider-neutral ellipsis cues.

Once running, ask: "What's Siobhan's number?"

Setup: export OPENAI_API_KEY=...; uv sync --extra quickstart --group dev
       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/output_processors.py
       uv run --env-file .env python examples/output_processors.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, PauseProcessor, PhoneticReplacementProcessor, run

# default_pronunciation_processors(name_pronunciations=..., phone_ellipsis_count=1)
# bundles the two below into one call.
run(
    EasyConfig.mic(
        agent=Agent(
            name="assistant",
            instructions=(
                "You are a helpful voice assistant for a fictional contact directory. "
                "When asked about a contact, answer with their full name and a phone "
                "number. Use 'Siobhan Nguyen' at '+1 555 123 4567' as your canned answer."
            ),
        ),
        output_processors=[
            PhoneticReplacementProcessor({"Siobhan": "shi-vawn", "Nguyen": "win"}),
            PauseProcessor(
                pattern=r"\+?\d[\d\s().-]{5,}\d",
                unit_pattern=r"\d",
                minimum_units=7,
            ),
        ],
    )
)
