feat(notifier): push state events to Smart Home Tablet overlay

Adds a thin HTTP bridge so the tablet at https://tablet.digital-home.site
shows a Siri-style overlay reflecting the current assistant state
(wake / command / response / idle / error). Non-fatal: if the tablet
is offline or TABLET_URL/VOICE_API_KEY are unset, events are silently
skipped and the assistant keeps working.

- satellite/notifier.py — POST /api/voice/event with bearer token,
  reused requests.Session for keep-alive, 1.5s timeout
- satellite/modes.py — emits wake on activation, command after STT,
  response after LLM, idle on timeout
- satellite/llm.py — emits error on gateway connection/timeout/HTTP
- .env.example documents TABLET_URL and VOICE_API_KEY

Tablet side (separate repo smart-home-tablet, commit 51c3d60) exposes
POST /api/voice/event + GET /api/voice/stream (SSE) and renders a
full-screen overlay in components/VoiceOverlay.tsx.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cosmo
2026-04-23 12:39:13 +00:00
parent a9001aef92
commit e4e7529063
4 changed files with 78 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import requests
from .config import AGENTS, VOICE_MAX_TOKENS, LLM_RETRIES, log
from .text import clean_for_speech, find_sentence_end
from .tts import speak, play_error_sound
from . import notifier
VOICE_SESSION_KEY = os.getenv("VOICE_SESSION_KEY", "agent:main:voice:home")
@@ -91,6 +92,7 @@ def ask_agent_stream(text: str, agent_id: str = "cosmo") -> str:
msg = "Не могу связаться с сервером, попробуй ещё раз."
print(f"⚠️ {msg}")
play_error_sound()
notifier.error(msg, agent_id)
_maybe_speak(msg)
return msg
except requests.Timeout:
@@ -98,6 +100,7 @@ def ask_agent_stream(text: str, agent_id: str = "cosmo") -> str:
msg = "Сервер не ответил вовремя, попробуй ещё раз."
print(f"⚠️ {msg}")
play_error_sound()
notifier.error(msg, agent_id)
_maybe_speak(msg)
return msg
except requests.HTTPError as e:
@@ -107,6 +110,7 @@ def ask_agent_stream(text: str, agent_id: str = "cosmo") -> str:
msg = "Ошибка сервера, попробуй ещё раз."
print(f"⚠️ Gateway {status}: {body[:200]}")
play_error_sound()
notifier.error(msg, agent_id)
_maybe_speak(msg)
return msg