From fc653a8a94c0a5c8a39086076cb21aefc20f9b86 Mon Sep 17 00:00:00 2001 From: Seto Elkahfi <1797197+setoelkahfi@users.noreply.github.com> Date: Tue, 10 Nov 2026 13:38:48 +0100 Subject: [PATCH 1/4] Add wasm-friendly seams to ed-agent Introduce MaybeSend and MaybeSync marker traits that are Send/Sync on native targets and blanket-implemented on wasm32, switch the async_trait attributes to ?Send on wasm, and use web_time::Instant so timing works in the browser. Native behavior and public signatures are unchanged. The Platforms section of the crate docs no longer claims the onde stub has different signatures; that was fixed on the onde side. Co-Authored-By: Claude Sonnet 5.5 --- Cargo.lock | 1 + crates/ed-agent/Cargo.toml | 2 ++ crates/ed-agent/src/ed.rs | 3 ++- crates/ed-agent/src/lib.rs | 7 +++++-- crates/ed-agent/src/maybe.rs | 34 ++++++++++++++++++++++++++++++++++ crates/ed-agent/src/session.rs | 10 ++++++---- crates/ed-agent/src/sink.rs | 5 +++-- crates/ed-agent/src/tool.rs | 18 +++++++++++------- 8 files changed, 64 insertions(+), 16 deletions(-) create mode 100644 crates/ed-agent/src/maybe.rs diff --git a/Cargo.lock b/Cargo.lock index fc3becb..7cbce73 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2065,6 +2065,7 @@ dependencies = [ "serde_json", "thiserror 2.0.21", "tokio", + "web-time", ] [[package]] diff --git a/crates/ed-agent/Cargo.toml b/crates/ed-agent/Cargo.toml index e7cf2d5..650e57e 100644 --- a/crates/ed-agent/Cargo.toml +++ b/crates/ed-agent/Cargo.toml @@ -20,6 +20,8 @@ log.workspace = true thiserror.workspace = true tokio.workspace = true futures-core = "0.3" +# std::time::Instant::now() panics on wasm32-unknown-unknown; web-time re-exports std on native. +web-time = "1" [dev-dependencies] tokio = { version = "1", features = ["macros", "rt", "sync"] } diff --git a/crates/ed-agent/src/ed.rs b/crates/ed-agent/src/ed.rs index 1860237..43795ba 100644 --- a/crates/ed-agent/src/ed.rs +++ b/crates/ed-agent/src/ed.rs @@ -4,7 +4,7 @@ use std::collections::{HashMap, HashSet}; use std::future::Future; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; -use std::time::{Duration, Instant}; +use std::time::Duration; use log::{error, info}; use onde::inference::types::{format_duration, ChatMessage}; @@ -12,6 +12,7 @@ use onde::inference::{ ChatEngine, EngineInfo, EngineStatus, GgufModelConfig, InferenceError, SamplingConfig, ToolCallingSupport, ToolDefinition, ToolResult, }; +use web_time::Instant; use crate::{ stream::chunk_error, tool::truncate_output, AgentConfig, AgentError, AgentReply, diff --git a/crates/ed-agent/src/lib.rs b/crates/ed-agent/src/lib.rs index 0a78ec8..b5d5246 100644 --- a/crates/ed-agent/src/lib.rs +++ b/crates/ed-agent/src/lib.rs @@ -24,8 +24,10 @@ //! implementations internally, so this crate compiles on every platform `onde` //! supports (macOS, iOS, tvOS, visionOS, watchOS, Windows, Linux, Android) and //! simply surfaces `onde`'s error where it can't run inference. Outside that -//! list `onde` falls back to a stub whose signatures differ, so Ed does not -//! build there either. +//! list (wasm32, for one) `onde` falls back to a stub engine with the same +//! signatures, whose calls all return an "unsupported" error. Releases of +//! `onde` up to 1.3.5 have a stub that drifted from the real engine, so Ed +//! only builds on those targets against a newer release. //! //! Do not add platform gates here, and be careful about adding them in a host: //! a gate narrower than `onde`'s own support list silently disables chat on a @@ -49,6 +51,7 @@ #![forbid(unsafe_code)] mod ed; +pub mod maybe; mod reply; mod session; mod sink; diff --git a/crates/ed-agent/src/maybe.rs b/crates/ed-agent/src/maybe.rs new file mode 100644 index 0000000..516d367 --- /dev/null +++ b/crates/ed-agent/src/maybe.rs @@ -0,0 +1,34 @@ +//! Thread-safety bounds that relax on `wasm32`. +//! +//! The host-facing seams ([`ToolExecutor`](crate::ToolExecutor), +//! [`ApprovalHandler`](crate::ApprovalHandler), [`EventSink`](crate::EventSink), +//! [`SessionStore`](crate::SessionStore)) must be `Send + Sync` on native +//! targets, where a turn can hop between runtime threads. In a browser the +//! agent lives on one JS thread and its implementations hold `JsValue`s, which +//! are `!Send`. These aliases resolve to exactly `Send` / `Sync` everywhere +//! except `wasm32`, so native signatures are unchanged. It is the same pattern +//! wgpu uses (`WasmNotSend`). +//! +//! Soundness rests on the single-thread guarantee: nothing holding a `JsValue` +//! may be handed to another thread. Do not paper over a `!Send` type with +//! `unsafe impl Send`. + +#[cfg(not(target_arch = "wasm32"))] +pub trait MaybeSend: Send {} +#[cfg(not(target_arch = "wasm32"))] +impl MaybeSend for T {} + +#[cfg(target_arch = "wasm32")] +pub trait MaybeSend {} +#[cfg(target_arch = "wasm32")] +impl MaybeSend for T {} + +#[cfg(not(target_arch = "wasm32"))] +pub trait MaybeSync: Sync {} +#[cfg(not(target_arch = "wasm32"))] +impl MaybeSync for T {} + +#[cfg(target_arch = "wasm32")] +pub trait MaybeSync {} +#[cfg(target_arch = "wasm32")] +impl MaybeSync for T {} diff --git a/crates/ed-agent/src/session.rs b/crates/ed-agent/src/session.rs index a6c1440..2d2906b 100644 --- a/crates/ed-agent/src/session.rs +++ b/crates/ed-agent/src/session.rs @@ -5,7 +5,7 @@ //! and hands the messages to [`Ed::restore_history`](crate::Ed::restore_history) //! when the user switches conversation. -use async_trait::async_trait; +use crate::maybe::{MaybeSend, MaybeSync}; use onde::inference::types::ChatMessage; use serde::{Deserialize, Serialize}; @@ -34,8 +34,9 @@ pub struct SessionError(pub String); /// messages if it does. /// - `delete` of an unknown id succeeds. /// - `list` is ordered most recently updated first. -#[async_trait] -pub trait SessionStore: Send + Sync + 'static { +#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] +pub trait SessionStore: MaybeSend + MaybeSync + 'static { async fn list(&self) -> Result, SessionError>; async fn load(&self, id: &str) -> Result>, SessionError>; async fn save(&self, id: &str, messages: &[ChatMessage]) -> Result<(), SessionError>; @@ -70,7 +71,8 @@ mod tests { } } - #[async_trait] + #[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))] + #[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] impl SessionStore for MemoryStore { async fn list(&self) -> Result, SessionError> { let mut metas: Vec<_> = self diff --git a/crates/ed-agent/src/sink.rs b/crates/ed-agent/src/sink.rs index 4069bdd..ba50881 100644 --- a/crates/ed-agent/src/sink.rs +++ b/crates/ed-agent/src/sink.rs @@ -2,6 +2,7 @@ use onde::inference::EngineStatus; +use crate::maybe::{MaybeSend, MaybeSync}; use crate::{AgentReply, ApprovalRequest, ChatReply, ToolCall, ToolExecutionResult}; /// Receives lifecycle transitions and completed replies. @@ -15,9 +16,9 @@ use crate::{AgentReply, ApprovalRequest, ChatReply, ToolCall, ToolExecutionResul /// /// Both methods are synchronous and should stay cheap — they are called while /// Ed is mid-operation. Hand off to a channel or an event bus rather than -/// blocking. Implementations must be `Send + Sync` because a load or a send +/// blocking. Implementations must be `Send + Sync` (on `wasm32`, where the agent is single-threaded, that relaxes to nothing; see [`maybe`](crate::maybe)) because a load or a send /// may be driven from any task. -pub trait EventSink: Send + Sync + 'static { +pub trait EventSink: MaybeSend + MaybeSync + 'static { /// The engine moved to a new lifecycle state. /// /// `model_name` is the model involved where one is known, and `error` diff --git a/crates/ed-agent/src/tool.rs b/crates/ed-agent/src/tool.rs index 526663b..6d0f135 100644 --- a/crates/ed-agent/src/tool.rs +++ b/crates/ed-agent/src/tool.rs @@ -1,6 +1,6 @@ //! Host-defined tools and the policies that guard them. -use async_trait::async_trait; +use crate::maybe::{MaybeSend, MaybeSync}; use serde::{Deserialize, Serialize}; /// A tool the model may ask the host application to run. @@ -105,20 +105,23 @@ pub enum ApprovalDecision { Deny, } -#[async_trait] -pub trait ToolExecutor: Send + Sync + 'static { +#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] +pub trait ToolExecutor: MaybeSend + MaybeSync + 'static { async fn execute(&self, tool_name: &str, arguments: &str) -> Result; } -#[async_trait] -pub trait ApprovalHandler: Send + Sync + 'static { +#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] +pub trait ApprovalHandler: MaybeSend + MaybeSync + 'static { async fn approve(&self, request: ApprovalRequest) -> ApprovalDecision; } #[derive(Debug, Default)] pub struct RejectingExecutor; -#[async_trait] +#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] impl ToolExecutor for RejectingExecutor { async fn execute(&self, tool_name: &str, _: &str) -> Result { Err(format!("no executor is registered for tool {tool_name:?}")) @@ -128,7 +131,8 @@ impl ToolExecutor for RejectingExecutor { #[derive(Debug, Default)] pub struct DenyApprovals; -#[async_trait] +#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] impl ApprovalHandler for DenyApprovals { async fn approve(&self, _: ApprovalRequest) -> ApprovalDecision { ApprovalDecision::Deny From f54d4fe5b43497d1c7c2b88b61fa21ae537492c3 Mon Sep 17 00:00:00 2001 From: Seto Elkahfi <1797197+setoelkahfi@users.noreply.github.com> Date: Tue, 10 Nov 2026 14:05:17 +0100 Subject: [PATCH 2/4] Relax thread-safety bounds only on wasm32-unknown-unknown target_arch = "wasm32" also matches wasm32-wasip1-threads and Emscripten with pthreads, where the single JS thread premise does not hold and the blanket MaybeSend/MaybeSync impls would let a !Send host type cross threads. Gate the relaxation, and the matching async_trait(?Send) attributes, on wasm32 with target_os = "unknown", the browser target the docs justify. Co-Authored-By: Claude Sonnet 5.5 Co-Authored-By: siGit Code v1.7.6 --- crates/ed-agent/src/maybe.rs | 22 ++++++++++++---------- crates/ed-agent/src/session.rs | 14 ++++++++++---- crates/ed-agent/src/sink.rs | 2 +- crates/ed-agent/src/tool.rs | 28 ++++++++++++++++++++-------- 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/crates/ed-agent/src/maybe.rs b/crates/ed-agent/src/maybe.rs index 516d367..5f427c2 100644 --- a/crates/ed-agent/src/maybe.rs +++ b/crates/ed-agent/src/maybe.rs @@ -1,4 +1,4 @@ -//! Thread-safety bounds that relax on `wasm32`. +//! Thread-safety bounds that relax on browser wasm. //! //! The host-facing seams ([`ToolExecutor`](crate::ToolExecutor), //! [`ApprovalHandler`](crate::ApprovalHandler), [`EventSink`](crate::EventSink), @@ -6,29 +6,31 @@ //! targets, where a turn can hop between runtime threads. In a browser the //! agent lives on one JS thread and its implementations hold `JsValue`s, which //! are `!Send`. These aliases resolve to exactly `Send` / `Sync` everywhere -//! except `wasm32`, so native signatures are unchanged. It is the same pattern +//! except `wasm32-unknown-unknown`, so native signatures are unchanged. Other +//! wasm targets (`wasm32-wasip1-threads`, Emscripten with pthreads) can run +//! threads, so they keep the real bounds. It is the same pattern //! wgpu uses (`WasmNotSend`). //! //! Soundness rests on the single-thread guarantee: nothing holding a `JsValue` //! may be handed to another thread. Do not paper over a `!Send` type with //! `unsafe impl Send`. -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] pub trait MaybeSend: Send {} -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] impl MaybeSend for T {} -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] pub trait MaybeSend {} -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] impl MaybeSend for T {} -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] pub trait MaybeSync: Sync {} -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] impl MaybeSync for T {} -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] pub trait MaybeSync {} -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] impl MaybeSync for T {} diff --git a/crates/ed-agent/src/session.rs b/crates/ed-agent/src/session.rs index 2d2906b..a078ea8 100644 --- a/crates/ed-agent/src/session.rs +++ b/crates/ed-agent/src/session.rs @@ -34,8 +34,11 @@ pub struct SessionError(pub String); /// messages if it does. /// - `delete` of an unknown id succeeds. /// - `list` is ordered most recently updated first. -#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))] -#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] +#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), async_trait::async_trait(?Send))] +#[cfg_attr( + not(all(target_arch = "wasm32", target_os = "unknown")), + async_trait::async_trait +)] pub trait SessionStore: MaybeSend + MaybeSync + 'static { async fn list(&self) -> Result, SessionError>; async fn load(&self, id: &str) -> Result>, SessionError>; @@ -71,8 +74,11 @@ mod tests { } } - #[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))] - #[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] + #[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), async_trait::async_trait(?Send))] + #[cfg_attr( + not(all(target_arch = "wasm32", target_os = "unknown")), + async_trait::async_trait + )] impl SessionStore for MemoryStore { async fn list(&self) -> Result, SessionError> { let mut metas: Vec<_> = self diff --git a/crates/ed-agent/src/sink.rs b/crates/ed-agent/src/sink.rs index ba50881..d5eaa37 100644 --- a/crates/ed-agent/src/sink.rs +++ b/crates/ed-agent/src/sink.rs @@ -16,7 +16,7 @@ use crate::{AgentReply, ApprovalRequest, ChatReply, ToolCall, ToolExecutionResul /// /// Both methods are synchronous and should stay cheap — they are called while /// Ed is mid-operation. Hand off to a channel or an event bus rather than -/// blocking. Implementations must be `Send + Sync` (on `wasm32`, where the agent is single-threaded, that relaxes to nothing; see [`maybe`](crate::maybe)) because a load or a send +/// blocking. Implementations must be `Send + Sync` (on `wasm32-unknown-unknown`, where the agent is single-threaded, that relaxes to nothing; see [`maybe`](crate::maybe)) because a load or a send /// may be driven from any task. pub trait EventSink: MaybeSend + MaybeSync + 'static { /// The engine moved to a new lifecycle state. diff --git a/crates/ed-agent/src/tool.rs b/crates/ed-agent/src/tool.rs index 6d0f135..b4b6f05 100644 --- a/crates/ed-agent/src/tool.rs +++ b/crates/ed-agent/src/tool.rs @@ -105,14 +105,20 @@ pub enum ApprovalDecision { Deny, } -#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))] -#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] +#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), async_trait::async_trait(?Send))] +#[cfg_attr( + not(all(target_arch = "wasm32", target_os = "unknown")), + async_trait::async_trait +)] pub trait ToolExecutor: MaybeSend + MaybeSync + 'static { async fn execute(&self, tool_name: &str, arguments: &str) -> Result; } -#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))] -#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] +#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), async_trait::async_trait(?Send))] +#[cfg_attr( + not(all(target_arch = "wasm32", target_os = "unknown")), + async_trait::async_trait +)] pub trait ApprovalHandler: MaybeSend + MaybeSync + 'static { async fn approve(&self, request: ApprovalRequest) -> ApprovalDecision; } @@ -120,8 +126,11 @@ pub trait ApprovalHandler: MaybeSend + MaybeSync + 'static { #[derive(Debug, Default)] pub struct RejectingExecutor; -#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))] -#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] +#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), async_trait::async_trait(?Send))] +#[cfg_attr( + not(all(target_arch = "wasm32", target_os = "unknown")), + async_trait::async_trait +)] impl ToolExecutor for RejectingExecutor { async fn execute(&self, tool_name: &str, _: &str) -> Result { Err(format!("no executor is registered for tool {tool_name:?}")) @@ -131,8 +140,11 @@ impl ToolExecutor for RejectingExecutor { #[derive(Debug, Default)] pub struct DenyApprovals; -#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))] -#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] +#[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), async_trait::async_trait(?Send))] +#[cfg_attr( + not(all(target_arch = "wasm32", target_os = "unknown")), + async_trait::async_trait +)] impl ApprovalHandler for DenyApprovals { async fn approve(&self, _: ApprovalRequest) -> ApprovalDecision { ApprovalDecision::Deny From 3439e9a7e45e7f4d4b10e28daf119d668427145e Mon Sep 17 00:00:00 2001 From: Seto Elkahfi <1797197+setoelkahfi@users.noreply.github.com> Date: Mon, 16 Nov 2026 11:58:07 +0100 Subject: [PATCH 3/4] ed-agent: require onde 1.4.0 and check wasm32 in CI onde 1.4.0 has a wasm32 stub engine whose signatures match the real engine, so ed-agent builds for wasm32-unknown-unknown against the published crate. Bump the workspace dependency to it and refresh the lockfile (uniffi stays at =0.31.0). Add a check-wasm32 job that runs cargo check and clippy -D warnings for ed-agent on that target, and make the CI status job wait on it. Update the Platforms crate doc to say wasm32-unknown-unknown builds against onde's web target. Co-Authored-By: Claude Sonnet 5.5 Co-Authored-By: siGit Code v1.7.10 Co-Authored-By: OndeCode v1.1.2 --- .github/workflows/ci.yml | 31 +++++++++- Cargo.lock | 112 +++++++++++++++++++++---------------- Cargo.toml | 8 ++- crates/ed-agent/src/lib.rs | 9 ++- 4 files changed, 103 insertions(+), 57 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51076e2..c5be6df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,9 +98,38 @@ jobs: - run: cargo clippy --locked --workspace --all-targets -- -D warnings - run: cargo test --locked --workspace + check-wasm32: + name: Check wasm32 + needs: changes + if: needs.changes.outputs.rust == 'true' + runs-on: ubuntu-latest + defaults: + run: + working-directory: ed + steps: + - uses: actions/checkout@v6 + with: + path: ed + - name: Read Rust toolchain + run: | + rust_toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n 1)" + test -n "$rust_toolchain" + echo "RUST_TOOLCHAIN=$rust_toolchain" >> "$GITHUB_ENV" + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + targets: wasm32-unknown-unknown + components: clippy + - uses: Swatinem/rust-cache@v2 + with: + workspaces: ed + key: wasm32 + - run: cargo check --locked --target wasm32-unknown-unknown -p ed-agent + - run: cargo clippy --locked --target wasm32-unknown-unknown -p ed-agent -- -D warnings + ci: name: CI status - needs: [changes, actionlint, check] + needs: [changes, actionlint, check, check-wasm32] if: always() runs-on: ubuntu-latest steps: diff --git a/Cargo.lock b/Cargo.lock index 7cbce73..a217efd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1725,17 +1725,6 @@ dependencies = [ "serde_core", ] -[[package]] -name = "derive-new" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cdc8d50f426189eef89dac62fabfa0abb27d5cc008f25bf4156a0203325becc" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - [[package]] name = "derive_builder" version = "0.20.2" @@ -4489,6 +4478,16 @@ dependencies = [ "paste", ] +[[package]] +name = "metrics" +version = "0.24.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89550ee9f79e88fef3119de263694973a8adb26c21d75322164fb8c493039fe2" +dependencies = [ + "portable-atomic", + "rapidhash", +] + [[package]] name = "mime" version = "0.3.17" @@ -4511,6 +4510,7 @@ version = "2.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86886cf6dbf4e614b19c9a1eec9775f021869d7eadde0fc73921a81b90c9b4c9" dependencies = [ + "indexmap 2.14.2", "memo-map", "serde", "serde_json", @@ -5154,9 +5154,9 @@ checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] name = "onde" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc87dc77609c5ed63840b263bc548acf50c1a6992a0a0834c032482e3cddc63b" +checksum = "8eb18dc9ca66ea6a7e45e06b2fcc83c1f6b58a705641afe320d563a06dab77be" dependencies = [ "anyhow", "cc", @@ -5226,9 +5226,9 @@ dependencies = [ [[package]] name = "onde-mistralrs" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "689f038ebc5d6d11e4880a24e50d62f91bbf21358b92c9b5cf7bf5e65af232bd" +checksum = "0d9f41269feaffb3e452022f04a9cfb95859ed950889b6c1d010391531847260" dependencies = [ "anyhow", "clap 4.6.7", @@ -5254,9 +5254,9 @@ dependencies = [ [[package]] name = "onde-mistralrs-audio" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71b9a72504697c5b91e1d0448d67883e8d3046ad060200610c0484aef5dfaee5" +checksum = "787f40176eda80bdef527227ba43a7d4dac3287a3d7e28af5b4072b92abee042" dependencies = [ "anyhow", "apodize", @@ -5266,9 +5266,9 @@ dependencies = [ [[package]] name = "onde-mistralrs-code-exec" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4016265a19fa51ad973e99a6746904e432d3140b5c2ca14a41077edc6b8648c2" +checksum = "b3851924d7b5dfceaa8309ada9d04d983a4b6cf8761117145e1a035011e4078f" dependencies = [ "anyhow", "base64 0.22.1", @@ -5286,9 +5286,9 @@ dependencies = [ [[package]] name = "onde-mistralrs-core" -version = "0.9.3" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e9266eb62ceb5a9cf8fb5342e6a9b78e286f47b670762559ee800a5a2db5132" +checksum = "40fc05573a7a15f901856e1b0c6341282693156cffbc05c6dfa9b9d49c0570eb" dependencies = [ "ahash", "akin", @@ -5305,9 +5305,9 @@ dependencies = [ "chrono", "clap 4.6.7", "csv", - "derive-new", "derive_more", "dirs 6.0.0", + "dispatch2", "either", "float8", "futures", @@ -5326,6 +5326,7 @@ dependencies = [ "libc", "llguidance", "lrtable", + "metrics", "mime_guess", "minijinja", "minijinja-contrib", @@ -5337,11 +5338,11 @@ dependencies = [ "onde-mistralrs-audio", "onde-mistralrs-code-exec", "onde-mistralrs-mcp", + "onde-mistralrs-metal-compile", "onde-mistralrs-paged-attn", "onde-mistralrs-quant", "onde-mistralrs-sandbox", "onde-mistralrs-vision", - "onde-tqdm", "openai-harmony", "ordered-float", "parking_lot", @@ -5365,10 +5366,12 @@ dependencies = [ "serde-saphyr", "serde_json", "serde_plain", + "sha2", "statrs", "strum 0.27.2", "symphonia", "sysinfo", + "tempfile", "thiserror 2.0.21", "tokenizers 0.21.4", "tokio", @@ -5377,6 +5380,7 @@ dependencies = [ "toktrie", "toktrie_hf_tokenizers", "toml 0.9.12+spec-1.1.0", + "tqdm", "tracing", "tracing-subscriber", "urlencoding", @@ -5387,9 +5391,9 @@ dependencies = [ [[package]] name = "onde-mistralrs-macros" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e624ab1f0896a07ff437f4c49050c891918c0f01a008113c788b64e5f76c1d9" +checksum = "8dd60c4cb0dc37105b335451643d075af0d293b8203df9bb038e88d83df8e475" dependencies = [ "darling 0.23.0", "proc-macro2", @@ -5399,9 +5403,9 @@ dependencies = [ [[package]] name = "onde-mistralrs-mcp" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8bcb140ed84c4dd2683f1533fc58905f959e7394843bc02a315bfdd3ffcbc25" +checksum = "f5b5bf129c896c975a98575b9752291bb47b38a5bd3170944a8c171cc491af1b" dependencies = [ "anyhow", "async-trait", @@ -5421,9 +5425,9 @@ dependencies = [ [[package]] name = "onde-mistralrs-metal-compile" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44109415be2971d311b403095d3c278443210d0ccc1c383a84ad44da5f5b1abf" +checksum = "02e15b1154394bc9750f69c52b55de0295e6f7d3a3f3151f9ad8d88e066629af" dependencies = [ "candle-metal-kernels", "objc2-metal", @@ -5431,9 +5435,9 @@ dependencies = [ [[package]] name = "onde-mistralrs-paged-attn" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f93c8c04d15ebce014e80675387d269bcead85be063bf9afce8b353d64e61b8" +checksum = "9ba6ae15cc8ce43c949fd038a8df0858e41dca38e4b4b77925aa04e6dc4aee84" dependencies = [ "anyhow", "candle-metal-kernels", @@ -5449,17 +5453,20 @@ dependencies = [ [[package]] name = "onde-mistralrs-quant" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d4ed48af14e3e5ff318a6ea6cefbc1e50ee753f143bd1ae6c0f188c33033d5a" +checksum = "a25f0259f21cf04d86f18b3b0f48b072bcc4a989cadae513ca142ab1ccb0c60a" dependencies = [ + "bytemuck", "byteorder", "candle-metal-kernels", "dispatch2", + "fancy-regex 0.14.0", "float8", "futures", "half", "hf-hub", + "indexmap 2.14.2", "indicatif 0.18.6", "lazy_static", "libc", @@ -5484,9 +5491,9 @@ dependencies = [ [[package]] name = "onde-mistralrs-sandbox" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77845cc6e16e3b1eebed11d3ba6a3a56785f0031421bf46d1deefbe281aaa19e" +checksum = "93b8ba017e502f2b7f2da67ced422ae73a7ea2494759b8c7a8e5fa38b341b3f5" dependencies = [ "anyhow", "itoa", @@ -5502,26 +5509,15 @@ dependencies = [ [[package]] name = "onde-mistralrs-vision" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cdc7ae244c416860838e9cb3ff5cd8ae8acf474f48f2fe15d45bc5491215760" +checksum = "f231953141403eb6a825d6c247dffd7aa2e99b01b7a70d075bb72533c8dc10e8" dependencies = [ "image", "onde-candle-core", "rayon", ] -[[package]] -name = "onde-tqdm" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d96f4fcb4af06959bf9c9b81ace0502e2be2d11d7e037c94f3f7851bde720ea" -dependencies = [ - "anyhow", - "crossterm", - "once_cell", -] - [[package]] name = "onig" version = "6.5.3" @@ -6340,6 +6336,15 @@ dependencies = [ "rand_core 0.10.1", ] +[[package]] +name = "rapidhash" +version = "4.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5da7e78a036ce858e8d55b7e7dc8ba3a88b78350fd2155d3591bbd966b58589e" +dependencies = [ + "rustversion", +] + [[package]] name = "ratatui" version = "0.30.2" @@ -9009,6 +9014,17 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" +[[package]] +name = "tqdm" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a882329b482cea1d2762e9b9ff1ed0f0327a1ec3a9ba7b8e8c4e3635908a4ae5" +dependencies = [ + "anyhow", + "crossterm", + "once_cell", +] + [[package]] name = "tracing" version = "0.1.44" diff --git a/Cargo.toml b/Cargo.toml index 2243b9c..737d364 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,9 +27,11 @@ homepage = "https://ondeinference.com" [workspace.dependencies] # The inference engine Ed wraps, resolved from crates.io like any dependency -# (there is no path override to a sibling checkout). 1.3.2 is the first release -# with ChatEngine::complete, which ed-acp's local provider calls. -onde = { version = "1.3.2" } +# (there is no path override to a sibling checkout). 1.4.0 is the first release +# whose wasm32 stub engine matches the real engine's signatures, so ed-agent +# compiles for wasm32-unknown-unknown. ChatEngine::complete, which ed-acp's +# local provider calls, arrived in 1.3.2. +onde = { version = "1.4.0" } async-trait = "0.1" serde = { version = "1", features = ["derive"] } serde_json = "1" diff --git a/crates/ed-agent/src/lib.rs b/crates/ed-agent/src/lib.rs index b5d5246..f199352 100644 --- a/crates/ed-agent/src/lib.rs +++ b/crates/ed-agent/src/lib.rs @@ -23,11 +23,10 @@ //! Ed has no `cfg(target_os)` gates. `onde` already splits real and fallback //! implementations internally, so this crate compiles on every platform `onde` //! supports (macOS, iOS, tvOS, visionOS, watchOS, Windows, Linux, Android) and -//! simply surfaces `onde`'s error where it can't run inference. Outside that -//! list (wasm32, for one) `onde` falls back to a stub engine with the same -//! signatures, whose calls all return an "unsupported" error. Releases of -//! `onde` up to 1.3.5 have a stub that drifted from the real engine, so Ed -//! only builds on those targets against a newer release. +//! simply surfaces `onde`'s error where it can't run inference. On +//! `wasm32-unknown-unknown` it builds against `onde`'s web target. Other +//! targets outside that list get a stub engine with the same signatures, +//! whose calls all return an "unsupported" error. //! //! Do not add platform gates here, and be careful about adding them in a host: //! a gate narrower than `onde`'s own support list silently disables chat on a From e6d25f3f3330cd0940cf49f0a56afbb7ca7d7b93 Mon Sep 17 00:00:00 2001 From: Seto Elkahfi <1797197+setoelkahfi@users.noreply.github.com> Date: Mon, 16 Nov 2026 12:31:16 +0100 Subject: [PATCH 4/4] ed-agent: verify the wasm32 ?Send test impls in CI Addresses review feedback on #57. The check-wasm32 job ran without --all-targets, so the test module never compiled on wasm32 and the ?Send switches inside it went unchecked. Adding --all-targets exposed that two test impls, CountingExecutor (ToolExecutor) and FixedApproval (ApprovalHandler), still carried a plain async_trait and so kept the Send bound their traits drop on wasm32-unknown-unknown. Give both the same wasm32 cfg_attr switch the production impls use, and run the wasm32 check and clippy with --all-targets so this path stays covered. Co-Authored-By: Claude Opus 4.8 Co-Authored-By: siGit Code v1.7.10 Co-Authored-By: OndeCode v1.1.2 --- .github/workflows/ci.yml | 4 ++-- crates/ed-agent/src/ed.rs | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5be6df..1ff419b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -124,8 +124,8 @@ jobs: with: workspaces: ed key: wasm32 - - run: cargo check --locked --target wasm32-unknown-unknown -p ed-agent - - run: cargo clippy --locked --target wasm32-unknown-unknown -p ed-agent -- -D warnings + - run: cargo check --locked --target wasm32-unknown-unknown -p ed-agent --all-targets + - run: cargo clippy --locked --target wasm32-unknown-unknown -p ed-agent --all-targets -- -D warnings ci: name: CI status diff --git a/crates/ed-agent/src/ed.rs b/crates/ed-agent/src/ed.rs index 43795ba..c1a4b16 100644 --- a/crates/ed-agent/src/ed.rs +++ b/crates/ed-agent/src/ed.rs @@ -654,7 +654,11 @@ mod tests { struct CountingExecutor(AtomicUsize); - #[async_trait::async_trait] + #[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), async_trait::async_trait(?Send))] + #[cfg_attr( + not(all(target_arch = "wasm32", target_os = "unknown")), + async_trait::async_trait + )] impl ToolExecutor for CountingExecutor { async fn execute(&self, tool_name: &str, _: &str) -> Result { self.0.fetch_add(1, Ordering::Relaxed); @@ -664,7 +668,11 @@ mod tests { struct FixedApproval(ApprovalDecision); - #[async_trait::async_trait] + #[cfg_attr(all(target_arch = "wasm32", target_os = "unknown"), async_trait::async_trait(?Send))] + #[cfg_attr( + not(all(target_arch = "wasm32", target_os = "unknown")), + async_trait::async_trait + )] impl ApprovalHandler for FixedApproval { async fn approve(&self, _: ApprovalRequest) -> ApprovalDecision { self.0