"""
Kivot Agents - OpenAI Agents SDK integration for the Kivot platform.

This package provides a drop-in replacement for the official OpenAI Agents Runner.

Standalone mode (no Temporal required):
    from agents import Agent
    from kivot_agents import KivotRunner, BudgetConfig

    agent = Agent(name="Assistant", instructions="You are helpful.")
    result = await KivotRunner.run(agent, input="Hello!")

Durable mode (with Temporal, requires `pip install kivot-agents[durable]`):
    from kivot_agents import KivotRunner, OpenAIAgentsKivotPlugin
    from temporalio import workflow

    plugin = OpenAIAgentsKivotPlugin(...)
    client = await Client.connect("localhost:7233", plugins=[plugin])

    @workflow.defn
    class MyAgent:
        @workflow.run
        async def run(self, prompt: str) -> str:
            agent = Agent(name="Assistant", instructions="You are helpful.")
            result = await KivotRunner.run(agent, input=prompt)
            return result.final_output
"""

from .budget import BudgetConfig
from .client import EventStream, KivotClient
from .errors import (
    KivotAPIError,
    KivotConnectionError,
    KivotError,
    RunNotFoundError,
    StreamError,
)
from .event_types import EventType, StreamEvent
from .runner import KivotRunner
from .types import AgentResult

# Temporal-dependent classes: only available with `pip install kivot-agents[durable]`
try:
    from .overrides import (
        ActivityParameters,
        KivotAgentsConfig,
        TruncationConfig,
        get_kivot_config,
        set_kivot_agent_overrides,
    )
    from .plugin import OpenAIAgentsKivotPlugin
    from .session import KivotSession

    __all__ = [
        "KivotRunner",
        "AgentResult",
        "BudgetConfig",
        "KivotClient",
        "EventStream",
        "StreamEvent",
        "EventType",
        "KivotError",
        "KivotAPIError",
        "KivotConnectionError",
        "RunNotFoundError",
        "StreamError",
        "KivotSession",
        "OpenAIAgentsKivotPlugin",
        "ActivityParameters",
        "KivotAgentsConfig",
        "TruncationConfig",
        "set_kivot_agent_overrides",
        "get_kivot_config",
    ]
except ImportError:
    # Temporal not installed, durable mode unavailable
    __all__ = [
        "KivotRunner",
        "AgentResult",
        "BudgetConfig",
        "KivotClient",
        "EventStream",
        "StreamEvent",
        "EventType",
        "KivotError",
        "KivotAPIError",
        "KivotConnectionError",
        "RunNotFoundError",
        "StreamError",
    ]
