Skip to main content

HardwareSession

Struct HardwareSession 

Source
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: String

Stable 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

Source

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.

Source

pub fn tts_format() -> AudioFormat

The TTS downlink format advertised back to the device in hello_ack.

Source

pub fn set_mode(&mut self, mode: Mode)

Switch operating mode. On entering chat we clear any stale turn buffer.

Source

pub fn on_listen_start(&mut self)

Begin a chat turn: drop any buffered audio so the turn starts clean.

Source

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.

Source

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.

Source

pub fn take_text_turn(&mut self, content: &str) -> Option<TurnInput>

Build a text-fallback turn input (skips ASR). None for empty input.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more