fix: full review pass (main process, voice pipeline, Hermes client, HUD) and e2e-validated local voice (v2.1.0.1)

Electron main
- utility-process channel: sherpa output copied into V8 buffers (Electron rejects external
  buffers), audio exchanged as base64; worker restart on timeout, identity-safe exit handling,
  deterministic native unload by restart
- webhook: loopback by default without secret, UTF-8-safe body assembly, clean restart, port validation
- files IPC: realpath-based root check, openPath allow-list (reveal-only outside document folders),
  Windows reserved names; store: debounced async atomic writes with backup of corrupt files;
  logger: streaming writes with rotation; log message size cap
- HTTP stream proxy: socket released on idle timeout / renderer destroyed, id validation
- model manager: inactivity timeout, retrying rm/rename (Windows locks), engine stopped before
  replacing a model; WAV decoder handles float/24-bit; IPC payload validation
- window: opaque rounded window on Windows, navigation lock-down, visibility events;
  Ctrl+Alt+Escape instead of the Task Manager shortcut; single-instance guard; EVEFLOW_USER_DATA

Voice pipeline
- abort semantics (SendHandle.aborted), abort before the stream opens, session id prefixes per transport
- hands-free re-arm after replies without speech, start/stop race, no chime on auto re-arm,
  no silence shipped to STT (400 ms pre-roll), no transcription of empty manual stops
- TTS: bounded prefetch, cancellable segments, non-interrupting notices, volume applied at play time
- SSE CRLF split, usage in chat completions, finish_reason length, phonetic regex hoisted

HUD
- core renderer: no canvas shadows, cached colours, reusable spectrum buffer, theme read on change,
  30 fps idle, stops when the window is hidden; ping flashes on send / tool / speech
- deltas coalesced per animation frame; stable auto-scroll; narrow selectors everywhere
- bundled fonts (offline), reduce-motion fix, error toasts, ops drawer below 1180 px,
  interim transcript and first-token latency in the core caption, Ctrl+K, dialog semantics,
  switch/aria roles, compact widget cleanup, Whisper small recommended for French
- docs/ROADMAP.md: audit results, e2e results and the plan towards a real JARVIS

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Wn5VX9HNbJ7N54hR24u9Y
This commit is contained in:
Claude committed 2026-09-03 18:08:09 +00:00
1 parent b1b8d0d5d4
commit 5f0fa7a1e2
55 files changed
+1181 -433

No files matched your search

+45 -20
View File
@@ -261,6 +261,7 @@ export class HermesClient {
for (const event of normalizeLifecycleEvent(eventName, data)) onEvent(event);
});
const errorChunks: string[] = [];
let handleReady = false;
const handle = await httpStream(
{
url: `${this.base}${path}`,
@@ -271,7 +272,6 @@ export class HermesClient {
},
{ onChunk: (text) => (handleReady ? parser.feed(text) : errorChunks.push(text)) }
);
let handleReady = handle.start.ok;
if (!handle.start.ok) {
await handle.done.catch(() => undefined);
throw new HttpError(handle.start.status, errorMessage(handle.start.status, errorChunks.join('')));
@@ -285,25 +285,45 @@ export class HermesClient {
send(options: SendOptions, transport: ResolvedTransport): SendHandle {
const effective: ResolvedTransport = options.images?.length && transport === 'runs' ? 'completions' : transport;
let abort: () => void = () => undefined;
let aborted = false;
let abortImpl: () => void = () => undefined;
const setAbort = (fn: () => void) => {
abortImpl = fn;
if (aborted) fn();
};
const isAborted = () => aborted;
const result =
effective === 'runs'
? this.sendViaRuns(options, (fn) => (abort = fn))
? this.sendViaRuns(options, setAbort, isAborted)
: effective === 'sessions'
? this.sendViaSessions(options, (fn) => (abort = fn))
: this.sendViaCompletions(options, (fn) => (abort = fn));
return { result, abort: () => abort(), transport: effective };
? this.sendViaSessions(options, setAbort, isAborted)
: this.sendViaCompletions(options, setAbort, isAborted);
return {
result,
transport: effective,
get aborted() {
return aborted;
},
abort: () => {
aborted = true;
abortImpl();
}
};
}
private async sendViaRuns(options: SendOptions, setAbort: (fn: () => void) => void): Promise<string> {
private async sendViaRuns(options: SendOptions, setAbort: (fn: () => void) => void, isAborted: () => boolean): Promise<string> {
const { onEvent } = options;
const run = await this.startRun({
input: options.text,
session_id: options.sessionId || undefined,
session_id: plainSession(options.sessionId) || undefined,
instructions: this.config.instructions || undefined,
model: this.config.model || undefined
});
const runId = run.run_id;
if (isAborted()) {
this.stopRun(runId).catch(() => undefined);
return '';
}
onEvent({ kind: 'run.started', runId });
Log.info('hermes', `run ${runId} started`);
@@ -329,7 +349,7 @@ export class HermesClient {
});
await handle.done;
if (stopped) return streamedText;
if (stopped || isAborted()) return streamedText;
if (failure) throw new Error(failure);
if (!completed) {
@@ -349,7 +369,7 @@ export class HermesClient {
return finalText || streamedText;
}
private async sendViaSessions(options: SendOptions, setAbort: (fn: () => void) => void): Promise<string> {
private async sendViaSessions(options: SendOptions, setAbort: (fn: () => void) => void, isAborted: () => boolean): Promise<string> {
const { onEvent } = options;
let sessionId = options.sessionId;
if (!sessionId || !sessionId.startsWith('hs:')) {
@@ -357,6 +377,7 @@ export class HermesClient {
sessionId = `hs:${session.id}`;
onEvent({ kind: 'session', sessionId });
}
if (isAborted()) return '';
const realId = sessionId.slice(3);
const body: Rec = { input: options.text };
if (this.config.instructions) body.instructions = this.config.instructions;
@@ -374,11 +395,12 @@ export class HermesClient {
});
setAbort(() => handle.abort());
await handle.done;
if (isAborted()) return streamed;
if (failure) throw new Error(failure);
return finalText || streamed;
}
private async sendViaCompletions(options: SendOptions, setAbort: (fn: () => void) => void): Promise<string> {
private async sendViaCompletions(options: SendOptions, setAbort: (fn: () => void) => void, isAborted: () => boolean): Promise<string> {
const { onEvent } = options;
const useTools = this.config.localTools && !!options.localToolExecutor && !!options.localToolDefinitions?.length;
const messages: HermesChatMessage[] = [];
@@ -389,16 +411,13 @@ export class HermesClient {
: options.text;
messages.push({ role: 'user', content: userContent });
let aborted = false;
let currentHandle: StreamHandle | null = null;
setAbort(() => {
aborted = true;
currentHandle?.abort();
});
setAbort(() => currentHandle?.abort());
const aborted = () => isAborted();
let fullText = '';
let toolsAllowed = useTools;
for (let iteration = 0; iteration < 6 && !aborted; iteration++) {
for (let iteration = 0; iteration < 6 && !aborted(); iteration++) {
const payload: Rec = { model: this.config.model || 'hermes-agent', messages, stream: true };
if (toolsAllowed) {
payload.tools = options.localToolDefinitions;
@@ -428,7 +447,8 @@ export class HermesClient {
});
const headers = this.headers({ Accept: 'text/event-stream' });
if (options.sessionId) headers['X-Hermes-Session-Id'] = options.sessionId;
const sessionId = plainSession(options.sessionId);
if (sessionId) headers['X-Hermes-Session-Id'] = sessionId;
const handle = await httpStream(
{ url: `${this.base}/v1/chat/completions`, method: 'POST', headers, body: JSON.stringify(payload), timeoutMs: 10 * 60_000 },
{ onChunk: (text) => (ready ? parser.feed(text) : errorChunks.push(text)) }
@@ -454,7 +474,7 @@ export class HermesClient {
parser.end();
fullText += iterationText;
if (finishReason === 'tool_calls' && toolsAllowed && toolCalls.size > 0 && !aborted) {
if (finishReason === 'tool_calls' && toolsAllowed && toolCalls.size > 0 && !aborted()) {
const calls = [...toolCalls.values()];
messages.push({
role: 'assistant',
@@ -471,11 +491,16 @@ export class HermesClient {
}
break;
}
onEvent({ kind: 'completed', status: aborted ? 'cancelled' : 'completed', text: fullText });
onEvent({ kind: 'completed', status: aborted() ? 'cancelled' : 'completed', text: fullText });
return fullText;
}
}
/** Session ids created by the sessions transport carry an `hs:` prefix; other endpoints get the bare id. */
export function plainSession(id: string): string {
return id.startsWith('hs:') ? id.slice(3) : id;
}
export function normalizeJob(job: HermesJob): HermesJob {
const raw = job as Rec;
const id = String(raw.id ?? raw.job_id ?? raw.name ?? '');
+1
View File
@@ -212,6 +212,7 @@ export function normalizeCompletionChunk(
): { events: HermesStreamEvent[]; finishReason: string | null } {
const events: HermesStreamEvent[] = [];
if (!isRec(chunk)) return { events, finishReason: null };
if (isRec(chunk.usage)) events.push({ kind: 'completed', status: 'usage', usage: chunk.usage as HermesUsage });
const choice = Array.isArray(chunk.choices) && isRec(chunk.choices[0]) ? (chunk.choices[0] as Rec) : null;
if (!choice) return { events, finishReason: null };
const delta = isRec(choice.delta) ? (choice.delta as Rec) : isRec(choice.message) ? (choice.message as Rec) : null;
+3 -1
View File
@@ -167,8 +167,10 @@ export interface SendOptions {
}
export interface SendHandle {
/** Resolves with the final assistant text. */
/** Resolves with the final assistant text (partial text when aborted). */
result: Promise<string>;
abort: () => void;
/** True once abort() was called; the caller must not treat the result as a completed reply. */
readonly aborted: boolean;
transport: Exclude<HermesTransport, 'auto'>;
}