"""Tetrate Agent Router (TARS) Python SDK.

A thin, idiomatic wrapper over the buf-generated protobuf-python messages
in ``agentrouter_sdk._gen``. The SDK speaks Connect-JSON over HTTP via
:mod:`httpx` -- the same wire protocol Connect-Go and Connect-ES use.

Quickstart::

    import os
    from agentrouter_sdk import Client

    router = Client(base_url=os.environ["AGENTROUTER_BASE_URL"])
    providers = router.catalog.list_providers().providers
    for p in providers:
        print(p.name)

Construct once and reuse; close when done (or use a ``with`` block).
"""

from __future__ import annotations

# Ensure the bundled _gen subtree is importable as top-level
# ``tars.<svc>.v1.<svc>_pb2`` and ``google.api.*``. Without this nudge, a
# consumer who installed agentrouter-sdk from PyPI would have to add the
# vendored proto path to sys.path themselves.
import os
import sys

_GEN_DIR = os.path.join(os.path.dirname(__file__), "_gen")
if _GEN_DIR not in sys.path:
    sys.path.insert(0, _GEN_DIR)

from .client import Client, Endpoints, RetryPolicy  # noqa: E402
from .errors import (  # noqa: E402
    ABORTED,
    ALREADY_EXISTS,
    DEADLINE_EXCEEDED,
    AgentrouterError,
    FailedPreconditionError,
    INVALID_ARGUMENT,
    NOT_FOUND,
    PERMISSION_DENIED,
    RETRYABLE,
    UNAUTHENTICATED,
    UNAVAILABLE,
    UNKNOWN,
)

# Standard environment variable names.
STANDARD_API_KEY_ENV = "AGENTROUTER_API_KEY"
STANDARD_BASE_URL_ENV = "AGENTROUTER_BASE_URL"
STANDARD_SESSION_TOKEN_ENV = "AGENTROUTER_SESSION_TOKEN"

__version__ = "0.1.0"

__all__ = [
    "Client",
    "Endpoints",
    "RetryPolicy",
    "AgentrouterError",
    "FailedPreconditionError",
    "STANDARD_API_KEY_ENV",
    "STANDARD_BASE_URL_ENV",
    "STANDARD_SESSION_TOKEN_ENV",
    "ABORTED",
    "ALREADY_EXISTS",
    "DEADLINE_EXCEEDED",
    "INVALID_ARGUMENT",
    "NOT_FOUND",
    "PERMISSION_DENIED",
    "RETRYABLE",
    "UNAUTHENTICATED",
    "UNAVAILABLE",
    "UNKNOWN",
    "__version__",
]
