"""add_event.py: your turn, add a UX event that makes the agent feel even better.

The agent emits status / tool / citation / token / cost / done events (../solution/events.py). Add a
new one and render it. Good candidates:
  - "thinking" with a token-by-token reasoning preview (careful: do not leak sensitive chain-of-thought)
  - "progress" with a step count, e.g. {"type":"progress","step":2,"of":3}
  - "retry" so the user sees a transient error was recovered (ties to M22)
  - "typing" indicator before the first token, so the gap never feels dead

Steps:
  1. Add a helper to events.py (for example  def progress(step, of): return {...}).
  2. yield it from streaming_agent.chat_stream at the right moment.
  3. Handle it in events.render so the UI shows it.
  4. Run:  python add_event.py
"""

import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "solution"))
import events as E
from streaming_agent import StreamingAgent
from mockmodel import make_mock_client


# TODO 1: define your new event helper, for example:
def progress(step, of):
    return {"type": "progress", "step": step, "of": of}


if __name__ == "__main__":
    # TODO 2 + 3: yield your event from chat_stream and render it; for now, just show the stream.
    agent = StreamingAgent(make_mock_client())
    E.render(agent.chat_stream("Who leads the team that runs billing?"))
    print("\nNow wire your new event into streaming_agent.chat_stream and events.render.")
