Speaking the Same Language: Message Types
In MentraOS Cloud, everything happens through messages. Think of them as the conversations between glasses, cloud, and apps. Let’s learn the language!The Four Conversations
There are four main conversations happening:- Glasses → Cloud (What the glasses tell us)
- Cloud → Glasses (What we tell the glasses)
- Apps → Cloud (What apps ask us to do)
- Cloud → Apps (What we tell the apps)
packages/sdk/src/types/message-types.ts.
Conversation 1: Glasses → Cloud
These messages come from the mobile app (remember, it’s the bridge between glasses and cloud). Types are defined inpackages/sdk/src/types/messages/glasses-to-cloud.ts:
Connection Messages
User Actions
App Control
Media Events
System Updates
Location Updates
Conversation 2: Cloud → Glasses
These messages tell the glasses what to do:Connection Management
Display Updates
Media Requests
Settings Updates
Conversation 3: Apps → Cloud
Apps use these messages to interact with the system:Connection Setup
Display Requests
Media Requests
Conversation 4: Cloud → Apps
The cloud sends these to apps:Connection Management
Data Streams
This is the main way apps receive data. Stream types are defined inpackages/sdk/src/types/streams.ts:
System Updates
Message Flow Example
Let’s trace a message through the system when Alex says “What’s the weather?”:- Glasses capture audio → Send audio data to cloud
- Cloud transcribes → “What’s the weather?”
- Cloud finds subscribers → Weather app is subscribed to transcriptions
-
Cloud sends to app:
- App processes → Fetches weather data
-
App responds:
- Cloud validates → Checks rate limits, formats display
-
Cloud sends to glasses:
- Alex sees the weather on their glasses display!
Important Patterns
Request-Response Pattern
Some messages have a request ID for tracking:- App sends
PHOTO_REQUESTwithrequestId: "photo-123" - Cloud forwards to glasses
- Glasses respond with
PHOTO_TAKENwith samerequestId - Cloud matches response to request and sends to app
Subscription Pattern
Apps don’t get all data, only what they subscribe to. Available stream types (frompackages/sdk/src/types/streams.ts):
Hardware Streams:
button_press- Button press eventshead_position- Head up/down positionlocation_update- GPS location updatesvps_coordinates- Visual positioning system data
transcription- Speech-to-text resultstranslation- Real-time translationVAD- Voice activity detectionaudio_chunk- Raw audio data
phone_notification- Incoming notificationsphone_notification_dismissed- Notification dismissalscalendar_event- Calendar updates
start_app- App start requestsstop_app- App stop requestscore_status_update- System status
photo_taken- Photo capture eventsrtmp_stream_status- RTMP streaming statusmanaged_stream_status- Managed streaming status
Fire-and-Forget Pattern
Some messages don’t expect responses:- Display updates just happen
- Settings updates are applied silently
- Status updates are informational