"""
Cisora SDK quickstart — Python

1. Install:        pip install cisora
2. Get an API key: https://cisora.io/settings/keys
3. Set env var:    export CISORA_API_KEY="cisora_live_..."
4. Run:            python quickstart.py
5. Refresh:        https://cisora.io/agents — you'll see this agent appear
"""

import os
from cisora import Cisora


def main():
    cisora = Cisora(
        api_key=os.environ["CISORA_API_KEY"],
        agent_name="quickstart-agent",
    )

    print("▶︎ Wrapping a mock model call…")
    with cisora.model_call("claude-sonnet-4-5") as call:
        # Replace with a real call: anthropic.messages.create(...)
        call.outputs = {"reply": "Hello from a Cisora-wrapped model call!"}

    print("▶︎ Wrapping a mock tool call…")
    with cisora.tool("send_email", metadata={"recipient": "demo@example.com"}) as call:
        # Replace with a real call: resend.emails.send(...)
        call.outputs = {"id": "msg_123", "queued": True}

    print("▶︎ Asking Cisora for a synchronous policy decision…")
    decision = cisora.check(
        action_type="tool_call",
        tool_name="database_write",
        metadata={"table": "users", "field": "email"},
    )
    print(f"  ↳ decision: {decision['decision']} ({decision.get('reason', 'no reason')})")

    cisora.flush()
    cisora.close()
    print("\n✅ Done. Open https://cisora.io/agents to see 'quickstart-agent' appear.")
    print("   Open https://cisora.io/actions to see all 3 events.")


if __name__ == "__main__":
    main()
