Skip to content

Commit 8517f5b

Browse files
committed
Add WebAssembly support with feature flags and conditional compilation, upgrade version to 0.5.0
- Add native and wasm feature flags to machi/Cargo.toml: native (default) enables tokio/full for native platforms, wasm enables getrandom/wasm_js, chrono/wasmbind, and uuid/js for WebAssembly - Configure workspace dependencies for WASM compatibility: disable default features for chrono and tokio, add explicit feature selections - Add getrandom dependency as optional workspace dependency for WASM random
1 parent 3a6f5dd commit 8517f5b

File tree

13 files changed

+239
-16
lines changed

13 files changed

+239
-16
lines changed

Cargo.lock

Lines changed: 196 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ default-members = ["machi"]
44
resolver = "3"
55

66
[workspace.package]
7-
version = "0.4.7"
7+
version = "0.5.0"
88
edition = "2024"
99
license = "MIT OR Apache-2.0"
1010
repository = "https://github.com/pyroth/machi"
1111

1212
[workspace.dependencies]
13-
machi = { version = "0.4.7", path = "machi" }
14-
machi-derive = { version = "0.4.7", path = "machi-derive" }
13+
machi = { version = "0.5.0", path = "machi" }
14+
machi-derive = { version = "0.5.0", path = "machi-derive" }
1515

1616
anyhow = "1.0"
1717
async-trait = "0.1"
@@ -21,7 +21,7 @@ proc-macro2 = "1.0"
2121
quote = "1.0"
2222
syn = { version = "2.0", features = ["full", "extra-traits", "parsing"] }
2323
bytes = "1.10"
24-
chrono = { version = "0.4", features = ["serde"] }
24+
chrono = { version = "0.4", default-features = false, features = ["serde", "std", "clock"] }
2525
convert_case = "0.11.0"
2626
futures = "0.3"
2727
regex = "1.11"
@@ -34,12 +34,13 @@ serde_yaml = "0.9"
3434
minijinja = { version = "2.6", features = ["loader"] }
3535
async-stream = "0.3"
3636
thiserror = "2.0"
37-
tokio = { version = "1.44", features = ["full"] }
37+
tokio = { version = "1.44", default-features = false, features = ["sync"] }
3838
tokio-test = "0.4"
3939
tracing = "0.1"
4040
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
4141
urlencoding = "2.1"
4242
uuid = { version = "1.16", features = ["v4", "serde"] }
43+
getrandom = "0.4.1"
4344
html-escape = "0.2"
4445

4546

machi/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ repository.workspace = true
77
description = "A Rust implementation of smolagents - lightweight AI agents framework"
88

99
[features]
10-
default = ["mcp", "toolkit", "derive"]
10+
default = ["mcp", "toolkit", "derive", "native"]
1111
mcp = ["dep:rmcp"]
1212
toolkit = ["dep:scraper"]
1313
derive = ["dep:machi-derive"]
14+
# Native platform support (tokio runtime, file system, etc.)
15+
native = ["tokio/full"]
16+
# WebAssembly support
17+
wasm = ["getrandom/wasm_js", "chrono/wasmbind", "uuid/js"]
1418

1519
[dependencies]
1620
anyhow.workspace = true
@@ -32,6 +36,7 @@ minijinja.workspace = true
3236
async-stream.workspace = true
3337
thiserror.workspace = true
3438
tokio.workspace = true
39+
getrandom = { workspace = true, optional = true }
3540
tracing.workspace = true
3641
urlencoding.workspace = true
3742
uuid.workspace = true

machi/src/managed/tool_wrapper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
use std::sync::Arc;
77

88
use async_trait::async_trait;
9+
use futures::lock::Mutex;
910
use serde_json::Value;
10-
use tokio::sync::Mutex;
1111

1212
use crate::tool::{DynTool, ToolDefinition, ToolError};
1313

0 commit comments

Comments
 (0)