use std::sync::Arc;
use async_trait::async_trait;
#[cfg(not(target_arch = "wasm32"))]
use futures_util::stream::BoxStream;
#[cfg(target_arch = "wasm32")]
use futures_util::stream::LocalBoxStream;
use crate::content::Content;
use crate::error::Result;
use crate::runtime::MaybeSendSync;
use crate::types::{Step, ToolResult};
#[cfg(not(target_arch = "wasm32"))]
pub type StepStream = BoxStream<'static, Result<Step>>;
#[cfg(target_arch = "wasm32")]
pub type StepStream = LocalBoxStream<'static, Result<Step>>;
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
pub trait Connection: MaybeSendSync {
fn is_idle(&self) -> bool;
fn conversation_id(&self) -> &str;
async fn send(&self, content: Content) -> Result<()>;
async fn send_trigger(&self, content: String) -> Result<()>;
async fn send_tool_results(&self, results: Vec<ToolResult>) -> Result<()>;
fn subscribe_steps(&self) -> StepStream;
async fn wait_for_idle(&self) -> Result<()>;
fn cancel_turn(&self) {}
async fn shutdown(&self) -> Result<()>;
}
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
pub trait ConnectionStrategy: MaybeSendSync {
async fn connect(&self) -> Result<Arc<dyn Connection>>;
}