Opening menu and hands-free mode: call an agent by name (0.3.0)

The app now opens on a menu, which is the root page: "Hands free" first,
"Agents" second. Agents is the 0.2.0 app unchanged. Hands free is the same
agents, conversations and question path with one flag set: the microphone
listens while the app is at rest and the app does not leave by itself.
The mode is never remembered; every launch starts at the menu with the
microphone closed, and double tap at Ready returns to the menu and closes
it.

Client: a loudness-only speech segmenter (core/vad.ts) cuts the stream
into utterances; each goes to the bridge for a wake check. "Wendy, <q>"
becomes a text turn to Wendy, with what was heard shown while she works.
A name alone starts a recording that sends itself when the speaker stops.
The status line starts with a dot for exactly as long as the microphone is
open at rest. In wake mode every microphone open and close goes through
one serialised reconciler; without the option the old path is untouched.

Bridge: POST /v1/wake transcribes one utterance in memory and reports
whether it BEGAN with an agent's name (first word of the display name, or
an alias from HERMEVEN_AGENT_<ID>_WAKE). Exact match only; a near miss is
reported as one word and never acted on. Creates no turn, stores nothing,
returns and logs nothing that was not addressed to an agent. One check at
a time per device, HERMEVEN_WAKE_CHECKS_PER_MINUTE (30).

Docs: decision 0004, bridge API, security gaps 3c/3d, device plan D.
The manifest's microphone description changed.

Not reviewed, not deployed, not uploaded, not device-tested.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Dan
2026-11-28 10:52:06 -08:00
co-authored by Claude Fable 5.2
parent 75b7ea1eff
commit e1d183b54d
26 changed files with 1847 additions and 48 deletions
+61 -13
View File
@@ -1,4 +1,4 @@
import { currentAgent, type AppState } from './reducer.ts';
import { currentAgent, menuItems, MODE_LABEL, type AppState } from './reducer.ts';
/**
* HUD geometry. Canvas size and line height are documented by Even
@@ -41,8 +41,37 @@ function clock(seconds: number): string {
return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`;
}
/** The longest question shown back while the agent works; the rest is on the phone. */
const HEARD_MAX = 160;
/** Shown in the status bar for as long as the microphone is open at rest. */
export const MIC_OPEN = '● ';
/**
* The names to call, as they are said: the first word of each agent's name. As many as fit
* comfortably; the rest are still reachable by swiping.
*/
function callNames(state: AppState): string {
const names: string[] = [];
let used = 0;
for (const { name } of state.agents) {
const word = name.trim().split(/\s+/)[0] ?? name;
if (names.length > 0 && used + word.length > 80) return `${names.join(' · ')} …`;
names.push(word);
used += word.length + 3;
}
return names.join(' · ');
}
/** Pure: the complete HUD text for a state at a moment in time. */
export function renderHud(state: AppState, nowMs: number): HudFrame {
const frame = renderFrame(state, nowMs);
// The microphone is open and listening for a name: every resting screen says so.
const resting = state.phase === 'ready' || state.phase === 'answer' || state.phase === 'error' || state.phase === 'cancelled';
return state.wakeListening && resting ? { body: frame.body, status: `${MIC_OPEN}${frame.status}` } : frame;
}
function renderFrame(state: AppState, nowMs: number): HudFrame {
// With more than one agent on offer, every screen of an exchange says who it is with.
const agent = state.agents.length > 1 ? currentAgent(state) : undefined;
switch (state.phase) {
@@ -55,21 +84,34 @@ export function renderHud(state: AppState, nowMs: number): HudFrame {
}
return { body: 'Hermeven\n\nNot connected.\nOpen Hermeven on your phone to pair.', status: 'Double-tap: exit' };
case 'ready':
if (agent) {
return {
body: state.notice ? `${agent.name}\n\n${state.notice}.` : `${agent.name}\n\nReady.`,
status: 'Tap: ask · Swipe: agent · 2×: exit',
};
case 'menu': {
// Plain ASCII marker: the firmware font silently drops characters it does not have.
const lines = menuItems(state).map((mode, i) => `${i === state.menuIndex ? '>' : ' '} ${MODE_LABEL[mode]}`);
return { body: `Hermeven\n\n${lines.join('\n')}`, status: lines.length > 1 ? 'Tap: open · Swipe: move · 2×: exit' : 'Tap: open · Double-tap: exit' };
}
case 'ready': {
// With a menu, double tap goes back to it; without one it leaves the app.
const out = state.menu ? 'menu' : 'exit';
const status = agent ? `Tap: ask · Swipe: agent · 2×: ${out}` : `Tap: ask · Double-tap: ${out}`;
if (state.wakeListening && !state.notice) {
return agent
? { body: `${agent.name}\n\nListening. Say a name, then your question:\n${callNames(state)}`, status }
: { body: 'Hermeven\n\nListening. Say your agent’s name, then your question.', status };
}
return {
body: state.notice ? `Hermeven\n\n${state.notice}.` : 'Hermeven\n\nReady.',
status: 'Tap: ask · Double-tap: exit',
};
if (agent) return { body: state.notice ? `${agent.name}\n\n${state.notice}.` : `${agent.name}\n\nReady.`, status };
return { body: state.notice ? `Hermeven\n\n${state.notice}.` : 'Hermeven\n\nReady.', status };
}
case 'listening': {
const elapsed = state.captureStartedAt === null ? 0 : (nowMs - state.captureStartedAt) / 1000;
const cap = state.captureMaxSeconds;
if (state.captureAuto) {
return {
body: `${agent ? `${agent.name} is listening…` : 'Listening…'}\n\nAsk your question. It is sent when you stop speaking.`,
status: `● REC ${clock(elapsed)} / ${clock(cap)} · Tap: send · 2×: cancel`,
};
}
return {
body: `${agent ? `${agent.name} is listening…` : 'Listening…'}\n\nRecording stops by itself after ${cap} seconds.`,
status: `● REC ${clock(elapsed)} / ${clock(cap)} · Tap or release: send · 2×: cancel`,
@@ -79,8 +121,14 @@ export function renderHud(state: AppState, nowMs: number): HudFrame {
case 'transcribing':
return { body: 'Transcribing…', status: 'Double-tap: cancel' };
case 'thinking':
return { body: agent ? `${agent.name} is thinking…` : 'Thinking…', status: 'Double-tap: cancel' };
case 'thinking': {
const title = agent ? `${agent.name} is thinking…` : 'Thinking…';
if (!state.heard) return { body: title, status: 'Double-tap: cancel' };
// Asked by voice with nothing pressed: show what was understood, so a mishearing is seen
// while it can still be cancelled.
const heard = state.heard.length > HEARD_MAX ? `${state.heard.slice(0, HEARD_MAX - 1).trimEnd()}…` : state.heard;
return { body: `${title}\n\nHeard: ${heard}`, status: 'Double-tap: cancel' };
}
case 'approval':
return {