1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! Unified Capabilities Module (Native + WASM support)
//!
//! This module provides capability APIs that work seamlessly
//! on both Native and WASM targets through conditional compilation.
//!
//! # Platform Support Matrix
//!
//! | Capability | Native | WASM | Implementation |
//! |------------|--------|------|----------------|
//! | Device Metrics Read | ✅ async | ✅ sync | Unified API |
//! | Device Metrics Write | ✅ async | ✅ sync | Unified API |
//! | Device Control | ✅ async | ✅ sync | Unified API |
//! | Storage Query | ✅ async | ✅ sync | Unified API |
//! | Telemetry History | ✅ async | ✅ sync | Host proxy |
//! | Metrics Aggregate | ✅ async | ✅ sync | Host proxy |
//! | Event Publish | ✅ async | ✅ sync | Unified API |
//! | Event Subscribe | ✅ async | ✅ poll | Polling mode |
//! | Extension Call | ✅ async | ✅ sync | Host proxy |
//! | Agent Trigger | ✅ async | ✅ sync | Host proxy |
//! | Rule Trigger | ✅ async | ✅ sync | Host proxy |
//!
//! # Design Philosophy
//!
//! - **Single API**: Developers learn one API that works everywhere
//! - **Automatic routing**: Context.invoke_capability() routes to the right backend
//! - **Minimal FFI**: Only 1-2 host functions needed internally
//! - **Type safety**: Same type definitions across platforms
//!
//! # Usage
//!
//! ```rust,ignore
//! use neomind_extension_sdk::capabilities::device;
//! use neomind_extension_sdk::capabilities::storage;
//!
//! // Works on both Native and WASM
//! // Native: async execution
//! // WASM: synchronous execution (host handles async internally)
//! let metrics = device::get_metrics(&ctx, "device-1")?;
//! let temp = device::get_metric_typed::<f64>(&ctx, "device-1", "temperature")?;
//!
//! // Write virtual metrics
//! device::write_virtual_metric(&ctx, "device-1", "status", &json!("active"))?;
//!
//! // Query telemetry history (now works on WASM!)
//! let history = device::query_telemetry(&ctx, "device-1", "temp", start, end)?;
//!
//! // Query storage (new!)
//! let latest = storage::get_latest(&ctx, "device-1", "temperature")?;
//! let range = storage::get_range(&ctx, "device-1", "temperature", start, end)?;
//!
//! // Subscribe to events
//! let sub = event::subscribe(&ctx, "device_changed", None)?;
//! let events = sub.poll()?; // Polling mode on WASM
//! ```
// Re-export error type
pub use CapabilityError;
// Re-export storage types
pub use ;
// Re-export core types from host module (now self-contained)
pub use crate;
// Re-export CapabilityContext for extensions
pub use crateCapabilityContext;