//! Dirigent Core
//!
//! The core functionality of Dirigent:
//! - Setup and manage ACP (Agent-Client Protocol) agents
//! - Connect as ACP client to ACP agents
//! - Manage projects and sessions
//! - Handle file access and terminal operations
//!
//! # Core Runtime Architecture
//!
//! The runtime provides a centralized orchestrator for managing connectors:
//! - `CoreRuntime` - Main runtime that manages connector lifecycle
//! - `CoreHandle` - Cloneable handle to the runtime for easy sharing
//! - `Connector` - Trait for connector implementations
//! - `ConnectorHandle` - Handle to a running connector instance
//!
//! # Quick Start
//!
//! ```no_run
//! use dirigent_core::{CoreRuntime, CoreConfig, CoreHandle};
//!
//! # async fn example() {
//! // Create runtime with default config
//! let runtime = CoreRuntime::new(CoreConfig::default());
//! let handle = CoreHandle::new(runtime);
//!
//! // List connectors
//! let connectors = handle.list_connectors(None).await;
//!
//! // Subscribe to events via the SharingBus
//! let _bus_rx = handle.sharing_bus().subscribe_all().await;
//! # }
//! ```

// Core types module - always available
pub mod types;

// Plugin system types (scaffolding) - always available
pub mod plugins;

// Tool directive and configuration types - always available (WASM-compatible)
pub mod tools;

// Re-export commonly used types (always available for WASM)
pub use types::{
    ConnectorErrorKind, ConnectorId, ConnectorKind, ConnectorState, ConnectorSummary, User, UserId,
    UserProfile,
};

// Server-only modules and exports
#[cfg(feature = "server")]
mod error;
#[cfg(feature = "server")]
mod runtime;

#[cfg(feature = "server")]
pub use error::CoreError;
#[cfg(feature = "server")]
pub use runtime::{CoreHandle, CoreRuntime};

// Re-export Zed agent → ConnectorConfig conversion (used by API)
#[cfg(feature = "server")]
pub use runtime::zed_detection::{refresh_zed_connector_binaries, zed_agent_to_connector_config};

// Configuration module (server-only)
#[cfg(feature = "server")]
pub mod config;

// Connectors module - abstraction layer for agent system connections (server-only)
#[cfg(feature = "server")]
pub mod connectors;

// Vendors module - vendor-specific knowledge (CLI detection, mappings, templates)
#[cfg(feature = "server")]
pub mod vendors;

// ACP module - Agent-Client Protocol implementation (server-only)
#[cfg(feature = "server")]
pub mod acp;

// Re-export configuration types (server-only)
#[cfg(feature = "server")]
pub use config::{
    apply_template, resolve_default_runtime_working_directory, AcpServerConfig, ConnectorConfig,
    CoreConfig, TaskConfig,
};

// Re-export connector abstractions (server-only)
#[cfg(feature = "server")]
pub use connectors::{Connector, ConnectorCommand, ConnectorHandle};

// Re-export connector implementations (server-only)
#[cfg(feature = "server")]
pub use connectors::opencode::{OpenCodeConfig, OpenCodeConnector};

// Re-export acceptor types for incoming connections (server-only)
#[cfg(feature = "server")]
pub use connectors::acceptor::{
    Acceptor, AcceptorError, AcceptorHandle, AcceptorId, AcceptorSummary, AcpAcceptor,
    IncomingSession, SessionRouting,
};

// Re-export gateway connector types (server-only)
#[cfg(feature = "server")]
pub use connectors::gateway::{
    get_transient_commands, merge_with_transient_commands, Command as GatewayCommand,
    CommandResult, ConnectorListCallback, ConnectorSummaryInfo, EchoConfig, GatewayConfig,
    GatewayConnector, GatewaySession, SessionTransferCallback,
};

// Session sharing abstraction (server-only)
#[cfg(feature = "server")]
pub mod sharing;
#[cfg(feature = "server")]
pub use dirigent_protocol::sharing::{SessionShare, ShareId, ShareSummary};

