forked from Blendman974/faceclaw
Add app tool registration for voice assistant; voice assistant can read and send to terminals
This commit is contained in:
1 parent
0aeb24ed00
commit
fe205c0164
9 files changed
+533
-16
No files matched your search
@@ -0,0 +1,87 @@
|
||||
# Even-Analogous Apps
|
||||
|
||||
Ideally we'd like full feature parity with the stock Even app (or at least,
|
||||
close enough that not-using the stock app doesn't feel like a sacrifice).
|
||||
A rough list of things the stock app has that we currently don't:
|
||||
|
||||
## Quicklist
|
||||
|
||||
Quicklist is Even's version of a todo app, in the form of a dashboard card
|
||||
that you add to and remove from with assistant voice commands. It's pretty
|
||||
simple to build once a general voice assistant is in place, but I don't
|
||||
actually like their design: a todo list really wants to be synchronized
|
||||
with something external like Roam or Notion, so I think it'd be better to
|
||||
build one of those integrations instead.
|
||||
|
||||
## Stocks, News
|
||||
|
||||
Even has a dashboard card which is a stock ticker. I think this is probably
|
||||
misguided; while there do exist people who would want and benefit from a stock
|
||||
tracker on their glasses, I do'm not sure there exist people who would want and
|
||||
benefit from a stock tracker that isn't a professional-tier tool connected
|
||||
to carefully chosen low-latency data sources, and neither I (nor Even) can
|
||||
build that tool.
|
||||
|
||||
The News dashboard card is more broadly useful, but has a similar issue: a
|
||||
generic news ticker isn't really useful without a much higher degree of
|
||||
customization. Probably the right thing to build instead is more like an RSS
|
||||
reader.
|
||||
|
||||
## Ring Connection Management
|
||||
|
||||
The stock Even app is responsible for pairing the glasses with the ring (ie,
|
||||
sending the glasses a configuration messages telling it to connect to the
|
||||
ring's MAC address). If you pair them in the stock app and then switch to a
|
||||
custom app, they remain paired indefinitely (this configuration is stored in
|
||||
flash), and our custom app can make use of the fact that they're paired.
|
||||
|
||||
We don't yet have support for connecting or disconnecting the glasses and ring
|
||||
to/from each other. For latency reasons, it would be nice if we could unpair
|
||||
the glasses from the ring and connect the phone to it directly; we don't yet
|
||||
support that either.
|
||||
|
||||
## Ring Health Metrics
|
||||
|
||||
The R1 ring contains an oximeter-style LED sensor and an accelerometer, which
|
||||
can be used for a step count, heart rate measurement, etc. I'm not sure
|
||||
whether the sensor interpretation is done within the firmware (in which case
|
||||
it would make sense to display them in the UI) or in the Even phone app (in
|
||||
which case we'd be reimplementing all the interpretation algorithms, which
|
||||
isn't worth it.
|
||||
|
||||
## Navigate
|
||||
|
||||
Even has a Navigate app, which is basically Google Maps for the specific use
|
||||
case of "name a destination, get turn by turn directions to there". I believe
|
||||
this is using Mapbox, which takes care of most of the heavy lifting (if you
|
||||
have an API key). I don't think Even's version is very good (they ran into
|
||||
trouble with image-upload performance preventing a good map display size), so
|
||||
it's likely not too hard to do better. One caveat is the location permission;
|
||||
Android normally only wants to prompt for location permission "while using the
|
||||
app", but Android's idea of in use (phone screen unlocked and window focused)
|
||||
doesn't match our idea of in use (G2 glasses on, phone could be locked). This
|
||||
app also gets a lot better if we figure out how to use the device's
|
||||
magnetometer (if it indeed has a working magnetometer).
|
||||
|
||||
## Distance/Viewport Configuration
|
||||
|
||||
During glasses onboarding, the stock firmware has you select a vertical offset
|
||||
for the screen image. This accounts for glasses resting at different positions
|
||||
on your face (the optics don't let you see the whole screen area), but cuts
|
||||
the usable screen height from 480px to 288px. There is also a "distance"
|
||||
config option in the stock Android app, which adjusts the horizontal position
|
||||
of the image on the two lenses separately to create the impression of the
|
||||
image being closer or farther; this cuts the usable screen width from 640px to
|
||||
576px. Unlike the vertical size reduction, this 64px reduction is not
|
||||
optically necessary.
|
||||
|
||||
## Even AI
|
||||
## Translate and Conversate
|
||||
|
||||
## Other Configuration
|
||||
|
||||
Brightness, head-up trigger
|
||||
|
||||
|
||||
# Other Apps
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# Music: "Resume" action via media-key dispatch
|
||||
|
||||
Follow-up to the MediaBrowserService browsing support. When no media session
|
||||
is active, `AudioManager.dispatchMediaKeyEvent(KEYCODE_MEDIA_PLAY)` (down+up
|
||||
pair) is routed by the system to the *last* media app's manifest-declared
|
||||
`MEDIA_BUTTON` receiver, even if that app's process is dead — the same
|
||||
mechanism a Bluetooth headset play button uses. Most players respond by
|
||||
resuming the last queue.
|
||||
|
||||
Idea: add a "Resume last" row to the Music app's no-active-session screen
|
||||
(next to the browse entry). ~5 lines in `FaceclawMediaController` plus one UI
|
||||
row; no per-app negotiation needed. Caveat: it's fire-and-forget — no feedback
|
||||
if nothing handles it, so the UI should just wait for a session to appear.
|
||||
@@ -0,0 +1,133 @@
|
||||
# MentraOS app compatibility for Faceclaw — feasibility assessment (2026-07-23)
|
||||
|
||||
MentraOS: https://github.com/Mentra-Community/MentraOS (MIT), docs at https://docs.mentraglass.com.
|
||||
|
||||
## TL;DR
|
||||
|
||||
Technically feasible with moderate effort, but the timing is awkward: MentraOS is
|
||||
**deprecating its entire current app API**. MentraOS 3.0 ships **Aug 3, 2026** and
|
||||
cloud-SDK apps stop working on it (a "MentraOS Legacy" mode preserves them through
|
||||
**October 2026**). The replacement — a **Miniapp SDK** where apps are phone-local JS
|
||||
bundles running in a WebView — gets a public spec in **September 2026**, and that model
|
||||
is a *much* better fit for Faceclaw than the cloud model. Recommendation: wait for the
|
||||
miniapp spec and target that; only build a minimal cloud-protocol emulator if access to
|
||||
the existing app corpus is wanted in the interim.
|
||||
|
||||
## MentraOS app model (current, "Cloud SDK" / TPA era)
|
||||
|
||||
- Apps are developer-hosted server processes (Node/Bun, `@mentra/sdk`). Chain:
|
||||
glasses → phone (BLE) → MentraOS Cloud (WS) → app server (WS).
|
||||
- Start flow: cloud POSTs a `session_request` webhook `{sessionId, userId, websocketUrl}`
|
||||
to the app's registered URL; the app dials back to `websocketUrl` and sends
|
||||
`tpa_connection_init {packageName, sessionId, apiKey}`; cloud acks with settings +
|
||||
device capabilities. **The webhook carries the WS URL, so an unmodified `@mentra/sdk`
|
||||
app can be pointed at any server** — that is the compat hook.
|
||||
- Protocol: JSON over WebSocket (binary frames for audio). 28 app→cloud + 28 cloud→app
|
||||
message types, defined in `cloud/packages/sdk/src/types/` (`message-types.ts`,
|
||||
`streams.ts`, `layouts.ts`, `webhooks.ts`, `capabilities.ts`). The TS types are the spec.
|
||||
- Subscriptions: `subscription_update` with a full list of stream types, some
|
||||
parameterized (`transcription:en-US`, `touch_event:forward_swipe`). Events arrive in a
|
||||
`data_stream` envelope.
|
||||
- Display: 7 layout types — `text_wall`, `double_text_wall`, `dashboard_card`,
|
||||
`reference_card`, `bitmap_view` (base64), `bitmap_animation`, `clear_view` — sent as
|
||||
`display_event {view: 'main'|'dashboard', layout, durationMs?, forceDisplay?}`.
|
||||
Cloud throttles displays to 1 per 300 ms. Dashboard = shared look-up surface.
|
||||
- Streams: `transcription` (`{text, isFinal, ...}`), `translation`, `VAD`, `audio_chunk`
|
||||
(PCM), `button_press`, `touch_event`, `head_position` (up/down), `glasses_battery_update`,
|
||||
`phone_battery_update`, `location_update`, `phone_notification`(+dismissed),
|
||||
`calendar_event`, plus camera/RTMP/LED families irrelevant to G2.
|
||||
- Other: ElevenLabs TTS (`audio.speak`), per-app settings (schema in dev console, 9
|
||||
setting types, live `settings_update`), webview UI with signed-token auth, cloud KV
|
||||
storage, app-to-app messaging.
|
||||
- Hardware abstraction: `Capabilities` flags per device. **Even Realities G2 is a
|
||||
first-class device** (`capabilities/even-realities-g2.ts`): display 640×200 (their
|
||||
rendering canvas, not the 576×288 EvenHub raster), maxTextLines 5, bitmap-capable,
|
||||
capacitive swipe bar with TAP/DOUBLE_TAP/TRIPLE_TAP/PRESS_HOLD/SWIPE_UP/SWIPE_DOWN,
|
||||
IMU, mic, no camera/speaker/LED.
|
||||
- Licensing: MIT throughout; cloud is self-hostable in principle (Bun + MongoDB + S3 +
|
||||
third-party STT/TTS keys) but heavy.
|
||||
|
||||
## Coming model (Miniapp SDK, MentraOS 3.0)
|
||||
|
||||
Miniapps are JS bundles (`index.html` + `miniapp.json`) running **on the phone** inside
|
||||
the MentraOS host app's WebView ("Mentra Runtime"), packages `@mentra/miniapp` +
|
||||
`@mentra/miniapp-cli`, sideloaded via QR. API is analogous but smaller:
|
||||
`session.transcription`, `session.display.showTextWall`, `session.storage`. Example:
|
||||
https://github.com/Mentra-Community/LiveCaptionsLocalSdkMiniapp. Public spec Sept 2026.
|
||||
|
||||
## Fit with Faceclaw
|
||||
|
||||
Faceclaw's worker-per-app architecture is unusually favorable: apps are already isolated
|
||||
contexts speaking a small typed JSON vocabulary (`WorkerAppMessage`/`WorkerAppReply` in
|
||||
`app/ui/shell/worker-window.ts`), with pixels out-of-band. The compat layer would be one
|
||||
compiled-in "MentraOS host" app (a peer of `WorkerAppHost`) that presents each external
|
||||
app as a `ShellWindow` and:
|
||||
|
||||
- **Rasterizes layouts** → trivial. All 7 layout types map onto `GrayImage` +
|
||||
`drawTextWrapped`/`bitBlt` into the 540×260 `APP_VIEWPORT`. Bitmaps need scaling from
|
||||
their 640×200/576×136 assumptions; monochrome already matches.
|
||||
- **Maps input** → good. `DashboardInputEvent` (`click`/`double-click`/`long-press`/
|
||||
`scroll-up`/`scroll-down`) covers their G2 button-event list almost 1:1 (TRIPLE_TAP
|
||||
missing). Work item: input is currently routed only to the focused window; MentraOS
|
||||
wants multi-subscriber fan-out (background apps), so a broadcast layer is needed.
|
||||
- **Transcription** → the load-bearing stream, and Faceclaw already has it:
|
||||
`voiceControlBridge.onTranscript` (`{text, isFinal}`, replace semantics — matches
|
||||
MentraOS's `TranscriptionData` model well). Onboard Moonshine is English-only;
|
||||
parameterized languages would fall back to ElevenLabs/Whisper cloud providers.
|
||||
Needs multi-consumer fan-out and a policy for when the mic is open (MentraOS keeps it
|
||||
effectively continuous; Faceclaw is PTT/wakeword-oriented — battery implications).
|
||||
- **VAD** → sherpa endpointing exists. **audio_chunk** → PCM already surfaced on the
|
||||
ElevenLabs path (`onPcm`).
|
||||
- **Battery / phone notifications / calendar** → data already flows in Faceclaw
|
||||
(top-bar battery, notification listener, calendar app); just needs re-emission as
|
||||
streams.
|
||||
- **head_position** → gap. Faceclaw exposes raw IMU only (no gesture classification);
|
||||
the look-up dashboard gesture would need a small accelerometer classifier (cmd 19
|
||||
stream exists, see imu-accelerometer memory).
|
||||
- **TTS / audio out** → G2 has no speaker; MentraOS plays through the phone. Faceclaw
|
||||
would need phone-side audio playback (new but simple Android work).
|
||||
- **Settings** → MentraOS per-app settings map onto the shared `FaceclawSettings` store
|
||||
with a `mentra.<packageName>.*` prefix; the 9 setting types map onto
|
||||
`ConfigSetting` subclasses, mostly.
|
||||
- **Not applicable on G2**: camera/photo/RTMP/LiveKit, LED, WiFi setup — can be
|
||||
rejected via capabilities, which the protocol explicitly supports.
|
||||
|
||||
## The hard parts
|
||||
|
||||
1. **Who plays "cloud"?** Cloud-SDK apps dial out to a WS URL given in a webhook, so
|
||||
Faceclaw must (a) run a WS **server** — none exists anywhere in the codebase today,
|
||||
all networking is outbound okhttp client (`FaceclawWebSocket`, g2mirror pattern) —
|
||||
reachable from wherever the app server runs (fine on LAN; NAT pain otherwise), and
|
||||
(b) send the session webhook itself (simple outbound HTTP POST). A phone-hosted
|
||||
mini-cloud with Java-WebSocket/NanoWSD listening on LAN is the sane MVP; self-hosting
|
||||
their actual cloud (Bun+Mongo+Docker) is overkill.
|
||||
2. **Session lifecycle**: connection init/ack, `subscription_update` bookkeeping,
|
||||
`reconnect`/`reconnect_ack/rejected/deferred`, `app_stopped`, per-app permission
|
||||
gating. This is bookkeeping-heavy but not deep.
|
||||
3. **Display arbitration**: foreground vs `background`+`forceDisplay` apps, `durationMs`
|
||||
auto-revert, the shared dashboard view. Faceclaw's shell has focus/foreground but no
|
||||
equivalent of background-app display preemption or a look-up dashboard.
|
||||
4. **App discovery/registration UX**: no dev console; needs a simple "add app by URL +
|
||||
API key" settings flow (API key check can be a no-op or shared secret).
|
||||
|
||||
## Effort estimate
|
||||
|
||||
MVP covering the bulk of display-glasses apps (live captions, teleprompters, dashboards,
|
||||
notification relays): ~10–15 message types + ~8 stream types + webhook sender + LAN WS
|
||||
server + layout rasterizer + settings mapping. Roughly a few weeks of focused work, with
|
||||
transcription-stream policy and the WS server being the riskiest pieces. Full-surface
|
||||
emulation (webview auth, app messaging rooms, TTS, location tiers) is substantially more
|
||||
and mostly not worth it.
|
||||
|
||||
## Recommendation
|
||||
|
||||
- **Don't invest in the cloud-TPA protocol as the long-term target** — the vendor is
|
||||
killing it within ~3 months of now, and the ecosystem's apps will migrate to miniapps.
|
||||
- **Target the Miniapp SDK when its spec lands (Sept 2026).** It's strictly easier for
|
||||
Faceclaw: JS bundle in an Android WebView with an injected `session` bridge — no
|
||||
server, no webhooks, no reconnect protocol — and Faceclaw already has every underlying
|
||||
facility the bridge needs. The rasterizer/input/transcription plumbing built for it
|
||||
would be shared with any interim TPA emulator anyway.
|
||||
- If interim access to existing cloud-SDK apps matters, build the minimal LAN emulator
|
||||
described above, scoped to text layouts + transcription + button streams, and treat it
|
||||
as disposable.
|
||||
@@ -1,8 +1,8 @@
|
||||
# Voice Assistant Architecture
|
||||
|
||||
Status: design draft, 2026-07-19; revised 2026-07-24 (tool availability
|
||||
ontology, misc fixes). **Phase 1 is implemented** (see the Implementation plan
|
||||
below); phases 2-4 are still design-only.
|
||||
ontology, misc fixes). **Phases 1 and 2 are implemented** (see the
|
||||
Implementation plan below); phases 3-4 are still design-only.
|
||||
|
||||
## Goal
|
||||
|
||||
@@ -383,13 +383,26 @@ default highlight and wakeword skip-confirmation auto-send;
|
||||
*Deliverable: speak wakeword, ask "what's on my calendar", get an answer
|
||||
on-lens.*
|
||||
|
||||
**Phase 2 — app tools.**
|
||||
Worker protocol extension (set-tools / tool-call / tool-result),
|
||||
availability-tier filtering in the registry (`open` on window open/close,
|
||||
`foreground` on foreground change), `installed`-tier registration on launcher
|
||||
entries (shell-side handlers only; launch-on-call deferred), terminal app
|
||||
tools as the reference. *Deliverable: "run the build again" typed into the
|
||||
terminal even while it's backgrounded.*
|
||||
**Phase 2 — app tools.** ✅ Landed 2026-07-25 (builds + typechecks; not yet
|
||||
hardware-tested).
|
||||
Worker protocol extended with `set-tools` / `tool-result` (WorkerAppReply) and
|
||||
`tool-call` (WorkerAppMessage). `ToolRegistry.setAppTools`/`removeAppTools`
|
||||
key tools by windowId, prefix names `app.<appId>.`, and gate `foreground`
|
||||
tools on an `isForeground()` predicate (checked at list and dispatch time).
|
||||
`WorkerAppHost` proxies calls to its worker (callId round-trip, 15s host
|
||||
timeout backstop on top of the registry's per-tool timeout), registers a
|
||||
window's tools on `set-tools`, and withdraws them + fails in-flight calls on
|
||||
window close. Direct mode now re-lists tools each loop iteration.
|
||||
Terminal is the reference: the hub window declares `send_input` /
|
||||
`read_screen` / `list_sessions` (all `open`-tier); send_input/read_screen act
|
||||
on the active view (foregrounded → last-active → sole view). *Deliverable:
|
||||
"run the build again" typed into the terminal even while it's backgrounded.*
|
||||
|
||||
*Not yet done from the Phase 2 design:* `installed`-tier registration on
|
||||
launcher entries (no `installed` app tool exists yet — timer stays deferred);
|
||||
in-process-window tool registration (only worker apps wired); the per-window
|
||||
same-name collision handling (the terminal sidesteps it by declaring all tools
|
||||
on the single hub window).
|
||||
|
||||
**Phase 3 — external bridge.**
|
||||
Bridge wire protocol; ExternalAgentBackend (phone side, reusing the
|
||||
|
||||
Reference in new issue
Block a user