Compare commits

...
7 Commits
Author SHA1 Message Date
LogiFlow 1ea3df2ad1 Merge pull request #24 from R0m1k3/claude/hermes-context-loss-fayw61
fix: keep Hermes session across runs and speak long replies as a digest (2.5.4)
2026-09-05 11:08:12 +02:00
Claude dc491e59c3 Merge origin/main into claude/hermes-context-loss-fayw61 (2.5.4)
Keeps main's neutral default instructions (assistant name now comes from the
settings) together with the new guidance on long replies and continuity;
bumps to 2.5.4 since main already published 2.5.3.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ln4KL1feHtnV4nee4sZFhM
2026-09-05 08:24:29 +00:00
Claude c2aef4cbc7 fix: keep Hermes session across runs and speak long replies as a digest (2.5.3)
Over the runs transport Hermes never reports the session it attached to a
run in the SSE stream, only in GET /v1/runs/{id}. EveFlow only read it in the
polling fallback, so the locally generated id was sent again and again and
each message opened a fresh Hermes session, losing the conversation context.
The client now adopts the run's session id after every run.

Long answers are now spoken as a digest: the first sentences (configurable,
4 by default) plus the closing question, followed by a short notice that the
full text is on screen. The default instructions ask Hermes to open long
replies with the essentials and to rely on the ongoing conversation.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ln4KL1feHtnV4nee4sZFhM
2026-09-05 08:22:48 +00:00
Michael 992693c9cf fix: use configurable assistant name in all Hermes conversations (2.5.3) 2026-09-05 09:39:06 +02:00
LogiFlow 5991410685 Merge pull request #23 from R0m1k3/main
Main
2026-09-05 09:18:23 +02:00
Michael 9f95f79943 ci: publish Windows releases from main 2026-09-05 09:18:06 +02:00
Michael c9b44433ac fix: discover actual Hermes provider models and route selections (2.5.2) 2026-09-05 09:06:36 +02:00
18 changed files with 369 additions and 42 deletions

No files matched your search

+1 -1
View File
@@ -67,7 +67,7 @@ jobs:
out/latest.yml
if-no-files-found: error
- name: Publish GitHub release
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/master' && steps.ver.outputs.released == 'false')
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') && steps.ver.outputs.released == 'false')
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.ver.outputs.version }}
+1
View File
@@ -29,6 +29,7 @@ La version 2 est une réécriture complète : plus de robot 3D, un pipeline voca
* **Serveur MCP intégré** : Hermes se connecte à `http://<pc>:7842/mcp` et obtient les outils du PC (capture d'écran renvoyée en image, verrouillage, applications, URL, touches média, presse-papiers, recherche de fichiers, voix, notifications, état du HUD, affichage dans le fil). Même port et même secret que le webhook ; en mode chat completions, les mêmes outils sont proposés directement au modèle.
* **Heures calmes et priorités** : plage horaire pendant laquelle les messages poussés s'affichent sans être lus ni faire clignoter le noyau (badge « non lus » à la place), thème nuit automatique, mots prioritaires lus quand même, résumé vocal des rapports longs (les premières phrases seulement).
* **Mode mission** : un bouton dans la barre de commande bascule sur un second modèle Hermes (plus puissant) pour les tâches longues ; le modèle rapide reste utilisé pour la conversation courante.
* **Résumé vocal des réponses longues** : seules les premières phrases (réglable) et la question finale sont lues, le reste s'affiche dans le fil ; la conversation Hermes est continue d'un message à l'autre (la session créée par Hermes est reprise à chaque run).
* **Widget compact « glanceable »** : état (veille, écoute, réflexion, parle), dernière phrase de l'assistant, badge de non-lus, indicateurs heures calmes et mission.
* **Voix Microsoft Edge** (moteur par défaut) : les voix neuronales de la lecture à voix haute d'Edge, gratuites, sans clé ni installation : Henri, Denise, Rémy, Vivienne, Éloise (fr-FR) et les voix fr-CA, fr-CH, fr-BE, plus de 300 voix dans 74 langues. Le rendu le plus naturel disponible ; nécessite une connexion.
* **Voix JARVIS** : deux préréglages en un clic (Paramètres → Voix) : en ligne (Edge Henri) ou hors ligne (Supertonic 3, voix masculine grave, téléchargé automatiquement), timbre « JARVIS » (légèrement plus grave et posé, chaleur, présence, courte réverbération d'intercom), débit calme.
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "eveflow",
"version": "2.5.1",
"version": "2.5.4",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "eveflow",
"version": "2.5.1",
"version": "2.5.4",
"license": "MIT",
"dependencies": {
"@fontsource/orbitron": "^5.3.0",
+2 -2
View File
@@ -1,7 +1,7 @@
{
"name": "eveflow",
"version": "2.5.1",
"releaseVersion": "2.5.1",
"version": "2.5.4",
"releaseVersion": "2.5.4",
"description": "JARVIS-style desktop HUD for Hermes Agent: voice, streaming runs, scheduled jobs, skills and telemetry",
"main": "dist-electron/main.js",
"private": true,
+1 -1
View File
@@ -15,7 +15,7 @@ export function ModelSelect({ label, value, models, defaultLabel, onChange }: {
<select id={id} className="select" value={value} onChange={(e) => onChange(e.target.value)}>
<option value="">{defaultLabel}</option>
{value && !models.some((m) => m.id === value) && <option value={value}>{value} (configuré)</option>}
{models.map((m) => <option key={m.id} value={m.id}>{m.id}{m.provider || m.owned_by ? ` · ${m.provider || m.owned_by}` : ''}</option>)}
{models.map((m) => <option key={m.id} value={m.id} disabled={m.available === false}>{m.name || m.id}{m.provider || m.owned_by ? ` · ${m.provider || m.owned_by}` : ''}{m.available === false ? ' (indisponible)' : ''}</option>)}
</select>
<button type="button" className="btn small" aria-expanded={manual} onClick={() => setManual(!manual)}>
{manual ? 'Masquer la saisie manuelle' : 'Saisir un autre identifiant'}
+13 -4
View File
@@ -81,6 +81,7 @@ export function SettingsDrawer({ onClose }: Props) {
const hermesModels = useHermes((s) => s.models);
const modelsLoading = useHermes((s) => s.modelsLoading);
const modelsError = useHermes((s) => s.modelsError);
const modelsNotice = useHermes((s) => s.modelsNotice);
const refreshHermesModels = useHermes((s) => s.refreshModels);
const hermesWebhook = useHermes((s) => s.webhook);
const hermesConnect = useHermes((s) => s.connect);
@@ -224,12 +225,12 @@ export function SettingsDrawer({ onClose }: Props) {
</div>
</div>
<div className="field">
<button className="btn small" disabled={modelsLoading} onClick={() => void refreshHermesModels()}>
<button className="btn small" disabled={modelsLoading} onClick={() => void refreshHermesModels(true)}>
{modelsLoading ? <Loader2 size={13} className="spin" /> : <RotateCcw size={13} />}
{modelsLoading ? 'Chargement des modèles…' : 'Actualiser les modèles'}
</button>
<span className="hint" role="status">{modelsLoading ? 'Interrogation du serveur Hermes…' : modelsError || (hermesModels.length ? `${hermesModels.length} modèle(s) disponible(s).` : 'Aucun modèle annoncé par le serveur.')}</span>
<span className="hint">Cette liste contient les modèles exposés par votre serveur Hermes. Si seul « hermes-agent » apparaît, les autres modèles doivent être configurés et exposés côté serveur.</span>
<span className={modelsNotice ? 'test-result fail' : 'hint'}>{modelsNotice || 'Modèles des fournisseurs configurés dans Hermes. Les modèles sans accès sont indiqués comme indisponibles.'}</span>
</div>
<div className="grid-2">
<div className="field">
@@ -556,6 +557,13 @@ export function SettingsDrawer({ onClose }: Props) {
</div>
</div>
<Toggle on={settings.speech.autoSpeak} onChange={(v) => update({ speech: { autoSpeak: v } })} label="Lire les réponses en streaming" hint="Chaque phrase est prononcée dès qu’elle est complète." />
<Toggle on={settings.speech.summarizeReplies} onChange={(v) => update({ speech: { summarizeReplies: v } })} label="Résumé vocal des réponses longues" hint="Seules les premières phrases et la question finale sont lues ; la réponse complète reste dans le fil." />
{settings.speech.summarizeReplies && (
<div className="field">
<label>Phrases lues : {settings.speech.replySentences}</label>
<input className="range" type="range" min={1} max={10} step={1} value={settings.speech.replySentences} onChange={(e) => update({ speech: { replySentences: Number(e.target.value) } })} />
</div>
)}
<Toggle on={settings.speech.speakIncoming} onChange={(v) => update({ speech: { speakIncoming: v } })} label="Lire les messages entrants (webhook, crons)" />
<div className="row" style={{ marginTop: 10 }}>
<button className="btn small" onClick={testTts} disabled={settings.speech.provider === 'off'}><Volume2 size={13} /> Tester la voix</button>
@@ -637,8 +645,9 @@ mcp_servers:
<div className="card">
<div className="grid-2">
<div className="field">
<label>Nom de l’assistant</label>
<input className="input" value={settings.assistantName} onChange={(e) => update({ assistantName: e.target.value.toUpperCase().slice(0, 18) || 'JARVIS' })} />
<label htmlFor="assistant-name">Nom de l’assistant</label>
<input id="assistant-name" className="input" value={settings.assistantName} maxLength={60} placeholder="Jarvis, Nova, Alfred…" onChange={(e) => update({ assistantName: e.target.value })} onBlur={() => update({ assistantName: settings.assistantName.trim() || DEFAULT_SETTINGS.assistantName })} />
<span className="hint">Choisissez le nom que vous voulez. Il est sauvegardé automatiquement et utilisé par l’assistant dès votre prochain message, y compris dans la conversation en cours.</span>
</div>
<div className="field">
<label>Votre nom</label>
+27
View File
@@ -129,6 +129,33 @@ export function chunkForSpeech(text: string, maxLength = 220): string[] {
return out;
}
/** Last speakable chunk of a reply when it is a question (« Tu veux que je… ? »), else null. */
export function closingQuestion(text: string): string | null {
const parts = speakableChunks(text);
const last = parts[parts.length - 1];
return last && /\?\s*$/.test(last) ? last : null;
}
/** Chunks of the spoken form of a text (markdown and code already stripped), letters only. */
function speakableChunks(text: string): string[] {
return chunkForSpeech(cleanForSpeech(text)).filter((part) => /[\p{L}\p{N}]/u.test(part));
}
/**
* Spoken digest of a long reply: the first `maxSentences` speakable chunks plus the closing
* question when there is one, so a long answer stays short to listen to but the conversation
* can go on. `truncated` tells the caller that the screen holds more than what is spoken.
*/
export function spokenDigest(text: string, maxSentences: number): { text: string; truncated: boolean } {
const parts = speakableChunks(text);
const limit = Math.max(1, Math.floor(maxSentences));
if (parts.length <= limit) return { text: parts.join(' '), truncated: false };
const head = parts.slice(0, limit);
const question = closingQuestion(text);
if (question && !head.includes(question)) head.push(question);
return { text: head.join(' '), truncated: true };
}
export function previewText(value: string, max = 96): string {
const flat = value.replace(/\s+/g, ' ').trim();
return flat.length > max ? `${flat.slice(0, max - 1)}…` : flat;
+2 -2
View File
@@ -269,8 +269,8 @@ export async function sendMessage(text: string, images: string[] = [], source =
if (handle.aborted) {
speech.discardStream();
} else if (settings.speech.autoSpeak) {
if (!streamedText && finalText) speech.say(finalText);
else speech.endStream();
if (!streamedText && finalText) speech.sayReply(finalText);
else speech.endStream(finalText);
} else {
speech.discardStream();
}
+50 -4
View File
@@ -31,6 +31,13 @@ const isRec = (v: unknown): v is Rec => !!v && typeof v === 'object' && !Array.i
export type ResolvedTransport = Exclude<HermesTransport, 'auto'>;
/** Stored picker IDs include the provider so identical model names remain distinct. */
export function modelSelection(value: string): { model?: string; provider?: string } {
const id = value.trim();
const separator = id.indexOf('::');
return separator > 0 ? { provider: id.slice(0, separator), model: id.slice(separator + 2) } : id ? { model: id } : {};
}
/**
* A web page (login portal, dashboard, reverse-proxy error) instead of JSON means the URL does not
* point at the Hermes API. Returns a human explanation, or null when the body is not HTML.
@@ -217,6 +224,29 @@ export class HermesClient {
return [...models.values()];
}
async modelCatalog(refresh = false): Promise<{ models: HermesModel[]; notice: string | null }> {
let payload: unknown;
try {
payload = await this.request<unknown>(`/api/model/options${refresh ? '?refresh=true' : ''}`, { timeoutMs: 30_000 });
} catch (err) {
if (!(err instanceof HttpError) || ![404, 405].includes(err.status)) throw err;
return { models: await this.models(), notice: 'Ce serveur ne propose pas le catalogue IA (/api/model/options). Mettez Hermes à jour pour choisir le fournisseur et son modèle. La liste ci-dessous contient uniquement les alias de connexion.' };
}
if (!isRec(payload) || !Array.isArray(payload.providers)) throw new Error('Catalogue IA Hermes invalide : liste des fournisseurs absente.');
const models = new Map<string, HermesModel>();
for (const row of payload.providers) {
if (!isRec(row) || typeof row.slug !== 'string' || !row.slug.trim() || !Array.isArray(row.models)) continue;
const unavailable = Array.isArray(row.unavailable_models) ? row.unavailable_models : [];
for (const model of row.models) {
if (typeof model !== 'string' || !model.trim()) continue;
const id = `${row.slug}::${model}`;
models.set(id, { id, name: model, provider: typeof row.name === 'string' ? row.name : row.slug,
available: row.authenticated !== false && !unavailable.includes(model) });
}
}
return { models: [...models.values()], notice: null };
}
async skills(): Promise<HermesSkill[]> {
const payload = await this.request<unknown>('/v1/skills');
return extractArray<HermesSkill>(payload, ['skills', 'data', 'items']);
@@ -304,11 +334,12 @@ export class HermesClient {
// ── Runs ──────────────────────────────────────────────────────────────────
async startRun(body: { input: string; session_id?: string; instructions?: string; model?: string }): Promise<{ run_id: string; status: string }> {
async startRun(body: { input: string; session_id?: string; instructions?: string; model?: string; provider?: string }): Promise<{ run_id: string; status: string }> {
const payload: Rec = { input: body.input };
if (body.session_id) payload.session_id = body.session_id;
if (body.instructions) payload.instructions = body.instructions;
if (body.model) payload.model = body.model;
if (body.provider) payload.provider = body.provider;
return this.request<{ run_id: string; status: string }>('/v1/runs', { method: 'POST', body: payload, timeoutMs: 30_000 });
}
@@ -402,7 +433,7 @@ export class HermesClient {
input: options.text,
session_id: plainSession(options.sessionId) || undefined,
instructions: this.config.instructions || undefined,
model: this.config.model || undefined
...modelSelection(this.config.model)
});
const runId = run.run_id;
if (isAborted()) {
@@ -416,6 +447,7 @@ export class HermesClient {
let finalText = '';
let streamedText = '';
let completed = false;
let sessionSeen = false;
let failure: string | null = null;
const handle = await this.streamRunEvents(runId, (event) => {
@@ -424,6 +456,7 @@ export class HermesClient {
completed = true;
finalText = event.text ?? '';
}
if (event.kind === 'session') sessionSeen = true;
if (event.kind === 'error') failure = event.message;
onEvent(event);
});
@@ -434,6 +467,9 @@ export class HermesClient {
});
await handle.done;
// The run events never carry the session id; only the run status does. Without adopting it,
// every message would start a fresh Hermes session and the conversation would lose its context.
if (!sessionSeen) await this.adoptRunSession(runId, onEvent);
if (stopped || isAborted()) return streamedText;
if (failure) throw new Error(failure);
@@ -454,6 +490,16 @@ export class HermesClient {
return finalText || streamedText;
}
/** Reads the session Hermes actually attached to a run and reports it, so the next run continues it. */
private async adoptRunSession(runId: string, onEvent: SendOptions['onEvent']): Promise<void> {
try {
const info = await this.getRun(runId);
if (info.session_id) onEvent({ kind: 'session', sessionId: String(info.session_id) });
} catch (err) {
Log.warn('hermes', `run ${runId}: session id unavailable (${(err as Error).message})`);
}
}
private async sendViaSessions(options: SendOptions, setAbort: (fn: () => void) => void, isAborted: () => boolean): Promise<string> {
const { onEvent } = options;
let sessionId = options.sessionId;
@@ -466,7 +512,7 @@ export class HermesClient {
const realId = sessionId.slice(3);
const body: Rec = { input: options.text };
if (this.config.instructions) body.instructions = this.config.instructions;
if (this.config.model) body.model = this.config.model;
Object.assign(body, modelSelection(this.config.model));
let streamed = '';
let finalText = '';
@@ -503,7 +549,7 @@ export class HermesClient {
let fullText = '';
let toolsAllowed = useTools;
for (let iteration = 0; iteration < 6 && !aborted(); iteration++) {
const payload: Rec = { model: this.config.model || 'hermes-agent', messages, stream: true };
const payload: Rec = { model: 'hermes-agent', ...modelSelection(this.config.model), messages, stream: true };
if (toolsAllowed) {
payload.tools = options.localToolDefinitions;
payload.tool_choice = 'auto';
+2
View File
@@ -35,6 +35,8 @@ export interface HermesHealth {
export interface HermesModel {
id: string;
name?: string;
available?: boolean;
owned_by?: string;
provider?: string;
[key: string]: unknown;
+56 -7
View File
@@ -1,16 +1,23 @@
/**
* Singleton facade over the TTS engine bound to the settings store, exposing speaking state
* to the voice and chat stores.
* to the voice and chat stores. Long replies are spoken as a digest (first sentences plus the
* closing question) so listening stays short while the full text remains on screen.
*/
import { useChat } from '../../state/chat';
import { useSettings } from '../../state/settings';
import { useVoice } from '../../state/voice';
import { chunkForSpeech, closingQuestion, extractSentences, spokenDigest } from '../../lib/text';
import { TtsEngine } from './tts';
export const DIGEST_NOTICE = 'Le détail complet est affiché à l’écran.';
class SpeechFacade {
private engine: TtsEngine | null = null;
private streaming = false;
private streamEnabled = true;
private streamBuffer = '';
private spokenCount = 0;
private truncated = false;
private get tts(): TtsEngine {
if (!this.engine) {
@@ -35,32 +42,74 @@ class SpeechFacade {
return this.engine?.isActive ?? false;
}
/** Number of spoken chunks allowed for one reply; unbounded when the digest is off. */
private replyLimit(): number {
const { summarizeReplies, replySentences } = useSettings.getState().settings.speech;
return summarizeReplies ? Math.max(1, Math.floor(replySentences || 1)) : Number.POSITIVE_INFINITY;
}
say(text: string, options: { interrupt?: boolean } = {}): void {
if (useSettings.getState().settings.speech.provider === 'off') return;
// While an answer streams, spoken notices are inserted without discarding the rest.
this.tts.speak(text, { interrupt: options.interrupt ?? !this.streaming });
}
/** Speak a finished (non-streamed) assistant reply, digested when it is long. */
sayReply(text: string): void {
const limit = this.replyLimit();
if (!Number.isFinite(limit)) return this.say(text);
const digest = spokenDigest(text, limit);
this.say(digest.truncated ? `${digest.text} ${DIGEST_NOTICE}` : digest.text);
}
pushStream(delta: string): void {
if (!useSettings.getState().settings.speech.autoSpeak) return;
this.streaming = true;
if (this.streamEnabled) this.tts.pushStream(delta);
if (!this.streamEnabled) return;
this.streamBuffer += delta;
const { sentences, rest } = extractSentences(this.streamBuffer);
this.streamBuffer = rest;
for (const sentence of sentences) this.enqueueWithinLimit(sentence);
}
endStream(): void {
if (this.streaming) this.tts.endStream();
this.streaming = false;
private enqueueWithinLimit(text: string): void {
if (this.truncated) return;
if (this.spokenCount >= this.replyLimit()) {
this.truncated = true;
return;
}
if (this.tts.enqueue(text)) this.spokenCount++;
}
/** Flush a streamed reply; `fullText` lets a digested reply end with its closing question. */
endStream(fullText = ''): void {
if (!this.streaming) return;
const rest = this.streamBuffer.trim();
if (rest) for (const chunk of chunkForSpeech(rest)) this.enqueueWithinLimit(chunk);
if (this.truncated) {
const question = closingQuestion(fullText);
if (question) this.tts.enqueue(question);
this.tts.enqueue(DIGEST_NOTICE);
}
this.resetStream();
}
discardStream(): void {
this.streaming = false;
this.resetStream();
this.tts.stop();
}
stop(): void {
this.streaming = false;
this.resetStream();
this.engine?.stop();
}
private resetStream(): void {
this.streaming = false;
this.streamBuffer = '';
this.spokenCount = 0;
this.truncated = false;
}
}
export const speech = new SpeechFacade();
+4 -2
View File
@@ -115,12 +115,14 @@ export class TtsEngine {
if (rest) for (const chunk of chunkForSpeech(rest)) this.enqueue(chunk);
}
enqueue(text: string): void {
/** Queue one chunk; false when nothing speakable remains once markdown and code are stripped. */
enqueue(text: string): boolean {
const item = this.makeItem(text);
if (!item) return;
if (!item) return false;
this.queue.push(item);
this.fillPrefetch();
void this.drain();
return true;
}
private makeItem(text: string): QueueItem | null {
+13 -9
View File
@@ -35,7 +35,8 @@ interface HermesStore {
models: HermesModel[];
modelsLoading: boolean;
modelsError: string | null;
refreshModels: () => Promise<void>;
modelsNotice: string | null;
refreshModels: (refresh?: boolean) => Promise<void>;
skills: HermesSkill[];
toolsets: HermesToolset[];
sessions: HermesSession[];
@@ -93,6 +94,7 @@ export const useHermes = create<HermesStore>((set, get) => ({
models: [],
modelsLoading: false,
modelsError: null,
modelsNotice: null,
skills: [],
toolsets: [],
sessions: [],
@@ -106,10 +108,12 @@ export const useHermes = create<HermesStore>((set, get) => ({
busy: false,
client: (modelOverride) => {
const config = useSettings.getState().settings.hermes;
// Without an explicit model, use the alias advertised by /v1/models (Hermes rejects unknown names).
const model = (modelOverride ?? '').trim() || config.model.trim() || get().models[0]?.id || '';
return new HermesClient({ ...config, model });
const settings = useSettings.getState().settings;
const config = settings.hermes;
const model = (modelOverride ?? '').trim() || config.model.trim();
const name = settings.assistantName.trim() || 'JARVIS';
const identity = `Identité de l'assistant dans cette conversation : ton nom est ${JSON.stringify(name)}. Utilise ce nom pour te présenter et parler de toi. EveFlow est le nom de l'application, pas ton nom. Cette identité remplace les anciens noms ou personas présents dans l'historique, la mémoire ou les instructions précédentes. Ne rappelle pas ton nom dans chaque réponse.`;
return new HermesClient({ ...config, model, instructions: [config.instructions.trim(), identity].filter(Boolean).join('\n\n') });
},
connect: () => {
@@ -166,17 +170,17 @@ export const useHermes = create<HermesStore>((set, get) => ({
return connectInflight;
},
refreshModels: async () => {
refreshModels: async (refresh = false) => {
const request = ++modelsRequest;
const config = useSettings.getState().settings.hermes;
const current = () => {
const now = useSettings.getState().settings.hermes;
return request === modelsRequest && now.url === config.url && now.apiKey === config.apiKey && now.sessionKey === config.sessionKey;
};
set({ models: [], modelsLoading: true, modelsError: null });
set({ models: [], modelsLoading: true, modelsError: null, modelsNotice: null });
try {
const models = await new HermesClient(config).models();
if (current()) set({ models });
const { models, notice } = await new HermesClient(config).modelCatalog(refresh);
if (current()) set({ models, modelsNotice: notice });
} catch (err) {
if (current()) set({ modelsError: (err as Error).message });
} finally {
+7 -2
View File
@@ -33,6 +33,9 @@ export interface VoiceSettings extends SttConfig {
export interface SpeechSettings extends TtsConfig {
autoSpeak: boolean;
speakIncoming: boolean;
/** Speak only the first sentences (and the closing question) of long replies; the full text stays on screen. */
summarizeReplies: boolean;
replySentences: number;
}
export interface WebhookSettings {
@@ -89,7 +92,7 @@ export const DEFAULT_SETTINGS: Settings = {
transport: 'auto',
reasoningEffort: '',
instructions:
"Tu es l'interface vocale EveFlow (style JARVIS). Réponds en français, de façon concise et orale quand la question est simple; utilise le Markdown uniquement pour le contenu structuré (code, listes, tableaux). Les images doivent être des URL http(s) ou des fichiers du dossier partagé.",
"Réponds en français, de façon concise et orale quand la question est simple; si la réponse est longue, commence par une ou deux phrases qui en donnent l'essentiel, puis le détail. Tu es dans une conversation continue : tiens compte des échanges précédents sans redemander ce qui a déjà été dit. Utilise le Markdown uniquement pour le contenu structuré (code, listes, tableaux). Les images doivent être des URL http(s) ou des fichiers du dossier partagé.",
localTools: true,
missionModel: ''
},
@@ -133,7 +136,9 @@ export const DEFAULT_SETTINGS: Settings = {
voiceGender: 'male',
timbre: 'jarvis',
autoSpeak: true,
speakIncoming: true
speakIncoming: true,
summarizeReplies: true,
replySentences: 4
},
webhook: { enabled: true, port: 7842, secret: '' },
notifications: { quietEnabled: false, quietStart: '22:30', quietEnd: '07:30', priorityKeywords: 'urgent, alerte, alarme, panne', summarizeIncoming: true, summarySentences: 2, nightTheme: true },
+53 -5
View File
@@ -1,13 +1,13 @@
import { afterEach, describe, expect, it, vi } from 'vitest';
import { HermesClient } from '../src/services/hermes/client';
import { httpFetch } from '../src/lib/transport';
import { httpFetch, httpStream } from '../src/lib/transport';
import { DEFAULT_SETTINGS, useSettings } from '../src/state/settings';
import { useHermes } from '../src/state/hermes';
import { createElement, act } from 'react';
import { createRoot } from 'react-dom/client';
import { ModelSelect } from '../src/components/settings/ModelSelect';
vi.mock('../src/lib/transport', async (original) => ({ ...await original<typeof import('../src/lib/transport')>(), httpFetch: vi.fn() }));
vi.mock('../src/lib/transport', async (original) => ({ ...await original<typeof import('../src/lib/transport')>(), httpFetch: vi.fn(), httpStream: vi.fn() }));
const config = { ...DEFAULT_SETTINGS.hermes, url: 'https://example.test/v1/', apiKey: ' test-key ' };
function respond(payload: unknown, status = 200) {
vi.mocked(httpFetch).mockResolvedValue({ ok: status === 200, status, statusText: '', headers: {}, text: JSON.stringify(payload) });
@@ -15,6 +15,54 @@ function respond(payload: unknown, status = 200) {
afterEach(() => { vi.restoreAllMocks(); useSettings.setState({ settings: DEFAULT_SETTINGS }); });
describe('Hermes models', () => {
it.each(['runs', 'sessions', 'completions'] as const)('sends the configured assistant identity over %s, including after a rename', async (transport) => {
const requests: Record<string, unknown>[] = [];
const capture = async (req: { body?: string }) => { requests.push(JSON.parse(req.body!)); throw new Error('stop'); };
vi.mocked(httpFetch).mockImplementation(capture);
vi.mocked(httpStream).mockImplementation(capture);
for (const name of ['Jarvis', 'Nova']) {
useSettings.setState({ settings: { ...DEFAULT_SETTINGS, assistantName: name, hermes: { ...config, instructions: 'Tu es Eve. Réponds en français.' } } });
const send = useHermes.getState().client().send({ text: 'Qui es-tu ?', sessionId: 'hs:test', history: [], onEvent: vi.fn() }, transport);
await expect(send.result).rejects.toThrow('stop');
const body = requests.at(-1)!;
const instructions = transport === 'completions' ? (body.messages as { content: string }[])[0].content : body.instructions as string;
expect(instructions).toContain(`ton nom est "${name}"`);
expect(instructions).toContain('Réponds en français.');
expect(instructions).toContain("EveFlow est le nom de l'application, pas ton nom");
}
expect(useSettings.getState().settings.hermes.instructions).toBe('Tu es Eve. Réponds en français.');
});
it('reads the real provider inventory, keeps providers distinct and marks inaccessible models', async () => {
respond({ providers: [
{ slug: 'first', name: 'First', authenticated: true, models: ['same', 'locked'], unavailable_models: ['locked'] },
{ slug: 'second', name: 'Second', authenticated: false, models: ['same'] }
] });
const result = await new HermesClient(config).modelCatalog(true);
expect(httpFetch).toHaveBeenCalledWith(expect.objectContaining({ url: 'https://example.test/api/model/options?refresh=true' }));
expect(result.models.map(m => [m.id, m.available])).toEqual([['first::same', true], ['first::locked', false], ['second::same', false]]);
expect(result.notice).toBeNull();
});
it('explains old servers instead of presenting the connection alias as an LLM catalog', async () => {
vi.mocked(httpFetch).mockResolvedValueOnce({ ok: false, status: 404, statusText: '', headers: {}, text: '' })
.mockResolvedValueOnce({ ok: true, status: 200, statusText: '', headers: {}, text: JSON.stringify({ data: [{ id: 'hermes-agent' }] }) });
const result = await new HermesClient(config).modelCatalog();
expect(result.models).toEqual([{ id: 'hermes-agent' }]);
expect(result.notice).toContain('Mettez Hermes à jour');
});
it.each(['runs', 'sessions', 'completions'] as const)('sends provider and actual model separately over %s', async (transport) => {
const requests: unknown[] = [];
vi.mocked(httpFetch).mockImplementation(async req => {
requests.push(JSON.parse(req.body as string));
throw new Error('stop');
});
vi.mocked(httpStream).mockImplementation(async req => {
requests.push(JSON.parse(req.body as string));
throw new Error('stop');
});
const send = new HermesClient({ ...config, model: 'custom:local::real-model' }).send({ text: 'Bonjour', sessionId: 'hs:test', history: [], onEvent: vi.fn() }, transport);
await expect(send.result).rejects.toThrow('stop');
expect(requests[0]).toMatchObject({ model: 'real-model', provider: 'custom:local' });
});
it('uses authenticated discovery and preserves provider labels, order and unique valid IDs', async () => {
respond({ data: [{ id: 'b', provider: 'provider-b' }, { id: 'a' }, { id: 'b' }, {}, ' c '] });
expect(await new HermesClient(config).models()).toEqual([{ id: 'b', provider: 'provider-b' }, { id: 'a' }, { id: 'c' }]);
@@ -38,12 +86,12 @@ describe('Hermes models', () => {
});
it('discards results from a previous server or an older refresh', async () => {
useSettings.setState({ settings: { ...DEFAULT_SETTINGS, hermes: config } });
let finish!: (value: { id: string }[]) => void;
vi.spyOn(HermesClient.prototype, 'models').mockImplementationOnce(() => new Promise(resolve => { finish = resolve; })).mockResolvedValue([{ id: 'new' }]);
let finish!: (value: { models: { id: string }[]; notice: null }) => void;
vi.spyOn(HermesClient.prototype, 'modelCatalog').mockImplementationOnce(() => new Promise(resolve => { finish = resolve; })).mockResolvedValue({ models: [{ id: 'new' }], notice: null });
const old = useHermes.getState().refreshModels();
useSettings.setState({ settings: { ...DEFAULT_SETTINGS, hermes: { ...config, url: 'https://new.test' } } });
await useHermes.getState().refreshModels();
finish([{ id: 'old' }]);
finish({ models: [{ id: 'old' }], notice: null });
await old;
expect(useHermes.getState().models).toEqual([{ id: 'new' }]);
});
+57
View File
@@ -0,0 +1,57 @@
import { afterEach, describe, expect, it, vi } from 'vitest';
import { HermesClient } from '../src/services/hermes/client';
import { httpFetch, httpStream } from '../src/lib/transport';
import { DEFAULT_SETTINGS } from '../src/state/settings';
import type { HermesStreamEvent } from '../src/services/hermes/types';
vi.mock('../src/lib/transport', async (original) => ({ ...await original<typeof import('../src/lib/transport')>(), httpFetch: vi.fn(), httpStream: vi.fn() }));
const config = { ...DEFAULT_SETTINGS.hermes, url: 'https://example.test' };
afterEach(() => vi.restoreAllMocks());
/** Run started, streamed to completion over SSE (which never carries the session id), status read afterwards. */
function mockRun(sessionId: string) {
const bodies: Array<{ url: string; body: unknown }> = [];
vi.mocked(httpFetch).mockImplementation(async (req) => {
bodies.push({ url: req.url, body: req.body ? JSON.parse(req.body as string) : undefined });
if (req.url.endsWith('/v1/runs')) return { ok: true, status: 200, statusText: '', headers: {}, text: JSON.stringify({ run_id: 'run_1', status: 'started' }) };
return { ok: true, status: 200, statusText: '', headers: {}, text: JSON.stringify({ run_id: 'run_1', status: 'completed', session_id: sessionId, output: 'Salut.' }) };
});
vi.mocked(httpStream).mockImplementation(async (_req, handlers) => {
// Chunks arrive on a later tick, after the client has accepted the stream (as over IPC).
const done = new Promise<void>((resolve) => setTimeout(() => {
handlers.onChunk('event: message.delta\ndata: {"run_id":"run_1","delta":"Salut."}\n\n');
handlers.onChunk('event: run.completed\ndata: {"run_id":"run_1","status":"completed","output":"Salut."}\n\n');
resolve();
}, 0));
return { start: { id: 'stream-1', ok: true, status: 200, statusText: '', headers: {} }, done, abort: () => undefined };
});
return bodies;
}
describe('Hermes runs session continuity', () => {
it('adopts the session Hermes attached to the run so the next message continues it', async () => {
const bodies = mockRun('api_abc');
const events: HermesStreamEvent[] = [];
const client = new HermesClient(config);
const reply = await client.send({ text: 'Bonjour', sessionId: 'eveflow-local', history: [], onEvent: (e) => events.push(e) }, 'runs').result;
expect(reply).toBe('Salut.');
expect(events.map((e) => e.kind)).toEqual(['run.started', 'delta', 'completed', 'session']);
expect(events[3]).toEqual({ kind: 'session', sessionId: 'api_abc' });
expect(bodies.map((b) => b.url)).toEqual(['https://example.test/v1/runs', 'https://example.test/v1/runs/run_1']);
expect(bodies[0].body).toEqual(expect.objectContaining({ input: 'Bonjour', session_id: 'eveflow-local' }));
const again = await client.send({ text: 'Et ensuite ?', sessionId: 'api_abc', history: [], onEvent: () => undefined }, 'runs').result;
expect(again).toBe('Salut.');
expect(bodies[2].body).toEqual(expect.objectContaining({ session_id: 'api_abc' }));
});
it('does not fail the reply when the run status is unavailable', async () => {
mockRun('api_abc');
vi.mocked(httpFetch).mockImplementation(async (req) =>
req.url.endsWith('/v1/runs')
? { ok: true, status: 200, statusText: '', headers: {}, text: JSON.stringify({ run_id: 'run_1', status: 'started' }) }
: { ok: false, status: 500, statusText: '', headers: {}, text: 'boom' });
const events: HermesStreamEvent[] = [];
const reply = await new HermesClient(config).send({ text: 'Bonjour', sessionId: 'x', history: [], onEvent: (e) => events.push(e) }, 'runs').result;
expect(reply).toBe('Salut.');
expect(events.some((e) => e.kind === 'session')).toBe(false);
});
});
+59
View File
@@ -0,0 +1,59 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { DEFAULT_SETTINGS, useSettings } from '../src/state/settings';
const enqueue = vi.fn((text: string) => /[\p{L}\p{N}]/u.test(text.replace(/```[\s\S]*?```/g, '')));
const speak = vi.fn();
const stop = vi.fn();
vi.mock('../src/services/voice/tts', () => ({
TtsEngine: class {
enqueue = enqueue;
speak = speak;
stop = stop;
onState() { return () => undefined; }
updateConfig() { /* noop */ }
get isActive() { return false; }
}
}));
const { speech, DIGEST_NOTICE } = await import('../src/services/voice/speech');
function stream(text: string, size = 7): void {
for (let i = 0; i < text.length; i += size) speech.pushStream(text.slice(i, i + size));
}
const spoken = () => enqueue.mock.calls.map((c) => c[0]);
describe('spoken digest of streamed replies', () => {
beforeEach(() => {
enqueue.mockClear();
speak.mockClear();
useSettings.setState({ settings: { ...DEFAULT_SETTINGS, speech: { ...DEFAULT_SETTINGS.speech, summarizeReplies: true, replySentences: 2 } } });
});
afterEach(() => speech.stop());
it('stops after the configured sentences, then adds the closing question and a notice', () => {
const text = 'Première phrase du rapport. Deuxième phrase utile. Troisième phrase de détail. Quatrième phrase encore. Tu veux la suite ?';
stream(text);
speech.endStream(text);
expect(spoken()).toEqual(['Première phrase du rapport.', 'Deuxième phrase utile.', 'Tu veux la suite ?', DIGEST_NOTICE]);
});
it('speaks short replies in full without any notice', () => {
const text = 'Une phrase courte. Une seconde phrase';
stream(text);
speech.endStream(text);
expect(spoken()).toEqual(['Une phrase courte.', 'Une seconde phrase']);
});
it('speaks everything when the digest is disabled', () => {
useSettings.setState({ settings: { ...DEFAULT_SETTINGS, speech: { ...DEFAULT_SETTINGS.speech, summarizeReplies: false } } });
const text = 'Première phrase du rapport. Deuxième phrase utile. Troisième phrase de détail. Quatrième phrase encore.';
stream(text);
speech.endStream(text);
expect(spoken()).toHaveLength(4);
});
it('digests a reply delivered in one piece', () => {
speech.sayReply('Première phrase du rapport. Deuxième phrase utile. Troisième phrase de détail. On continue ?');
expect(speak).toHaveBeenCalledWith(`Première phrase du rapport. Deuxième phrase utile. On continue ? ${DIGEST_NOTICE}`, expect.anything());
});
});
+19 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
import { chunkForSpeech, cleanForSpeech, extractSentences, isTranscriptNoise, preprocessMedia } from '../src/lib/text';
import { chunkForSpeech, cleanForSpeech, closingQuestion, extractSentences, isTranscriptNoise, preprocessMedia, spokenDigest } from '../src/lib/text';
describe('text', () => {
it('cleans markdown for speech', () => {
@@ -40,3 +40,21 @@ describe('isTranscriptNoise', () => {
expect(isTranscriptNoise('Oui')).toBe(false);
});
});
describe('spokenDigest', () => {
const reply = 'Voici la réponse. Elle contient plusieurs phrases. Une troisième pour la forme. Et une quatrième.\n\n```js\nconsole.log(1)\n```\n\nTu veux que je continue ?';
it('speaks the first sentences and keeps the closing question', () => {
const digest = spokenDigest(reply, 2);
expect(digest.truncated).toBe(true);
expect(digest.text).toBe('Voici la réponse. Elle contient plusieurs phrases. Tu veux que je continue ?');
});
it('leaves short replies untouched', () => {
const digest = spokenDigest('Bonjour Michael. Tout va bien.', 4);
expect(digest).toEqual({ text: 'Bonjour Michael. Tout va bien.', truncated: false });
});
it('ignores code blocks when counting and only reports a real question', () => {
expect(spokenDigest('Une phrase.\n\n```\ncode\n```\n', 1).truncated).toBe(false);
expect(closingQuestion(reply)).toBe('Tu veux que je continue ?');
expect(closingQuestion('Aucune question ici.')).toBeNull();
});
});