Files
hermeven/apps/even-client/src/device/port.ts
T
DanandClaude Fable 5.2 344a2288b8 Idle exit starts however the app was opened (0.1.2)
On a real G2 with build 0.1.1, a voice launch with nothing touched never
left the glasses: no glassesMenu launch source reached the app, so the
countdown was never armed. After one swipe it left as designed.

The countdown now runs however the session was opened. The launch source is
kept for Diagnostics only. Setting up on the phone stays protected: nothing
leaves while unpaired, and a touch on the phone page holds the app open for
the grace period. Dan approved the change after the trial.

Also records the 0.1.1 trial, Dan's keep/change decisions (contract
section F) and the 0.1.1 upload. Version 0.1.2. Not reviewed, not uploaded.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 15:34:20 -08:00

55 lines
2.7 KiB
TypeScript

import type { HudFrame } from '../core/hud.ts';
import type { DeviceEvent } from './events.ts';
export type StorageRead = { ok: true; value: string } | { ok: false };
/** Everything Hermeven needs from the glasses runtime. Implemented by the Even adapter and by test fakes. */
export interface DevicePort {
/** Create the HUD page. Resolves false when the host refused it. */
init(frame: HudFrame): Promise<boolean>;
/** Show a frame. Calls are serialised and coalesced; only the latest pending frame is sent. */
show(frame: HudFrame): void;
/** Open the glasses microphone. Resolves false when the host refused (for example no permission). */
startMic(): Promise<boolean>;
stopMic(): Promise<void>;
onEvent(listener: (event: DeviceEvent) => void): () => void;
onConnection(listener: (connected: boolean) => void): () => void;
/** Ask the OS to show its own exit confirmation. */
requestExit(): Promise<void>;
/**
* Leave the glasses now, with no confirmation, returning them to their normal screen. Used
* when the app has been idle: while it is open it occupies the display and (seen on a real
* G2) phone notifications do not reach the lenses.
*
* Resolves `true` ONLY when the host confirmed the exit. `false` covers a refusal, an error
* and a wait that ran out; the caller may try again. An implementation must never have two
* exit calls in flight, and must not call the host again after a confirmed exit.
*/
exitNow(): Promise<boolean>;
/**
* Optional, for Diagnostics: how this session was opened, when the host says. On a real G2 a
* voice launch was not reported as `glassesMenu`, so nothing may depend on it.
* The host sends this once, early. An implementation must remember it and replay it to a
* listener that subscribes later.
*/
onLaunchSource?(listener: (source: 'appMenu' | 'glassesMenu') => void): () => void;
/**
* Read a stored value. `{ ok: false }` means the host did not answer (or failed): the value
* is UNKNOWN, which is different from "nothing stored" (`{ ok: true, value: '' }`).
*/
storageGet(key: string): Promise<StorageRead>;
/**
* Store a value. Resolves `true` ONLY when the host positively confirmed the write.
* `false` covers a refusal, an error and a timeout; after a timeout the write may still
* land later, so `false` is "not confirmed", never "not written" and never "written".
*/
storageSet(key: string, value: string): Promise<boolean>;
/**
* Optional, for the phone's Diagnostics only: a one-line summary of what the glasses runtime
* has delivered (counts and event types; never audio or any content).
*/
inputSummary?(): string;
/** Optional: called whenever `inputSummary()` would change. */
onInputActivity?(listener: () => void): () => void;
}