pub mod accumulator;
pub mod adapters;
pub mod conversation;
pub mod events;
pub mod inspector;
pub mod log_utils;
pub mod project;
pub mod session;
pub mod sharing;
pub mod streaming;
pub mod types;

pub use conversation::{Message, MessageMetadata, MessagePart, MessageRole, MessageStatus};
pub use events::{Event, InspectorSnapshotNode, TurnCompleteTrigger};
pub use inspector::{NodeId, NodeKind, NodeMetadata, NodeState};
pub use session::{
    ConfigOption, ConfigOptionType, ConfigOptionValue, ModelId, ModelInfo, Session,
    SessionMetadata, SessionMode, SessionModeId, SessionModeState, SessionModelState,
    SessionOrigin, SessionOwnership, ToolHandler,
};
pub use types::{
    ContentBlock, Meta, PermissionOption, PermissionOptionKind, PermissionToolCallStatus,
    ProviderMeta, RequestPermissionOutcome, RequestPermissionResponse, SessionUpdate, ToolCall,
    ToolCallContent, ToolCallId, ToolCallInfo, ToolCallLocation, ToolCallStatus, ToolKind,
};
pub use sharing::{SessionShare, ShareId, ShareSummary};
pub use accumulator::{AccumulatedMessage, AccumulatedPart, MessageAccumulator, ToolCallData as AccumulatorToolCallData};

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_public_api_imports() {
        // Test that all types are accessible from the crate root

        // ContentBlock
        let _content = ContentBlock::Text {
            text: "test".to_string(),
        };

        // Meta and ProviderMeta
        let _meta = Meta::default();
        let _provider = ProviderMeta {
            name: "test".to_string(),
            original_ids: None,
            raw_excerpt: None,
        };

        // ToolCall, ToolCallId, ToolCallStatus
        let _tool_call_id: ToolCallId = "call_123".to_string();
        let _status = ToolCallStatus::Pending;
        let _tool_call = ToolCall {
            id: "call_123".to_string(),
            tool_name: "test".to_string(),
            status: ToolCallStatus::Running,
            content: vec![],
            raw_input: None,
            raw_output: None,
            title: None,
            error: None,
            metadata: None,
            origin: None,
        };

        // SessionUpdate
        let _update = SessionUpdate::UserMessageChunk {
            message_id: "msg_123".to_string(),
            content: ContentBlock::Text {
                text: "Hello".to_string(),
            },
            _meta: None,
        };

        // If this compiles, all types are accessible via use dirigent_protocol::{...}
    }

    #[test]
    fn test_session_metadata_types_accessible() {
        // Test that new ACP session metadata types are accessible from crate root

        // ModelId and SessionModeId (type aliases)
        let _model_id: ModelId = "default".to_string();
        let _mode_id: SessionModeId = "plan".to_string();

        // ModelInfo
        let _model_info = ModelInfo {
            model_id: "default".to_string(),
            name: "Default".to_string(),
            description: Some("Main model".to_string()),
        };

        // SessionModelState
        let _model_state = SessionModelState {
            available_models: vec![_model_info],
            current_model_id: "default".to_string(),
        };

        // SessionMode
        let _mode = SessionMode {
            id: "default".to_string(),
            name: "Default".to_string(),
            description: None,
        };

        // SessionModeState
        let _mode_state = SessionModeState {
            current_mode_id: "default".to_string(),
            available_modes: vec![_mode],
        };

        // SessionMetadataReceived event
        let _event = Event::SessionMetadataReceived {
            connector_id: "test".to_string(),
            session_id: "test".to_string(),
            models: Some(_model_state),
            modes: Some(_mode_state),
            config_options: None,
        };
    }

    #[test]
    fn test_permission_types_accessible() {
        // Test that ACP permission types are accessible from crate root

        // PermissionOption and PermissionOptionKind
        let _option = PermissionOption {
            option_id: "allow_1".to_string(),
            name: "Allow once".to_string(),
            kind: PermissionOptionKind::AllowOnce,
        };

        // RequestPermissionResponse and RequestPermissionOutcome
        let _response = RequestPermissionResponse {
            outcome: RequestPermissionOutcome::Selected {
                option_id: "allow_1".to_string(),
            },
        };

        // ToolCallInfo and related types
        let _info = ToolCallInfo {
            tool_call_id: "call_123".to_string(),
            title: "Read file".to_string(),
            kind: Some(ToolKind::Read),
            status: Some(PermissionToolCallStatus::Pending),
            locations: Some(vec![ToolCallLocation {
                path: "/test.txt".to_string(),
                line: Some(10),
            }]),
            raw_input: None,
        };

        // If this compiles, all permission types are accessible
    }

    #[test]
    fn test_session_ownership_types_accessible() {
        // Test that Session Ownership Model types are accessible from crate root

        // SessionOrigin
        let _origin_internal = SessionOrigin::Internal;
        let _origin_external = SessionOrigin::External {
            client_id: "test".to_string(),
            client_capabilities: None,
        };

        // ToolHandler
        let _handler_agent = ToolHandler::Agent;
        let _handler_dirigent = ToolHandler::Dirigent;
        let _handler_forward = ToolHandler::ForwardToClient;

        // SessionOwnership and its constructors
        let _ownership_default = SessionOwnership::default();
        let _ownership_internal = SessionOwnership::internal();
        let _ownership_forwarded =
            SessionOwnership::external_forwarded("client-123".to_string(), None);
        let _ownership_handled = SessionOwnership::external_handled("client-456".to_string(), None);

        // Test helper methods
        assert!(!_ownership_internal.is_external());
        assert!(_ownership_forwarded.is_external());
        assert_eq!(_ownership_internal.client_id(), None);
        assert_eq!(_ownership_forwarded.client_id(), Some("client-123"));

        // If this compiles, all ownership types are accessible
    }
}
