edge-intelligence-sdk 0.3.7 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/android/jniLibs/arm64-v8a/libel_ffi.so +0 -0
- package/ios/libel_ffi.a +0 -0
- package/package.json +3 -2
- package/src/web/README.md +91 -0
- package/src/web/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# edge-intelligence-sdk
|
|
2
|
+
|
|
3
|
+
Generated Web and React Native bindings for the Edge Intelligence SDK.
|
|
4
|
+
|
|
5
|
+
This package contains the WASM/TypeScript browser surface, React Native
|
|
6
|
+
TypeScript bindings, and native Android/iOS libraries assembled by the
|
|
7
|
+
release pipeline.
|
|
8
|
+
|
|
9
|
+
Source, crate documentation, and release notes live in the Edge
|
|
10
|
+
Intelligence repository.
|
|
Binary file
|
package/ios/libel_ffi.a
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edge-intelligence-sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"description": "Edge-native LLM inference SDK — Web (WASM) + React Native",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"files": [
|
|
13
13
|
"src/",
|
|
14
14
|
"android/",
|
|
15
|
-
"ios/"
|
|
15
|
+
"ios/",
|
|
16
|
+
"README.md"
|
|
16
17
|
],
|
|
17
18
|
"license": "Apache-2.0"
|
|
18
19
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# el-ffi — host bindings (React Native, Flutter, Web)
|
|
2
|
+
|
|
3
|
+
One Rust API surface exported three ways, so mobile and web apps can call the
|
|
4
|
+
SDK in their native idiom (ADR-001, ADR-009, ADR-010):
|
|
5
|
+
|
|
6
|
+
| Surface | Tool | Output |
|
|
7
|
+
|---------|------|--------|
|
|
8
|
+
| **React Native** | `uniffi-bindgen-react-native` | TypeScript + JSI C++ + Turbo Module |
|
|
9
|
+
| **Flutter** | `flutter_rust_bridge` v2 | Dart opaque handle, `Future`/`Stream` |
|
|
10
|
+
| **Web / npm** | `wasm-bindgen` | ESM TypeScript package via `wasm-pack` |
|
|
11
|
+
|
|
12
|
+
No `unsafe` (`#![forbid(unsafe_code)]`). The crate is `cdylib` + `staticlib` +
|
|
13
|
+
`lib` so each toolchain can link the form it needs.
|
|
14
|
+
|
|
15
|
+
## What it provides
|
|
16
|
+
|
|
17
|
+
- **`EdgeLlm`** — the flat, FFI-friendly facade, annotated for all three
|
|
18
|
+
surfaces at once:
|
|
19
|
+
- `EdgeLlm::local(model_uri)` — local Candle engine, air-gapped (ADR-002/004).
|
|
20
|
+
An empty `model_uri` uses a deterministic toy model for development;
|
|
21
|
+
a path loads a consumer-supplied GGUF.
|
|
22
|
+
- `EdgeLlm::cloud(model, api_key)` — frontier cloud backend (opt-in, ADR-010).
|
|
23
|
+
**Native only** — see the web limitation below. `api_key` must come from the
|
|
24
|
+
platform keystore, never embedded.
|
|
25
|
+
- `ask(prompt) -> Result<String, SdkError>` — blocking chat.
|
|
26
|
+
- `ask_stream(prompt, |token| …)` — closure streaming (Flutter / FRB v2).
|
|
27
|
+
- `ask_stream_cb(prompt, handler)` — `StreamHandler` callback streaming
|
|
28
|
+
(React Native; UniFFI cannot export `impl FnMut`).
|
|
29
|
+
- `reset()`.
|
|
30
|
+
- **`SdkError`** — a thin, FFI-safe projection of `el_core::EdgeError`
|
|
31
|
+
(`el-core`'s `Box<str>`/Rust-specific variants are not FFI-safe). Projects to
|
|
32
|
+
the host language's exception type, or a JS exception on wasm.
|
|
33
|
+
- **`StreamHandler`** — the React Native streaming callback interface.
|
|
34
|
+
|
|
35
|
+
## Usage (Rust side)
|
|
36
|
+
|
|
37
|
+
```rust
|
|
38
|
+
use el_ffi::EdgeLlm;
|
|
39
|
+
|
|
40
|
+
// Empty path → deterministic toy model; exercises the full binding layer.
|
|
41
|
+
let sdk = EdgeLlm::local(String::new())?;
|
|
42
|
+
let reply = sdk.ask("hello".into())?;
|
|
43
|
+
assert!(!reply.is_empty());
|
|
44
|
+
|
|
45
|
+
// Streaming (Flutter / closure form):
|
|
46
|
+
sdk.ask_stream("hi".into(), |fragment| print!("{fragment}"))?;
|
|
47
|
+
# Ok::<(), el_ffi::SdkError>(())
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Building the bindings
|
|
51
|
+
|
|
52
|
+
The Rust binding *surfaces* compile on the host; the cross-target builds and
|
|
53
|
+
codegen run via the [`Makefile`](../../../Makefile):
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
make build-android # cargo build --target aarch64-linux-android (shared lib)
|
|
57
|
+
make build-ios # cargo build --target aarch64-apple-ios (static lib)
|
|
58
|
+
make build-wasm # wasm-pack build → out/web ESM package
|
|
59
|
+
|
|
60
|
+
make codegen-rn # React Native JSI bindings (needs build-android)
|
|
61
|
+
make codegen-flutter # flutter_rust_bridge v2 Dart bindings
|
|
62
|
+
make bindings # all three surfaces
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Prerequisites (rustup targets, NDK linker, `wasm-pack`,
|
|
66
|
+
`uniffi-bindgen-react-native`, `flutter_rust_bridge_codegen`) are documented in
|
|
67
|
+
the Makefile header.
|
|
68
|
+
|
|
69
|
+
## Web limitations
|
|
70
|
+
|
|
71
|
+
On `wasm32` the local path currently uses a dev-stage echo placeholder until
|
|
72
|
+
Candle-on-wasm is wired, and the **cloud backend is not available on web**
|
|
73
|
+
(ADR-010 amendment): `el-cloud`'s blocking HTTP transport has no wasm
|
|
74
|
+
implementation, so `EdgeLlm.cloud` throws an explicit error there instead of
|
|
75
|
+
silently degrading. Use a native binding (React Native / Flutter) for cloud
|
|
76
|
+
access.
|
|
77
|
+
|
|
78
|
+
## Status
|
|
79
|
+
|
|
80
|
+
Implemented and tested (native + `wasm32` compile). As a workspace member, the
|
|
81
|
+
host-target Rust surfaces build and test with the rest of the workspace
|
|
82
|
+
(`cargo test --workspace`); the Android / iOS / wasm cross-builds and binding
|
|
83
|
+
codegen run separately via the Makefile because those toolchains are installed
|
|
84
|
+
out-of-band.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
Part of the [Edge Intelligence](../../../README.md) workspace. Realizes
|
|
89
|
+
[ADR-001](../../../docs/adr/ADR-001-adopt-webassembly-as-cross-platform-sdk-runtime.md),
|
|
90
|
+
[ADR-009](../../../docs/adr/ADR-009-flutter-rust-bridge-for-dart-bindings.md),
|
|
91
|
+
and [ADR-010](../../../docs/adr/ADR-010-unified-llm-provider-trait-with-opt-in-frontier-egress.md).
|
package/src/web/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "el-ffi",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "Host bindings: uniffi-bindgen-react-native (RN), flutter_rust_bridge v2 (Flutter), wasm-bindgen (web) — ADR-001/009.",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.9",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"files": [
|
|
8
8
|
"el_ffi_bg.wasm",
|