pub struct HardwareSession {
pub device_id: String,
pub device_type: DeviceType,
pub caps: Caps,
pub mode: Mode,
pub ambient_session_id: Option<String>,
pub conversation_id: String,
pub agent_id: Option<String>,
/* private fields */
}Expand description
Live state for one connected device.
Fields§
§device_id: String§device_type: DeviceType§caps: Caps§mode: Mode§ambient_session_id: Option<String>The ambient long-running meeting id, if this device is ambient-capable.
conversation_id: StringStable per-device conversation id used for each chat turn’s trace + (future)
history binding. NOTE: v1 hardware chat is per-turn STATELESS — the turn
runs run_text_turn(persist=false) with only the current user message, so
prior turns are not replayed into the model. The stable id is here so a
later persist=true / history-prefill upgrade has a durable key to hang on.
Public so the Core WS pump (which owns the kernel-welded chat turn) can build
the turn’s key without reaching into the session.
agent_id: Option<String>The agent that handles device chat turns (None = the default LLM path).
Resolved once at connect by the Core WS handler and carried here so the
pump can build the kernel-welded ChatTurn from a pure TurnInput.
Implementations§
Source§impl HardwareSession
impl HardwareSession
Sourcepub fn new(
device_id: String,
device_type: DeviceType,
caps: Caps,
ambient_session_id: Option<String>,
meetings: Arc<dyn MeetingIngest>,
agent_id: Option<String>,
) -> Result<Self>
pub fn new( device_id: String, device_type: DeviceType, caps: Caps, ambient_session_id: Option<String>, meetings: Arc<dyn MeetingIngest>, agent_id: Option<String>, ) -> Result<Self>
Create a session from the device’s hello. ambient_session_id is the
resumed/opened long-running meeting (set by the WS handler when the device
is ambient-capable); None for interactive-only devices.
Sourcepub fn tts_format() -> AudioFormat
pub fn tts_format() -> AudioFormat
The TTS downlink format advertised back to the device in hello_ack.
Sourcepub fn set_mode(&mut self, mode: Mode)
pub fn set_mode(&mut self, mode: Mode)
Switch operating mode. On entering chat we clear any stale turn buffer.
Sourcepub fn on_listen_start(&mut self)
pub fn on_listen_start(&mut self)
Begin a chat turn: drop any buffered audio so the turn starts clean.
Sourcepub async fn on_audio(
&mut self,
opus_packet: &[u8],
) -> Result<Vec<SessionOutput>>
pub async fn on_audio( &mut self, opus_packet: &[u8], ) -> Result<Vec<SessionOutput>>
Handle a decoded uplink Opus packet for the current mode.
In chat it accumulates the turn (the model runs on listen:stop). In
ambient it buffers ~1 s then feeds a WAV chunk to the meetings pipeline,
returning ambient_ack/ambient_skip. Idle mode ignores audio.
Sourcepub fn take_voice_turn(&mut self) -> Option<TurnInput>
pub fn take_voice_turn(&mut self) -> Option<TurnInput>
Take the buffered chat turn on listen:stop. Returns the captured 16 kHz
mono PCM as a pure TurnInput, or None when nothing was captured. The
Core WS pump wraps this in its kernel-welded ChatTurn (with the session
deps + conversation_id) and spawns the ASR → model → TTS turn off the recv
loop so the loop stays live for barge-in.
Sourcepub fn take_text_turn(&mut self, content: &str) -> Option<TurnInput>
pub fn take_text_turn(&mut self, content: &str) -> Option<TurnInput>
Build a text-fallback turn input (skips ASR). None for empty input.
Sourcepub fn emotion_for_phase(&self) -> Emotion
pub fn emotion_for_phase(&self) -> Emotion
Map a chat/processing phase to the face emotion to push. Used by the WS handler when it wants to nudge the face outside a full turn.