//! BlueBubbles iMessage bridge plugin for ElizaOS
//!
//! This plugin provides iMessage integration via the BlueBubbles macOS app and REST API.

pub mod actions;
pub mod client;
pub mod config;
pub mod error;
pub mod providers;
pub mod service;
pub mod types;

pub use client::BlueBubblesClient;
pub use config::BlueBubblesConfig;
pub use error::{BlueBubblesError, Result};
pub use service::BlueBubblesService;
pub use types::*;

use elizaos::Plugin;
use std::sync::Arc;

/// Plugin name constant
pub const BLUEBUBBLES_SERVICE_NAME: &str = "bluebubbles";

/// Creates the BlueBubbles plugin with all components
pub fn create_plugin() -> Plugin {
    let service = Arc::new(BlueBubblesService::new());

    Plugin::new(
        BLUEBUBBLES_SERVICE_NAME,
        "BlueBubbles iMessage bridge plugin for ElizaOS agents",
    )
    .with_action(Arc::new(actions::SendMessageAction::new(service.clone())))
    .with_action(Arc::new(actions::SendReactionAction::new(service.clone())))
    .with_provider(Arc::new(providers::ChatStateProvider::new(service)))
}

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

    #[test]
    fn test_create_plugin() {
        let plugin = create_plugin();
        assert_eq!(plugin.name(), BLUEBUBBLES_SERVICE_NAME);
        assert!(!plugin.description().is_empty());
        assert_eq!(plugin.action_handlers.len(), 2);
        assert_eq!(plugin.provider_handlers.len(), 1);
    }
}
