The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
Merge remote-tracking branch 'origin/main' into wake-toggle-config
Teknium0cf58de85e5f
diff --cc apps/desktop/src/app/chat/composer/hooks/use-voice-conversation.tsindex 59ba4ee3c8e,ea40a5fc2cc..674b19bbb73--- a/apps/desktop/src/app/chat/composer/hooks/use-voice-conversation.ts+++ b/apps/desktop/src/app/chat/composer/hooks/use-voice-conversation.ts@@@ -9,8 -9,8 +9,9 @@@ importstartSpeechStream,stopVoicePlayback} from '@/lib/voice-playback'+import { isVoiceStopCommand } from '@/lib/voice-stop-word'import { notify, notifyError } from '@/store/notifications'+ import { $voicePlayback } from '@/store/voice-playback'import { useMicRecorder } from './use-mic-recorder'diff --cc tests/test_tui_gateway_server.pyindex 96f152e3d79,83f9127fc2c..225c34f5d7f--- a/tests/test_tui_gateway_server.py+++ b/tests/test_tui_gateway_server.py@@@ -1307,264 -1314,55 +1315,313 @@@ def test_voice_record_start_handles_nonassert captured["auto_restart"] is False+def test_wake_owner_is_sticky_and_routes_detection_to_first_transport(monkeypatch):+ from tools import wake_word++ state = {"owner": None, "callback": None, "paused": False}+ voice_callbacks = {}++ def start_listening(callback, *, owner, config):+ if state["owner"] is not None and state["owner"] is not owner:+ raise wake_word.WakeWordInUse+ state.update(owner=owner, callback=callback, paused=False)++ def pause_listening(*, owner):+ if state["owner"] is not owner:+ return False+ state["paused"] = True+ return True++ def stop_listening(*, owner):+ if state["owner"] is not owner:+ return False+ state.update(owner=None, callback=None, paused=False)+ return True++ def resume_listening(*, owner):+ if state["owner"] is not owner:+ return False+ state["paused"] = False+ return True++ def start_continuous(**callbacks):+ voice_callbacks.update(callbacks)+ return True++ monkeypatch.setattr(wake_word, "load_wake_word_config", lambda: {+ "enabled": True,+ "phrase": "hey hermes",+ "surface": "auto",+ "start_new_session": True,+ })+ monkeypatch.setattr(wake_word, "check_wake_word_requirements", lambda _cfg: {+ "available": True,+ "phrase": "hey hermes",+ "provider": "test",+ "hint": "",+ })+ monkeypatch.setattr(wake_word, "start_listening", start_listening)+ monkeypatch.setattr(wake_word, "pause_listening", pause_listening)+ monkeypatch.setattr(wake_word, "stop_listening", stop_listening)+ monkeypatch.setattr(wake_word, "owns_listener", lambda owner: state["owner"] is owner)+ monkeypatch.setattr(+ wake_word,+ "is_listening",+ lambda: state["owner"] is not None and not state["paused"],+ )+ monkeypatch.setattr(+ wake_word,+ "resume_listening",+ resume_listening,+ )+ monkeypatch.setitem(+ sys.modules,+ "hermes_cli.voice",+ types.SimpleNamespace(+ start_continuous=start_continuous,+ stop_continuous=lambda **_kwargs: None,+ ),+ )+ monkeypatch.setenv("HERMES_VOICE", "1")++ first = types.SimpleNamespace(_closed=False)+ second = types.SimpleNamespace(_closed=False)+ emitted = []+ monkeypatch.setattr(+ server,+ "_emit",+ lambda event, sid, payload: emitted.append(+ (event, sid, payload, server.current_transport())+ ),+ )+ server._wake_owner_transport = None+ server._wake_owner_surface = ""+ try:+ started = server.dispatch({+ "id": "wake-1",+ "method": "wake.start",+ "params": {"surface": "gui", "session_id": "first-session"},+ }, transport=first)+ denied = server.dispatch({+ "id": "wake-2",+ "method": "wake.start",+ "params": {"surface": "tui", "session_id": "second-session"},+ }, transport=second)+ denied_stop = server.dispatch({+ "id": "wake-stop-2",+ "method": "wake.stop",+ "params": {},+ }, transport=second)+ denied_voice_stop = server.dispatch({+ "id": "voice-stop-2",+ "method": "voice.record",+ "params": {"action": "stop"},+ }, transport=second)++ assert started["result"]["started"] is True+ assert denied["result"] == {+ "started": False,+ "reason": "owned",+ "owner_surface": "gui",+ }+ assert denied_stop["result"] == {+ "stopped": False,+ "reason": "not_owner",+ "disabled_persisted": False,+ }+ assert denied_voice_stop["result"] == {+ "status": "busy",+ "reason": "wake_owned",+ }++ state["callback"]()+ assert emitted == [(+ "wake.detected",+ "first-session",+ {"phrase": "hey hermes", "profile": None, "start_new_session": True},+ first,+ )]+ assert state["paused"] is True++ voice_started = server.dispatch({+ "id": "voice-start-1",+ "method": "voice.record",+ "params": {"action": "start", "session_id": "first-session"},+ }, transport=first)+ assert voice_started["result"]["status"] == "recording"+ voice_callbacks["on_status"]("idle")+ assert state["paused"] is False++ stopped = server.dispatch({+ "id": "wake-stop-1",+ "method": "wake.stop",+ "params": {},+ }, transport=first)+ assert stopped["result"] == {+ "stopped": True,+ "reason": None,+ "disabled_persisted": False,+ }++ reclaimed = server.dispatch({+ "id": "wake-reclaim-2",+ "method": "wake.start",+ "params": {"surface": "tui", "session_id": "second-session"},+ }, transport=second)+ assert reclaimed["result"]["started"] is True+ assert state["owner"] is second++ state["callback"]()+ assert emitted[-1] == (+ "wake.detected",+ "second-session",+ {"phrase": "hey hermes", "profile": None, "start_new_session": True},+ second,+ )++ stopped_again = server.dispatch({+ "id": "wake-stop-2-after-reclaim",+ "method": "wake.stop",+ "params": {},+ }, transport=second)+ assert stopped_again["result"] == {+ "stopped": True,+ "reason": None,+ "disabled_persisted": False,+ }+ finally:+ server._wake_owner_transport = None+ server._wake_owner_surface = ""+++def test_wake_toggle_persists_enabled_flag_only_on_explicit_gesture(monkeypatch):+ """The ear toggle / /wake on|off write wake_word.enabled; auto-arm never does."""+ from tools import wake_word++ config = {"enabled": False, "phrase": "hey hermes", "surface": "auto",+ "start_new_session": True}+ persisted = []++ def fake_persist(enabled):+ persisted.append(enabled)+ config["enabled"] = enabled+ return True++ monkeypatch.setattr(server, "_persist_wake_enabled", fake_persist)+ monkeypatch.setattr(wake_word, "load_wake_word_config", lambda: dict(config))+ monkeypatch.setattr(wake_word, "check_wake_word_requirements", lambda _cfg: {+ "available": True,+ "phrase": "hey hermes",+ "provider": "test",+ "hint": "",+ })+ listener = {"owner": None}+ monkeypatch.setattr(+ wake_word, "start_listening",+ lambda callback, *, owner, config: listener.update(owner=owner),+ )+ monkeypatch.setattr(+ wake_word, "stop_listening",+ lambda *, owner: listener["owner"] is owner and not listener.update(owner=None),+ )+ monkeypatch.setattr(wake_word, "owns_listener", lambda owner: listener["owner"] is owner)++ transport = types.SimpleNamespace(_closed=False)+ server._wake_owner_transport = None+ server._wake_owner_surface = ""+ try:+ # Passive auto-arm (no persist): refused, config untouched.+ passive = server.dispatch({+ "id": "wake-passive",+ "method": "wake.start",+ "params": {"surface": "gui"},+ }, transport=transport)+ assert passive["result"] == {"started": False, "reason": "disabled"}+ assert persisted == []++ # Explicit gesture: enables in config AND arms.+ clicked = server.dispatch({+ "id": "wake-click",+ "method": "wake.start",+ "params": {"surface": "gui", "persist": True},+ }, transport=transport)+ assert clicked["result"]["started"] is True+ assert clicked["result"]["enabled_persisted"] is True+ assert persisted == [True]++ # Explicit stop: disables in config.+ stopped = server.dispatch({+ "id": "wake-click-off",+ "method": "wake.stop",+ "params": {"persist": True},+ }, transport=transport)+ assert stopped["result"]["stopped"] is True+ assert stopped["result"]["disabled_persisted"] is True+ assert persisted == [True, False]++ # persist does NOT override an explicit surface scoping.+ config.update(enabled=True, surface="tui")+ scoped = server.dispatch({+ "id": "wake-scoped",+ "method": "wake.start",+ "params": {"surface": "gui", "persist": True},+ }, transport=transport)+ assert scoped["result"] == {"started": False, "reason": "disabled_for_surface"}+ assert persisted == [True, False]+ finally:+ server._wake_owner_transport = None+ server._wake_owner_surface = ""+++ def test_voice_record_start_forwards_max_recording_seconds(monkeypatch):+ """voice.max_recording_seconds must reach start_continuous from the TUI.++ The CLI wiring alone doesn't cover TUI recordings: the gateway forwards+ recorder params explicitly, so a missing kwarg here silently leaves the+ cap dead in the TUI while CLI tests stay green. Semantics mirror the+ silence params: non-numeric / bool / missing falls back to the documented+ 120 default, an explicit numeric value <= 0 disables the cap.+ """+ captured: dict = {}++ def fake_start_continuous(**kwargs):+ captured.update(kwargs)++ monkeypatch.setitem(+ sys.modules,+ "hermes_cli.voice",+ types.SimpleNamespace(+ start_continuous=fake_start_continuous, stop_continuous=lambda: None+ ),+ )+ monkeypatch.setenv("HERMES_VOICE", "1")++ for cfg, expected in (+ ({"max_recording_seconds": 45}, 45), # explicit cap forwarded as-is+ ({"max_recording_seconds": 0}, 0.0), # explicit 0 = disabled+ ({"max_recording_seconds": -5}, 0.0), # negative = disabled+ ({}, 120.0), # missing = documented default+ ({"max_recording_seconds": True}, 120.0), # bool must not become 1s cap+ ({"max_recording_seconds": "long"}, 120.0), # garbage = documented default+ ):+ captured.clear()+ monkeypatch.setattr(server, "_load_cfg", lambda c=cfg: {"voice": c})++ resp = server.dispatch(+ {+ "id": "voice-record-cap",+ "method": "voice.record",+ "params": {"action": "start"},+ }+ )++ assert "result" in resp, f"voice.record raised for cfg={cfg!r}: {resp.get('error')}"+ assert resp["result"]["status"] == "recording"+ assert (+ captured["max_recording_seconds"] == expected+ ), f"cfg={cfg!r} forwarded {captured.get('max_recording_seconds')!r}, expected {expected!r}"++def test_voice_record_stop_forces_transcription(monkeypatch):captured: dict = {}diff --cc tools/lazy_deps.pyindex 55b1fe5e418,155e43ce616..faa919d028f--- a/tools/lazy_deps.py+++ b/tools/lazy_deps.py@@@ -136,41 -136,10 +136,44 @@@ LAZY_DEPS: dict[str, tuple[str, ...]]"sounddevice==0.5.5","numpy==2.4.3",),+ # SILK voice-note decoding (WeChat/QQ .silk voice messages). pilk is a+ # small silk-v3 codec binding; installed on first .silk transcription.+ "stt.silk": ("pilk==0.2.4",),+ # ─── Wake word ("Hey Hermes") engines ──────────────────────────────────+ # Keep in sync with the `wake` extra in pyproject.toml. openWakeWord is the+ # free, local default (ONNX runtime); Porcupine is the premium engine.+ # openWakeWord's ONNX embedding model returns near-zero scores on macOS+ # ARM64 (dscripka/openWakeWord#336), so the wake word runs on the tflite+ # backend there. Upstream declares tflite-runtime for Linux only;+ # ai-edge-litert is the macOS equivalent, bridged in tools/wake_word.py.+ # It lives in its own feature because lazy-dep specs cannot carry PEP 508+ # environment markers (_spec_is_safe rejects ";"), so the platform gate is+ # applied by the caller instead.+ "wake.openwakeword.tflite": (+ "ai-edge-litert==2.1.6",+ ),+ "wake.openwakeword": (+ "openwakeword==0.6.0",+ "onnxruntime==1.27.0",+ "sounddevice==0.5.5",+ "numpy==2.4.3",+ ),+ # Open-vocabulary keyword spotting: any typed phrase, zero training.+ # sentencepiece is required by sherpa_onnx.text2token (runtime phrase+ # tokenization) even though sherpa-onnx doesn't declare it.+ "wake.sherpa": (+ "sherpa-onnx==1.13.4",+ "sentencepiece==0.2.2",+ "sounddevice==0.5.5",+ "numpy==2.4.3",+ ),+ "wake.porcupine": (+ "pvporcupine==4.0.3",+ "sounddevice==0.5.5",+ "numpy==2.4.3",+ ),+# ─── Image generation backends ─────────────────────────────────────────"image.fal": ("fal-client==0.13.1",),diff --cc tui_gateway/server.pyindex 75c3a20cc0a,e35e528a02c..3519fdb631c--- a/tui_gateway/server.py+++ b/tui_gateway/server.py@@@ -18088,42 -17768,28 +18121,53 @@@ def _(rid, params: dict) -> dictif isinstance(duration, (int, float)) and not isinstance(duration, bool)else 3.0)+ # Hand the mic to STT if the wake-word detector holds it; resume+ # once a terminal capture event fires (one-shot transcript / silence+ # limit), so wake-triggered and manual captures both coexist.+ try:+ from tools.wake_word import pause_listening++ wake_paused = pause_listening(owner=transport)+ except Exception:+ wake_paused = False+ if wake_paused:+ with _voice_sid_lock:+ _voice_wake_owner = transport++ def _on_transcript(t):+ _voice_emit("voice.transcript", {"text": t})+ _resume_voice_wake()++ def _on_silent():+ _voice_emit("voice.transcript", {"no_speech_limit": True})+ _resume_voice_wake()++ def _on_status(state):+ _voice_emit("voice.status", {"state": state})+ if state == "idle":+ _resume_voice_wake()++ # voice.max_recording_seconds — hard cap on a single recording's+ # length. Same guard as the silence params: non-numeric / bool /+ # missing falls back to the documented 120 default, while an+ # explicit numeric value <= 0 disables the cap (0.0).+ max_rec = voice_cfg.get("max_recording_seconds")+ safe_max_rec = (+ (max_rec if max_rec > 0 else 0.0)+ if isinstance(max_rec, (int, float)) and not isinstance(max_rec, bool)+ else 120.0+ )started = start_continuous(- on_transcript=lambda t: _voice_emit("voice.transcript", {"text": t}),- on_status=lambda s: _voice_emit("voice.status", {"state": s}),- on_silent_limit=lambda: _voice_emit(- "voice.transcript", {"no_speech_limit": True}- ),+ on_transcript=_on_transcript,+ on_status=_on_status,+ on_silent_limit=_on_silent,silence_threshold=safe_threshold,silence_duration=safe_duration,auto_restart=False,+ max_recording_seconds=safe_max_rec,)if started is False:+ _resume_voice_wake()return _ok(rid, {"status": "busy"})return _ok(rid, {"status": "recording"})diff --cc uv.lockindex d9796e09648,dee539ca975..ef3672e745e--- a/uv.lock+++ b/uv.lock@@@ -1845,12 -1805,9 +1843,12 @@@ requires-dist ={ name = "microsoft-teams-apps", marker = "extra == 'teams'", specifier = "==2.0.13.4" },{ name = "mistralai", marker = "extra == 'mistral'", specifier = "==2.4.8" },{ name = "modal", marker = "extra == 'modal'", specifier = "==1.3.4" },- { name = "nemo-relay", marker = "extra == 'nemo-relay'", specifier = ">=0.5,<1.0" },+ { name = "nemo-relay", marker = "(platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'aarch64' and sys_platform == 'linux') or (platform_machine == 'x86_64' and sys_platform == 'linux') or (platform_machine == 'AMD64' and sys_platform == 'win32') or (platform_machine == 'ARM64' and sys_platform == 'win32')", specifier = ">=0.6.0,<0.7" },{ name = "numpy", marker = "extra == 'voice'", specifier = "==2.4.3" },+ { name = "numpy", marker = "extra == 'wake'", specifier = "==2.4.3" },+ { name = "onnxruntime", marker = "extra == 'wake'", specifier = "==1.27.0" },{ name = "openai", specifier = "==2.24.0" },+ { name = "openwakeword", marker = "extra == 'wake'", specifier = "==0.6.0" },{ name = "packaging", specifier = "==26.0" },{ name = "parallel-web", marker = "extra == 'parallel-web'", specifier = "==0.4.2" },{ name = "pathspec", specifier = "==1.1.1" },@@@ -2646,25 -2599,16 +2644,25 @@@ wheels ={ url = "https://files.pythonhosted.org/packages/81/08/7036c080d7117f28a4af526d794aab6a84463126db031b007717c1a6676e/multidict-6.7.1-py3-none-any.whl", hash = "sha256:55d97cc6dae627efa6a6e548885712d4864b81110ac76fa4e534c03819fa4a56", size = 12319, upload-time = "2026-01-26T02:46:44.004Z" },]+[[package]]+name = "narwhals"+version = "2.24.0"+source = { registry = "https://pypi.org/simple" }+sdist = { url = "https://files.pythonhosted.org/packages/2b/1d/58946e5aab18393e793bd4add6985b95d0e01c3a2d832f38f54468b10dcd/narwhals-2.24.0.tar.gz", hash = "sha256:b5c0f684ccd9d7475b564111e319a4964abcf2baf79d3cf6b1003d06ac9b828d", size = 661143, upload-time = "2026-07-13T10:49:19.086Z" }+wheels = [+ { url = "https://files.pythonhosted.org/packages/7e/85/a5bfaebfd305ac18b57b0854d74e37e586809061a91fda62f0bd50c8518e/narwhals-2.24.0-py3-none-any.whl", hash = "sha256:42fdedf44e5b2ca7505630d45b4ac3058f38d8485cba9fe1652ca23152df7489", size = 461030, upload-time = "2026-07-13T10:49:17.571Z" },+]+[[package]]name = "nemo-relay"- version = "0.5.0"+ version = "0.6.0"source = { registry = "https://pypi.org/simple" }wheels = [- { url = "https://files.pythonhosted.org/packages/aa/fc/6892859ffbfb60f8cc09a4181c8d407b574d49490e35cd563e7f0a61bf54/nemo_relay-0.5.0-cp311-abi3-macosx_11_0_arm64.whl", hash = "sha256:203409e0f392fc4f40f52277347ed75ba9969b2af28ddb3b6ae53f789185a0ed", size = 7769721, upload-time = "2026-07-08T18:43:57.745Z" },- { url = "https://files.pythonhosted.org/packages/dd/13/25c4fcf6fb979af07c9562238819183588a910c2ae09767603500d6948c2/nemo_relay-0.5.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:de61ad0644c5e8c300de814f6884c5de7ae51db14694f5057f938b4da54bfaaf", size = 7037083, upload-time = "2026-07-08T18:44:00.135Z" },- { url = "https://files.pythonhosted.org/packages/49/97/bd4c77e975d50f7d09f8bfcb74d7e704e05a8b2205f555bf557f84edc5fe/nemo_relay-0.5.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cb323569f104506f4f1a0e2104b22d74c9a0bbf3280ec4d58ad3d768de76fb15", size = 7430817, upload-time = "2026-07-08T18:44:02.165Z" },- { url = "https://files.pythonhosted.org/packages/da/8b/5681f3430e6d25bf7419dbe576da14599e1cfadc083edb74e691a0c3a980/nemo_relay-0.5.0-cp311-abi3-win_amd64.whl", hash = "sha256:da1bd1e1dec79b7bda3984dd8c59b32ba97abf96c37e85cd1f38d208a29f42b9", size = 7359048, upload-time = "2026-07-08T18:44:04.169Z" },- { url = "https://files.pythonhosted.org/packages/4e/f2/65c3ef0435e671c829063d4872897f9054f369f0aeacab12c5aefe486705/nemo_relay-0.5.0-cp311-abi3-win_arm64.whl", hash = "sha256:87462585f17b40ce82c54347acef5ace96ee11de3015f234e0b902f23b3793fb", size = 6934235, upload-time = "2026-07-08T18:44:06.078Z" },+ { url = "https://files.pythonhosted.org/packages/25/65/d320016505457cc30971f575e8dadffb923b7cfc780ab8bb25a4ce9d305c/nemo_relay-0.6.0-cp311-abi3-macosx_11_0_arm64.whl", hash = "sha256:ad5dae6febf6532d7b113abc2a404679c8feffc499df3034b93d9a078185d2bb", size = 9917779, upload-time = "2026-07-22T20:07:48.961Z" },+ { url = "https://files.pythonhosted.org/packages/ae/c0/f33250e71c4206da1b339072893f9a1e39295fe1aceb9a2fef4b8620a0f2/nemo_relay-0.6.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c0cd9570f64c6956fe3bfb82af1cdb3ee70cb50b51098cdb0de831c3f9b4e904", size = 8888375, upload-time = "2026-07-22T20:07:51.049Z" },+ { url = "https://files.pythonhosted.org/packages/a3/f4/d1dfaed022da0f6f14765a122867f976a69cc520fe1faaf99757f5719d1f/nemo_relay-0.6.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:849daa9e45158ac581e54506e0fcc7a24f557d1ed06dbdc074f5de7a00393cbc", size = 9336372, upload-time = "2026-07-22T20:07:53.224Z" },+ { url = "https://files.pythonhosted.org/packages/3a/b0/908d77f75b9054e1e403da78f7d9430249a45939070d4298abbb41a04b5b/nemo_relay-0.6.0-cp311-abi3-win_amd64.whl", hash = "sha256:bfbbedfd130fa95c9b8c04643c30910df850e0ed3500beeab82b00ca2d94e7ea", size = 9613425, upload-time = "2026-07-22T20:07:55.175Z" },+ { url = "https://files.pythonhosted.org/packages/cd/71/c438b9d746303ff7f270d99f13b250bf947cdac3e52de2a83fd132cbca0b/nemo_relay-0.6.0-cp311-abi3-win_arm64.whl", hash = "sha256:82fe132943399d89e6ec34dc28df0be7bbe41b84f6698c545928b8816b6010f6", size = 9034810, upload-time = "2026-07-22T20:07:57.467Z" },][[package]]