From f0a1ab09114f6db9c95dfeaa894319caaef30a2a Mon Sep 17 00:00:00 2001 From: boban Date: Mon, 11 May 2026 22:58:09 +0200 Subject: [PATCH] Fox: /fox/message returns audio_url Route now waits synchronously for FoxAgent response and returns reply + audio_url. Co-Authored-By: Claude Sonnet 4.6 --- app/Services/FoxAgent.php | 38 +++++++++++++++++++++- resources/js/fox-hud.js | 20 ++++++++++++ resources/views/livewire/fox-hud.blade.php | 8 +++-- routes/web.php | 19 +++++++++++ 4 files changed, 81 insertions(+), 4 deletions(-) diff --git a/app/Services/FoxAgent.php b/app/Services/FoxAgent.php index b1feb75..7224df6 100644 --- a/app/Services/FoxAgent.php +++ b/app/Services/FoxAgent.php @@ -329,6 +329,13 @@ class FoxAgent calculate: Rechnen, Umrechnen, Kalkulieren remind: Erinnerung setzen brain: Fox Brain / Gedächtnis-Visualisierung öffnen + close_map / close_poi / close_transit / close_status: Aktives Panel schließen + spotify_play / spotify_pause / spotify_next / spotify_prev: Spotify steuern + mail_open: Mail App öffnen + open_app: Mac App öffnen → app=App-Name + screenshot: Screenshot machen + save_desktop: Desktop speichern + volume_up / volume_down: Lautstärke anpassen response: Normale Antwort wenn keine andere Action passt BEISPIELE: @@ -347,6 +354,18 @@ class FoxAgent "was weißt du" → action=brain "dein Gedächtnis" → action=brain "memory" → action=brain + "spiel musik" → action=spotify_play + "nächster song" → action=spotify_next + "vorheriger song" → action=spotify_prev + "musik pause" → action=spotify_pause + "öffne mail" → action=mail_open + "öffne finder" → action=open_app, app="Finder" + "öffne safari" → action=open_app, app="Safari" + "mach einen screenshot" → action=screenshot + "lauter" → action=volume_up + "leiser" → action=volume_down + "schließe die karte" → action=close_map + "schließe die restaurants" → action=close_poi BEI action=code: - code: VOLLSTÄNDIGER ausführbarer Code, nicht nur Erklärung @@ -389,6 +408,9 @@ class FoxAgent 'map', 'poi', 'weather', 'transit', 'route', 'recommend', 'response', 'close_map', 'close_poi', 'close_transit', 'close_status', 'web_search', 'open_url', 'code', 'calculate', 'remind', 'brain', + 'spotify_play', 'spotify_pause', 'spotify_next', 'spotify_prev', + 'mail_open', 'open_app', 'screenshot', 'save_desktop', + 'volume_up', 'volume_down', ]), new StringSchema('city', 'Kleingeschriebener Stadtname (leer wenn nicht relevant)'), new StringSchema('category', 'POI-Kategorie bei action=poi: restaurant, parking, pharmacy, hotel, doctor, bank, supermarket'), @@ -401,8 +423,9 @@ class FoxAgent new StringSchema('language', 'Programmiersprache bei action=code (php, js, python, etc.)'), new StringSchema('result', 'Berechnetes Ergebnis bei action=calculate'), new StringSchema('description', 'Beschreibung was der Code macht, bei action=code'), + new StringSchema('app', 'App Name bei action=open_app'), ], - requiredFields: ['action', 'text', 'city', 'category', 'place', 'to', 'url', 'query', 'code', 'language', 'result', 'description'], + requiredFields: ['action', 'text', 'city', 'category', 'place', 'to', 'url', 'query', 'code', 'language', 'result', 'description', 'app'], ); // Provider-Chain: Ollama (Mac, qwen2.5:32b) → OpenAI (gpt-4o-mini) → Heuristik. @@ -657,6 +680,19 @@ class FoxAgent ])); } + // Desktop-Actions (Spotify, Mail, App, System) — für Electron Mac Agent + if (in_array($action, [ + 'spotify_play', 'spotify_pause', 'spotify_next', 'spotify_prev', + 'mail_open', 'open_app', 'screenshot', 'save_desktop', + 'volume_up', 'volume_down', + ], true)) { + broadcast(new FoxAction([ + 'action' => $action, + 'text' => $reply['text'] ?? '', + 'app' => $reply['app'] ?? null, + ])); + } + $message = Message::create([ 'role' => Message::ROLE_ASSISTANT, 'content' => $reply['text'] ?: '...', diff --git a/resources/js/fox-hud.js b/resources/js/fox-hud.js index 2f25691..ac87572 100644 --- a/resources/js/fox-hud.js +++ b/resources/js/fox-hud.js @@ -500,6 +500,24 @@ document.addEventListener('alpine:init', () => { return; } + // Spotify + if (payload.action === 'spotify_play') { window.foxBridge?.macCommand('spotify_play'); if (payload.text) this.notify(payload.text); return; } + if (payload.action === 'spotify_pause') { window.foxBridge?.macCommand('spotify_pause'); if (payload.text) this.notify(payload.text); return; } + if (payload.action === 'spotify_next') { window.foxBridge?.macCommand('spotify_next'); if (payload.text) this.notify(payload.text); return; } + if (payload.action === 'spotify_prev') { window.foxBridge?.macCommand('spotify_prev'); if (payload.text) this.notify(payload.text); return; } + + // Desktop Actions + if (payload.action === 'mail_open') { window.foxBridge?.macCommand('mail_open'); if (payload.text) this.notify(payload.text); return; } + if (payload.action === 'volume_up') { window.foxBridge?.macCommand('volume_up'); if (payload.text) this.notify(payload.text); return; } + if (payload.action === 'volume_down') { window.foxBridge?.macCommand('volume_down'); if (payload.text) this.notify(payload.text); return; } + if (payload.action === 'screenshot') { window.foxBridge?.macCommand('screenshot'); if (payload.text) this.notify(payload.text); return; } + if (payload.action === 'save_desktop') { window.foxBridge?.macCommand('save_desktop'); if (payload.text) this.notify(payload.text); return; } + if (payload.action === 'open_app' && payload.app) { + window.foxBridge?.macCommand('app:' + payload.app); + if (payload.text) this.notify(payload.text); + return; + } + if (['map','food','weather','transit','poi'].includes(payload.action)) { let city = payload.data; if (!city && payload.city) { @@ -562,6 +580,8 @@ document.addEventListener('alpine:init', () => { ml.style.visibility = 'visible'; ml.classList.add('show'); } + document.getElementById('fox-center')?.classList.add('hide'); + document.getElementById('fox-mini')?.classList.add('show'); // 200ms warten damit der Browser die Layout-Änderungen committed hat, // dann erst resize() (sonst rechnet MapLibre auf alter Container-Größe). diff --git a/resources/views/livewire/fox-hud.blade.php b/resources/views/livewire/fox-hud.blade.php index bc49f3a..71612b2 100644 --- a/resources/views/livewire/fox-hud.blade.php +++ b/resources/views/livewire/fox-hud.blade.php @@ -2,7 +2,8 @@
-
+
{{-- Fox Brain Layer --}}
@@ -61,7 +62,7 @@
@@ -131,7 +132,8 @@
-