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
+32 -2
View File
@@ -151,13 +151,14 @@ describe('plain text', () => {
});
describe('HUD frames', () => {
const phases: Phase[] = ['unpaired', 'ready', 'listening', 'transcribing', 'thinking', 'approval', 'answer', 'error', 'disconnected', 'cancelled'];
const phases: Phase[] = ['unpaired', 'menu', 'ready', 'listening', 'transcribing', 'thinking', 'approval', 'answer', 'error', 'disconnected', 'cancelled'];
const variants = (phase: Phase): AppState[] => {
const base: AppState = { ...initialState, phase, captureStartedAt: 0, captureMaxSeconds: 120 };
if (phase === 'answer') {
return [
{ ...base, pages: ['x'], pageIndex: 0 },
{ ...base, pages: Array(99).fill('x'), pageIndex: 98, partial: true },
{ ...base, pages: Array(99).fill('x'), pageIndex: 98, partial: true, wakeListening: true, agents: [{ id: 'default', name: 'Pepper' }, { id: 'natalie', name: 'Natalie' }], agentId: 'natalie' },
];
}
if (phase === 'disconnected') {
@@ -172,9 +173,24 @@ describe('HUD frames', () => {
return [
{ ...base, error: { code: 'outcome_unknown', hud: 'The outcome is unknown. Check the agent before asking again.', retryable: false } },
{ ...base, error: { code: 'agent_timeout', hud: 'The agent ran out of time and was stopped. Actions it had already taken are not undone.', retryable: true } },
{ ...base, wakeListening: true, error: { code: 'agent_timeout', hud: 'The agent ran out of time and was stopped.', retryable: true } },
];
}
if (phase === 'ready') return [base, { ...base, notice: 'New conversation' }];
// Listening for a name: sixteen agents with the longest names allowed, and none.
const many = Array.from({ length: 16 }, (_, i) => ({ id: `a${i}`, name: 'Wwwwwwwwwwwwwwwwwwwwwwww' }));
const few = [
{ id: 'default', name: 'Pepper' },
{ id: 'wendy', name: 'Wendy' },
{ id: 'cody', name: 'Cody' },
];
const wake = { wakeListening: true };
if (phase === 'menu') return [base, { ...base, handsFree: true }, { ...base, handsFree: true, menuIndex: 1 }];
if (phase === 'ready') {
return [{ ...base, menu: true }, { ...base, menu: true, ...wake, agents: few }, base, { ...base, notice: 'New conversation' }, { ...base, ...wake }, { ...base, ...wake, agents: few }, { ...base, ...wake, agents: many }, { ...base, ...wake, agents: few, notice: 'New conversation' }];
}
if (phase === 'listening') return [base, { ...base, captureAuto: true }, { ...base, captureAuto: true, agents: few }];
if (phase === 'thinking') return [base, { ...base, heard: 'W'.repeat(4000) }, { ...base, agents: few, heard: 'What is on my calendar tomorrow?' }];
if (phase === 'cancelled') return [base, { ...base, ...wake }];
if (phase === 'unpaired') return [base, { ...base, storageFault: true }];
return [base];
};
@@ -201,6 +217,20 @@ describe('HUD frames', () => {
}
});
it('an open microphone at rest is always marked, and never claimed while it is closed', () => {
for (const phase of ['ready', 'answer', 'error', 'cancelled'] as Phase[]) {
const state: AppState = { ...initialState, phase, pages: ['x'] };
expect(renderHud({ ...state, wakeListening: true }, 0).status.startsWith('● ')).toBe(true);
expect(renderHud(state, 0).status).not.toContain('●');
}
// In flight the microphone is closed, whatever the flag last said.
for (const phase of ['transcribing', 'thinking', 'approval', 'disconnected', 'unpaired'] as Phase[]) {
expect(renderHud({ ...initialState, phase, wakeListening: true }, 0).status).not.toContain('●');
}
const ready = renderHud({ ...initialState, phase: 'ready', wakeListening: true, agents: [{ id: 'default', name: 'Pepper' }, { id: 'wendy', name: 'Wendy' }] }, 0);
expect(ready.body).toBe('Pepper\n\nListening. Say a name, then your question:\nPepper · Wendy');
});
it('errors offer a recovery action and send detail to the phone', () => {
const frame = renderHud({ ...initialState, phase: 'error', error: { code: 'stt_empty', hud: 'No speech was recognised.', retryable: true } }, 0);
expect(frame.body).toContain('No speech was recognised.');