"""Core observability - events, spans, handlers, and logging.

This module provides the observability infrastructure for the runtime:
- Event types for tracing execution (turns, pathways, nodes, tools, LLM)
- EventEmitter for pub/sub
- Span types for distributed tracing
- Debug and trace handlers
- Logging configuration with context propagation
- VM bridge for pathway observability

Usage:
    from core.observability import EventEmitter, DebugHandler, EventType

    events = EventEmitter()
    events.on_all(DebugHandler(show_timestamps=True))

    # Or configure logging
    from core.observability import configure_logging
    configure_logging()
"""

from core.observability.events import (
    Event,
    # Emitter
    EventEmitter,
    EventHandler,
    # Event types
    EventType,
    LLMRequestEvent,
    LLMResponseEvent,
    NodeCompletedEvent,
    NodeFailedEvent,
    NodeInfo,
    NodeStartedEvent,
    PathwayCompletedEvent,
    PathwayCreatedEvent,
    PathwayStartedEvent,
    StateTransitionEvent,
    ToolCalledEvent,
    ToolCompletedEvent,
    ToolFailedEvent,
    TurnCompletedEvent,
    TurnFailedEvent,
    TurnStartedEvent,
)
from core.observability.handlers import (
    Colors,
    DebugHandler,
    GraphTraceLogger,
    JsonLineHandler,
)
from core.observability.logging import (
    configure_logging,
    pop_trace_depth,
    push_trace_depth,
    reset_log_agent_id,
    reset_log_execution_id,
    reset_log_pathway_id,
    reset_log_request_id,
    reset_log_thread_id,
    set_log_agent_id,
    set_log_execution_id,
    set_log_pathway_id,
    set_log_request_id,
    set_log_thread_id,
)
from core.observability.spans import (
    Span,
    SpanKind,
    SpanStatus,
)
from core.observability.vm_bridge import (
    PathwayVMObservabilityBridge,
    attach_pathway_vm_observability,
)

__all__ = [
    # Handlers
    "Colors",
    "DebugHandler",
    "Event",
    # Emitter
    "EventEmitter",
    "EventHandler",
    # Event types
    "EventType",
    "GraphTraceLogger",
    "JsonLineHandler",
    "LLMRequestEvent",
    "LLMResponseEvent",
    "NodeCompletedEvent",
    "NodeFailedEvent",
    "NodeInfo",
    "NodeStartedEvent",
    "PathwayCompletedEvent",
    "PathwayCreatedEvent",
    "PathwayStartedEvent",
    # VM bridge
    "PathwayVMObservabilityBridge",
    # Spans
    "Span",
    "SpanKind",
    "SpanStatus",
    "StateTransitionEvent",
    "ToolCalledEvent",
    "ToolCompletedEvent",
    "ToolFailedEvent",
    "TurnCompletedEvent",
    "TurnFailedEvent",
    "TurnStartedEvent",
    "attach_pathway_vm_observability",
    "configure_logging",
    "pop_trace_depth",
    "push_trace_depth",
    "reset_log_agent_id",
    "reset_log_execution_id",
    "reset_log_pathway_id",
    "reset_log_request_id",
    "reset_log_thread_id",
    "set_log_agent_id",
    "set_log_execution_id",
    "set_log_pathway_id",
    # Logging
    "set_log_request_id",
    "set_log_thread_id",
]
