mirror of
https://github.com/R0m1k3/EveFlow.git
synced 2026-10-21 06:08:14 +02:00
feat: serveur MCP, heures calmes, mode mission, widget glanceable, barge-in (v2.4.0) (#14)
Serveur MCP local - Endpoint /mcp (JSON-RPC 2.0, Streamable HTTP, réponses JSON) sur le serveur webhook : initialize, tools/list, tools/call, ping. Même secret que le webhook. 14 outils : capture_screen (image MCP), lock_session, open_app, open_url, media_key, clipboard_get/set, find_files, speak_text, notify_user, set_hud_state, get_app_status, get_conversation_history, show_message. Les outils UI transitent par IPC vers le renderer. - Les mêmes actions système sont proposées au modèle en chat completions. Notifications - Heures calmes (plage horaire, franchissement de minuit), mots prioritaires, échecs de crons toujours lus, résumé vocal des messages entrants (n premières phrases), thème nuit automatique, compteur de non-lus. Conversation - Mode mission : bouton dans la barre de commande, second modèle Hermes (hermes.missionModel) pour les tâches longues. - Barge-in : la parole de l'utilisateur coupe la voix ; seuil d'énergie et ratio relevés pendant la synthèse pour ignorer l'écho. Widget compact - Bandeau glanceable : état, dernière phrase, non-lus, indicateurs heures calmes et mission. Tests : 28 tests unitaires (heures calmes, priorité, résumé), e2e Electron sous Xvfb : MCP initialize/tools/list/tools/call (presse-papiers, capture en image, état et message via le renderer), bandeau compact, aucune erreur. Claude-Session: https://claude.ai/code/session_017Wn5VX9HNbJ7N54hR24u9Y Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
af8bdc5e9d
commit
6fc38d335b
24 files changed
+668
-31
No files matched your search
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Answers tool calls that Hermes sends through the local MCP endpoint and that need the renderer
|
||||
* (voice, notifications, HUD, chat). System tools are executed in the main process directly.
|
||||
*/
|
||||
import type { McpToolRequest } from '../../shared/ipc';
|
||||
import { bridge } from '../lib/bridge';
|
||||
import { Log } from '../lib/log';
|
||||
import { useChat } from '../state/chat';
|
||||
import { executeLocalTool, type LocalToolContext } from './hermes/localTools';
|
||||
|
||||
let unsubscribe: (() => void) | null = null;
|
||||
|
||||
export function initMcpBridge(context: () => LocalToolContext): void {
|
||||
const api = bridge();
|
||||
if (!api || unsubscribe) return;
|
||||
unsubscribe = api.hermes.onToolRequest((req: McpToolRequest) => {
|
||||
void handle(req, context)
|
||||
.then((result) => api.hermes.toolResponse({ id: req.id, ok: true, result }))
|
||||
.catch((err: Error) => api.hermes.toolResponse({ id: req.id, ok: false, error: err.message }));
|
||||
});
|
||||
}
|
||||
|
||||
async function handle(req: McpToolRequest, context: () => LocalToolContext): Promise<unknown> {
|
||||
Log.info('mcp', `tool ${req.name}`);
|
||||
const chat = useChat.getState();
|
||||
if (req.name === 'show_message') {
|
||||
const text = String(req.args.text ?? '');
|
||||
if (!text.trim()) throw new Error('texte vide');
|
||||
chat.addMessage({ role: 'assistant', content: text, source: 'mcp', jobName: typeof req.args.title === 'string' ? req.args.title : undefined, status: 'done' });
|
||||
chat.pushActivity({ kind: 'system', name: 'hermes → eveflow', status: 'done', detail: text.slice(0, 160) });
|
||||
return { ok: true };
|
||||
}
|
||||
const raw = await executeLocalTool(req.name, JSON.stringify(req.args ?? {}), context());
|
||||
try {
|
||||
const parsed = JSON.parse(raw) as { error?: string };
|
||||
if (parsed && typeof parsed === 'object' && parsed.error) throw new Error(parsed.error);
|
||||
return parsed;
|
||||
} catch (err) {
|
||||
if ((err as Error).message && !(err instanceof SyntaxError)) throw err;
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user