#!/usr/bin/env python3
"""
Basic Agent Status SDK Usage Example

Demonstrates core SDK functionality:
- Initializing the client
- Registering an agent
- Checking agent status
- Running a one-off probe
- Listing all agents
"""

import os
import agent_status

API_KEY = os.environ.get("RORA_API_KEY", "your_api_key_here")

agent_status.init(api_key=API_KEY)

agent = agent_status.register(
    name="My Test Agent",
    endpoint="https://my-agent.example.com/chat",
    description="A test agent for demonstration",
    tags=["test", "demo"],
)
print(f"Registered agent: {agent.agent_id}")

status = agent_status.status(agent.agent_id)
print(f"\nAgent Status:")
print(f"  Verdict: {status.verdict.value}")
print(f"  Uptime (24h): {status.uptime_24h}%")
print(f"  Latency P95: {status.latency_p95} ms")
print(f"  Pass Rate: {status.pass_rate}")

result = agent_status.run(
    agent_id=agent.agent_id,
    prompt="What can you help me with?",
)
print(f"\nProbe Result:")
print(f"  Run ID: {result.run_id}")
print(f"  Verdict: {result.verdict.value}")
print(f"  Latency: {result.latency_ms} ms")
print(f"  Response: {result.response_preview[:100]}...")

agents = agent_status.list_agents(limit=10)
print(f"\nAll Agents ({len(agents)}):")
for a in agents:
    print(f"  - {a.name} ({a.id}): {a.last_verdict}")
