Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ pipx = "latest"
"pipx:cmake" = "latest"
protoc = "latest"
rclone = "latest"
ruff = "latest"
rust = { version = "latest", components = "clippy" }
typos = "latest"
uv = "latest"

[tasks]
editorconfig-check = "ec"
ruff-check = "ruff check services/ws-modules/"
ruff-fmt = "ruff format services/ws-modules/"

[tasks.dprint-check]
run = "dprint check"
Expand All @@ -32,7 +36,7 @@ DPRINT_CACHE_DIR = "/tmp/dprint-cache"
run = "dprint fmt"

[tasks.fmt]
depends = ["cargo-clippy-fix", "cargo-fmt", "dprint-fmt", "taplo-fmt"]
depends = ["cargo-clippy-fix", "cargo-fmt", "dprint-fmt", "ruff-fmt", "taplo-fmt"]
description = "Run repository formatters"

[tasks.install-nightly]
Expand All @@ -46,6 +50,7 @@ depends = [
"dprint-check",
"editorconfig-check",
"osv-scanner",
"ruff-check",
"taplo-check",
"typos",
]
Expand Down Expand Up @@ -159,7 +164,15 @@ description = "Build the nfc workflow WASM module"
dir = "services/ws-modules/nfc"
run = "wasm-pack build . --target web"

[tasks.build-wasm]
[tasks.build-ws-pydata1-module]
description = "Build the pydata1 Python workflow module"
dir = "services/ws-modules/pydata1"
run = """
uv build --wheel --out-dir pkg
cargo run -p pyproject-to-package-json
"""

[tasks.build-modules]
depends = [
"build-ws-audio1-module",
"build-ws-bluetooth-module",
Expand All @@ -170,6 +183,7 @@ depends = [
"build-ws-graphics-info-module",
"build-ws-har1-module",
"build-ws-nfc-module",
"build-ws-pydata1-module",
"build-ws-sensor1-module",
"build-ws-speech-recognition-module",
"build-ws-video1-module",
Expand Down
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace.package]
edition = "2024"
license = "Apache-2.0 and MIT"
license = "Apache-2.0 or MIT"
repository = "https://github.com/edge-toolkit/core"
rust-version = "1.87.0"

Expand All @@ -23,6 +23,7 @@ members = [
"services/ws-server",
"services/ws-wasm-agent",
"utilities/onnx",
"utilities/pyproject-to-package-json",
]
resolver = "2"

Expand All @@ -40,5 +41,6 @@ serde-env = "0.3"
serde-inline-default = "1.0"
serde_default = "0.2"
serde_json = "1"
toml = "0.8"
tracing = "0.1"
uuid = { version = "1", features = ["v4", "v7"] }
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mise run ws-e2e-chrome

## Run ws agent in browser

### Build WASM and run the WS server
### Build modules and run the WS server

In a separate terminal start OpenObserve (o2) and leave it running.

Expand All @@ -31,16 +31,14 @@ Then start the fetch the ONNX models and run the server

```bash
mise run download-models
mise run build-wasm
mise run build-modules
mise run ws-server
```

Scan the QR-Code with a smart-phone camera and open the URL.

Select the module to run in the drop-down, then click "Run module" button.

The module list is dynamically populated from the modules in [services/ws-modules](services/ws-modules).

Note: The WASM build disables WebAssembly reference types, so it can still load on older browsers such as Chrome 95.

In a separate terminal, open the OpenObserve UX using:
Expand All @@ -51,6 +49,17 @@ mise run open-o2

The server logs appear in the Logs section.

## Modules

The module list is dynamically populated from the modules in [services/ws-modules](services/ws-modules).

Each module must be a directory `pkg` containing a `package.json` that defines a `main` which contains a JavaScript file
that can load and run the module.

Most of the module are built from Rust using `wasm-pack build --target web`.

The module `pydata1` uses [pyodide](https://pyodide.org/) to run a Python script.

## Grant

This repository is part of a grant managed by the School of EECMS, Curtin University.
Expand Down
10 changes: 0 additions & 10 deletions services/ws-modules/audio1/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,6 @@ pub fn init() {
info!("audio-capture module initialized");
}

#[wasm_bindgen]
pub fn metadata() -> JsValue {
serde_wasm_bindgen::to_value(&json!({
"name": env!("CARGO_PKG_NAME"),
"description": env!("CARGO_PKG_DESCRIPTION"),
"version": env!("CARGO_PKG_VERSION"),
}))
.unwrap_or(JsValue::NULL)
}

#[wasm_bindgen]
pub fn is_running() -> bool {
AUDIO_CAPTURE_RUNTIME.with(|runtime| runtime.borrow().is_some())
Expand Down
10 changes: 0 additions & 10 deletions services/ws-modules/bluetooth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,6 @@ pub fn init() {
info!("bluetooth module initialized");
}

#[wasm_bindgen]
pub fn metadata() -> JsValue {
serde_wasm_bindgen::to_value(&json!({
"name": env!("CARGO_PKG_NAME"),
"description": env!("CARGO_PKG_DESCRIPTION"),
"version": env!("CARGO_PKG_VERSION"),
}))
.unwrap_or(JsValue::NULL)
}

#[wasm_bindgen]
pub fn is_running() -> bool {
false
Expand Down
10 changes: 0 additions & 10 deletions services/ws-modules/comm1/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ pub fn init() {
info!("comm1 workflow module initialized");
}

#[wasm_bindgen]
pub fn metadata() -> JsValue {
serde_wasm_bindgen::to_value(&json!({
"name": env!("CARGO_PKG_NAME"),
"description": env!("CARGO_PKG_DESCRIPTION"),
"version": env!("CARGO_PKG_VERSION"),
}))
.unwrap_or(JsValue::NULL)
}

#[wasm_bindgen]
pub async fn run() -> Result<(), JsValue> {
log("comm1: entered run()")?;
Expand Down
11 changes: 0 additions & 11 deletions services/ws-modules/data1/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::rc::Rc;
use edge_toolkit::ws::WsMessage;
use et_ws_wasm_agent::{WsClient, WsClientConfig, append_to_textarea};
use js_sys::{Promise, Reflect};
use serde_json::json;
use tracing::info;
use wasm_bindgen::prelude::*;
use wasm_bindgen_futures::JsFuture;
Expand All @@ -16,16 +15,6 @@ pub fn init() {
info!("data1 workflow module initialized");
}

#[wasm_bindgen]
pub fn metadata() -> JsValue {
serde_wasm_bindgen::to_value(&json!({
"name": env!("CARGO_PKG_NAME"),
"description": env!("CARGO_PKG_DESCRIPTION"),
"version": env!("CARGO_PKG_VERSION"),
}))
.unwrap_or(JsValue::NULL)
}

#[wasm_bindgen]
pub async fn run() -> Result<(), JsValue> {
let msg = "data1: entered run()";
Expand Down
10 changes: 0 additions & 10 deletions services/ws-modules/face-detection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,6 @@ pub fn init() {
info!("face detection workflow module initialized");
}

#[wasm_bindgen]
pub fn metadata() -> JsValue {
serde_wasm_bindgen::to_value(&json!({
"name": env!("CARGO_PKG_NAME"),
"description": env!("CARGO_PKG_DESCRIPTION"),
"version": env!("CARGO_PKG_VERSION"),
}))
.unwrap_or(JsValue::NULL)
}

#[wasm_bindgen]
pub fn is_running() -> bool {
FACE_RUNTIME.with(|runtime| runtime.borrow().is_some())
Expand Down
10 changes: 0 additions & 10 deletions services/ws-modules/geolocation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,6 @@ pub fn init() {
info!("geolocation module initialized");
}

#[wasm_bindgen]
pub fn metadata() -> JsValue {
serde_wasm_bindgen::to_value(&json!({
"name": env!("CARGO_PKG_NAME"),
"description": env!("CARGO_PKG_DESCRIPTION"),
"version": env!("CARGO_PKG_VERSION"),
}))
.unwrap_or(JsValue::NULL)
}

#[wasm_bindgen]
pub fn is_running() -> bool {
false
Expand Down
10 changes: 0 additions & 10 deletions services/ws-modules/graphics-info/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,6 @@ pub fn init() {
info!("graphics-info module initialized");
}

#[wasm_bindgen]
pub fn metadata() -> JsValue {
serde_wasm_bindgen::to_value(&json!({
"name": env!("CARGO_PKG_NAME"),
"description": env!("CARGO_PKG_DESCRIPTION"),
"version": env!("CARGO_PKG_VERSION"),
}))
.unwrap_or(JsValue::NULL)
}

#[wasm_bindgen]
pub fn is_running() -> bool {
false
Expand Down
10 changes: 0 additions & 10 deletions services/ws-modules/har1/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,16 +299,6 @@ pub fn init() {
info!("har1 workflow module initialized");
}

#[wasm_bindgen]
pub fn metadata() -> JsValue {
serde_wasm_bindgen::to_value(&json!({
"name": env!("CARGO_PKG_NAME"),
"description": env!("CARGO_PKG_DESCRIPTION"),
"version": env!("CARGO_PKG_VERSION"),
}))
.unwrap_or(JsValue::NULL)
}

#[wasm_bindgen]
pub async fn run() -> Result<(), JsValue> {
set_har_status("har1: entered run()")?;
Expand Down
10 changes: 0 additions & 10 deletions services/ws-modules/nfc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,6 @@ pub fn init() {
info!("nfc module initialized");
}

#[wasm_bindgen]
pub fn metadata() -> JsValue {
serde_wasm_bindgen::to_value(&json!({
"name": env!("CARGO_PKG_NAME"),
"description": env!("CARGO_PKG_DESCRIPTION"),
"version": env!("CARGO_PKG_VERSION"),
}))
.unwrap_or(JsValue::NULL)
}

#[wasm_bindgen]
pub fn is_running() -> bool {
false
Expand Down
2 changes: 2 additions & 0 deletions services/ws-modules/pydata1/pkg/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.whl
package.json
Loading
Loading