diff --git a/Cargo.lock b/Cargo.lock index b81d7fc..a356a60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1080,7 +1080,7 @@ dependencies = [ [[package]] name = "amico-core" -version = "1.1.0" +version = "1.2.0" dependencies = [ "anyhow", "chrono", diff --git a/amico-core/Cargo.toml b/amico-core/Cargo.toml index 7a09fe8..b171c68 100644 --- a/amico-core/Cargo.toml +++ b/amico-core/Cargo.toml @@ -1,11 +1,15 @@ [package] name = "amico-core" -version = "1.1.0" +version = "1.2.0" edition = "2024" description = "The core Agent components of the Amico AI Agent Framework" repository = "https://github.com/AIMOverse/amico" license = "MIT OR Apache-2.0" +[features] +default = [] +wasm = ["tokio_with_wasm"] + [dependencies] serde = { workspace = true, features = ["derive"] } thiserror = { workspace = true } @@ -17,8 +21,10 @@ evenio = { workspace = true } # Check: For WASM support, only `sync`, `macros`, `io-util`, `rt` and `time` features are supported tokio = { workspace = true, features = ["rt", "sync"] } -tokio_with_wasm = { workspace = true, features = ["rt", "sync"] } +tokio_with_wasm = { workspace = true, features = ["rt", "sync"], optional = true } [dev-dependencies] tokio = { workspace = true, features = ["rt", "sync", "macros", "time"] } tracing-subscriber = "0.3.19" +# Enable for tests +tokio_with_wasm = { workspace = true, features = ["rt", "sync"] } diff --git a/amico-core/src/agent.rs b/amico-core/src/agent.rs index 7a781b8..de6d513 100644 --- a/amico-core/src/agent.rs +++ b/amico-core/src/agent.rs @@ -1,4 +1,6 @@ use tokio::sync::mpsc::{Receiver, Sender, channel}; + +#[cfg(feature = "wasm")] use tokio_with_wasm::alias as tokio; use crate::{ diff --git a/amico-core/src/traits/event_source.rs b/amico-core/src/traits/event_source.rs index 4d60467..3127b74 100644 --- a/amico-core/src/traits/event_source.rs +++ b/amico-core/src/traits/event_source.rs @@ -1,4 +1,6 @@ use tokio::task::JoinHandle; + +#[cfg(feature = "wasm")] use tokio_with_wasm::alias as tokio; use crate::types::AgentEvent; diff --git a/amico-core/tests/strategy_interaction.rs b/amico-core/tests/strategy_interaction.rs index ce5ede0..08b39d1 100644 --- a/amico-core/tests/strategy_interaction.rs +++ b/amico-core/tests/strategy_interaction.rs @@ -6,6 +6,8 @@ use amico_core::{ types::{AgentEvent, Chat, Interaction}, }; use tokio::{task::JoinHandle, time::sleep}; + +#[cfg(feature = "wasm")] use tokio_with_wasm::alias as tokio; struct InteractionSource; diff --git a/amico-hal/src/os/common/audio/control.rs b/amico-hal/src/os/common/audio/control.rs index 2a464b9..8cc30e7 100644 --- a/amico-hal/src/os/common/audio/control.rs +++ b/amico-hal/src/os/common/audio/control.rs @@ -77,7 +77,7 @@ pub enum AudioRecordingError { // We'll record to a temporary WAV file and then convert it to MP3 after recording pub async fn record_blocking(filepath: &str) -> Result<(), AudioRecordingError> { // Create a temporary WAV file path - let temp_wav_path = format!("{}.temp.wav", filepath); + let temp_wav_path = format!("{filepath}.temp.wav"); // Record to the temporary WAV file record_to_wav(&temp_wav_path)?; @@ -113,7 +113,7 @@ fn record_to_wav(filepath: &str) -> Result<(), AudioRecordingError> { let samples = Arc::new(Mutex::new(Vec::::new())); let samples_clone = Arc::clone(&samples); - let err_fn = |err| eprintln!("Stream error: {}", err); + let err_fn = |err| eprintln!("Stream error: {err}"); let stream = device .build_input_stream(