"""Deterministic JSON Schema export for non-Python SDK consumers."""

from __future__ import annotations

from pydantic import TypeAdapter

from .compatibility import CompatibilityAssessment
from .evidence import EvidenceRecord, RawTransportRecord
from .identity import DeviceInstanceRef
from .operations import OperationEvent, OperationPolicy, OperationRequest
from .runtime import (
    RuntimeActionInvocation,
    RuntimeActionResult,
    RuntimeHandshakeRequest,
    RuntimeHandshakeResult,
    RuntimeHealthSnapshot,
    RuntimePluginDescriptor,
)
from .session import DeviceSessionContext, DeviceSessionSnapshot
from .streams import CanonicalStreamEnvelope


def contract_json_schemas() -> dict[str, dict[str, object]]:
    """Return named schemas; callers may persist or serve the resulting bundle."""

    contracts: dict[str, object] = {
        "DeviceInstanceRef": DeviceInstanceRef,
        "DeviceSessionContext": DeviceSessionContext,
        "DeviceSessionSnapshot": DeviceSessionSnapshot,
        "OperationPolicy": OperationPolicy,
        "OperationRequest": OperationRequest,
        "OperationEvent": OperationEvent,
        "RuntimeActionInvocation": RuntimeActionInvocation,
        "RuntimeActionResult": RuntimeActionResult,
        "RuntimePluginDescriptor": RuntimePluginDescriptor,
        "RuntimeHandshakeRequest": RuntimeHandshakeRequest,
        "RuntimeHandshakeResult": RuntimeHandshakeResult,
        "RuntimeHealthSnapshot": RuntimeHealthSnapshot,
        "CanonicalStreamEnvelope": CanonicalStreamEnvelope,
        "EvidenceRecord": EvidenceRecord,
        "RawTransportRecord": RawTransportRecord,
        "CompatibilityAssessment": CompatibilityAssessment,
    }
    return {name: TypeAdapter(contract).json_schema() for name, contract in contracts.items()}
