From cf9ea286f33363f0b03daca946af128f760d5bd4 Mon Sep 17 00:00:00 2001 From: takasaki404 Date: Mon, 21 Jul 2025 20:13:55 +0800 Subject: [PATCH 1/4] feat: `wasm` feature control --- amico-core/Cargo.toml | 5 ++++- amico-core/src/agent.rs | 2 ++ amico-core/src/traits/event_source.rs | 2 ++ amico-core/tests/strategy_interaction.rs | 2 ++ amico-sdk/src/resource.rs | 2 ++ 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/amico-core/Cargo.toml b/amico-core/Cargo.toml index 7a09fe8..2876d84 100644 --- a/amico-core/Cargo.toml +++ b/amico-core/Cargo.toml @@ -6,6 +6,9 @@ description = "The core Agent components of the Amico AI Agent Framework" repository = "https://github.com/AIMOverse/amico" license = "MIT OR Apache-2.0" +[features] +wasm = ["tokio_with_wasm"] + [dependencies] serde = { workspace = true, features = ["derive"] } thiserror = { workspace = true } @@ -17,7 +20,7 @@ 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"] } 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-sdk/src/resource.rs b/amico-sdk/src/resource.rs index c85d56b..0dd9c0f 100644 --- a/amico-sdk/src/resource.rs +++ b/amico-sdk/src/resource.rs @@ -1,6 +1,8 @@ use std::sync::Arc; use tokio::sync::{Mutex, MutexGuard}; + +#[cfg(feature = "wasm")] use tokio_with_wasm::alias as tokio; /// `Resource` represents a globally available resource instance that can be shared among agents. From ddb610d9c973520e0d8b97af44f73f0572122d4b Mon Sep 17 00:00:00 2001 From: takasaki404 Date: Mon, 21 Jul 2025 21:05:48 +0800 Subject: [PATCH 2/4] fix: do not use tokio_with_wasm for `sdk` --- amico-sdk/src/resource.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/amico-sdk/src/resource.rs b/amico-sdk/src/resource.rs index 0dd9c0f..c85d56b 100644 --- a/amico-sdk/src/resource.rs +++ b/amico-sdk/src/resource.rs @@ -1,8 +1,6 @@ use std::sync::Arc; use tokio::sync::{Mutex, MutexGuard}; - -#[cfg(feature = "wasm")] use tokio_with_wasm::alias as tokio; /// `Resource` represents a globally available resource instance that can be shared among agents. From ad83c461be59a88b2e5fa834f3485d2c8f86057c Mon Sep 17 00:00:00 2001 From: takasaki404 Date: Mon, 21 Jul 2025 21:14:17 +0800 Subject: [PATCH 3/4] fix: default features & clippy --- amico-core/Cargo.toml | 3 +++ amico-hal/src/os/common/audio/control.rs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/amico-core/Cargo.toml b/amico-core/Cargo.toml index 2876d84..80b0f5c 100644 --- a/amico-core/Cargo.toml +++ b/amico-core/Cargo.toml @@ -7,6 +7,7 @@ repository = "https://github.com/AIMOverse/amico" license = "MIT OR Apache-2.0" [features] +default = [] wasm = ["tokio_with_wasm"] [dependencies] @@ -25,3 +26,5 @@ 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-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( From 399b53cbdf095ac93da5f9088cb906e1a9a79e00 Mon Sep 17 00:00:00 2001 From: takasaki404 Date: Mon, 21 Jul 2025 21:19:07 +0800 Subject: [PATCH 4/4] chore: publish `amico-core` 1.2.0 --- Cargo.lock | 2 +- amico-core/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 80b0f5c..b171c68 100644 --- a/amico-core/Cargo.toml +++ b/amico-core/Cargo.toml @@ -1,6 +1,6 @@ [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"