Skip to main content

ryu_hardware/
lib.rs

1//! Ryu Hardware Protocol (RHP v1) node backend — an extracted Core capability crate.
2//!
3//! This crate is the node half of the Ryu Hardware Protocol defined in
4//! `apps/hardware/PROTOCOL.md`. Ryu hardware (watch / necklace / desk, all
5//! ESP32-S3) talks to a node over a WebSocket, either directly over WiFi (Mode B)
6//! or tunneled through the mobile app over BLE (Mode A — transparent to the node).
7//!
8//! ## Layout
9//!
10//! - [`protocol`] — serde structs/enums mirroring PROTOCOL.md §3 (the wire
11//!   contract shared by the firmware and mobile relay mirrors).
12//! - [`store`] — the device registry (SQLite): paired devices, per-device
13//!   revocable Bearer tokens, last-seen/battery presence.
14//! - [`pairing`] — pairing-nonce verification and token issuance.
15//! - [`codec`] — the Opus/WAV codec edge, so the rest of Core sees PCM/WAV.
16//! - [`session`] — the per-connection realtime session state machine (audio
17//!   buffering + the ambient meetings bridge, via the [`ingest::MeetingIngest`]
18//!   seam), the live device-sender registry, and
19//!   [`session::SessionOutput`]/[`session::TurnInput`].
20//! - [`ingest`] — the [`ingest::MeetingIngest`] seam inverting the ambient-audio
21//!   coupling so this crate never links `ryu_meetings`.
22//! - [`feed`] — the [`feed::DashboardFeed`] seam inverting the device-dashboard
23//!   render coupling so this crate never links `ryu_dashboards`.
24//! - [`nudge`] — the live display-nudge loop (dashboard change → device re-poll).
25//! - [`api`] — the device-registry CRUD + TRMNL display HTTP surface.
26//!
27//! ## What stays Core-side (consumers of this crate's types)
28//!
29//! The **public ws/pair ingress route** (a per-device Bearer/nonce the global
30//! `RYU_TOKEN` `require_auth` cannot gate, plus node-URL resolution welded to the
31//! mesh + the SSRF guard) and the **chat-turn orchestration** (welded to Core's
32//! `run_text_turn` / voice ASR / OuteTTS session loop) stay in `apps/core` and
33//! consume this crate's [`session::HardwareSession`]/[`session::TurnInput`]/
34//! [`session::SessionOutput`]/[`protocol`] types — the documented kernel weld,
35//! exactly the teams `@team`-orchestration precedent.
36//!
37//! Placement (Core vs Gateway): the device registry, token lifecycle, and the
38//! realtime session decide *what runs*, so they are Core-tier.
39
40pub mod api;
41pub mod codec;
42pub mod feed;
43pub mod ingest;
44pub mod nudge;
45pub mod pairing;
46pub mod protocol;
47pub mod session;
48pub mod store;
49
50pub use feed::{
51    DashboardFeed, DeviceBinding, DeviceManifest, RenderedImage, ScreenProfile, SetDeviceResult,
52};
53pub use ingest::MeetingIngest;
54pub use session::{live, HardwareSession, SessionOutput, TurnInput};
55pub use store::{hash_token, DeviceRecord, DeviceStore};