Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
chore: auto-save WIP via Claude stop-hook safety net (2026-07-10 18:12)
Ruben Lütke337389369174
diff --git a/jarvis/plugins/realtime/gemini_live.py b/jarvis/plugins/realtime/gemini_live.pyindex 5f09cd38b9..06255460c0 100644--- a/jarvis/plugins/realtime/gemini_live.py+++ b/jarvis/plugins/realtime/gemini_live.py@@ -36,6 +36,9 @@ class _ProviderEvent:is_final: bool = Falsems_played: int | None = Noneerror: str | None = None+ call_id: str | None = None+ tool_name: str | None = None+ tool_args: dict[str, Any] | None = Noneclass _GeminiLiveSession:@@ -103,6 +106,22 @@ class _GeminiLiveSession:if bool(getattr(content, "turn_complete", False)):yield _ProviderEvent(type="turn_complete")+ tool_call = getattr(message, "tool_call", None)+ for function_call in getattr(tool_call, "function_calls", None) or ():+ raw_args = getattr(function_call, "args", None) or {}+ if hasattr(raw_args, "model_dump"):+ raw_args = raw_args.model_dump()+ try:+ args = dict(raw_args)+ except (TypeError, ValueError):+ args = {}+ yield _ProviderEvent(+ type="tool_call",+ call_id=str(getattr(function_call, "id", "") or ""),+ tool_name=str(getattr(function_call, "name", "") or ""),+ tool_args=args,+ )+go_away = getattr(message, "go_away", None)if go_away is not None:retry_ms = getattr(go_away, "time_left", None)@@ -125,6 +144,21 @@ class _GeminiLiveSession:# The Live API has no separate response-cancel call for this flow.return None+ async def send_tool_result(+ self, call_id: str, name: str, result: dict[str, Any]+ ) -> None:+ from google.genai import types # lazy (AP-26)++ await self._session.send_tool_response(+ function_responses=[+ types.FunctionResponse(+ id=call_id,+ name=name,+ response=result,+ )+ ]+ )+async def close(self) -> None:if self._closed:return@@ -177,6 +211,19 @@ class GeminiLiveProvider:system_instruction=str(getattr(cfg, "instructions", "") or "") or None,input_audio_transcription=types.AudioTranscriptionConfig(),output_audio_transcription=types.AudioTranscriptionConfig(),+ **(+ {+ "tools": [+ {+ "function_declarations": list(+ tuple(getattr(cfg, "tools", ()) or ())+ )+ }+ ]+ }+ if tuple(getattr(cfg, "tools", ()) or ())+ else {}+ ),**({"speech_config": types.SpeechConfig(diff --git a/jarvis/plugins/realtime/openai_realtime.py b/jarvis/plugins/realtime/openai_realtime.pyindex fe0f9d4aa5..c2aa885785 100644--- a/jarvis/plugins/realtime/openai_realtime.py+++ b/jarvis/plugins/realtime/openai_realtime.py@@ -10,6 +10,7 @@ from __future__ import annotationsimport asyncioimport base64+import jsonfrom collections.abc import AsyncIteratorfrom dataclasses import dataclassfrom typing import Any@@ -36,6 +37,9 @@ class _ProviderEvent:is_final: bool = Falsems_played: int | None = Noneerror: str | None = None+ call_id: str | None = None+ tool_name: str | None = None+ tool_args: dict[str, Any] | None = Nonedef _error_message(event: Any) -> str:@@ -70,7 +74,7 @@ def _session_payload(cfg: Any) -> dict[str, Any]:if voice:output["voice"] = voice- return {+ payload: dict[str, Any] = {"type": "realtime","instructions": str(getattr(cfg, "instructions", "") or ""),"output_modalities": ["audio"],@@ -87,6 +91,20 @@ def _session_payload(cfg: Any) -> dict[str, Any]:"output": output,},}+ tools = tuple(getattr(cfg, "tools", ()) or ())+ if tools:+ payload["tools"] = [+ {+ "type": "function",+ "name": str(tool.get("name", "")),+ "description": str(tool.get("description", "")),+ "parameters": tool.get("parameters") or {"type": "object"},+ }+ for tool in tools+ if isinstance(tool, dict) and tool.get("name")+ ]+ payload["tool_choice"] = "auto"+ return payloadclass _OpenAIRealtimeSession:@@ -158,6 +176,20 @@ class _OpenAIRealtimeSession:)elif event_type == "input_audio_buffer.speech_started":yield _ProviderEvent(type="speech_started")+ elif event_type == "response.function_call_arguments.done":+ raw_arguments = str(getattr(event, "arguments", "") or "{}")+ try:+ arguments = json.loads(raw_arguments)+ except (TypeError, ValueError):+ arguments = {}+ if not isinstance(arguments, dict):+ arguments = {}+ yield _ProviderEvent(+ type="tool_call",+ call_id=str(getattr(event, "call_id", "") or ""),+ tool_name=str(getattr(event, "name", "") or ""),+ tool_args=arguments,+ )elif event_type == "response.done":yield _ProviderEvent(type="turn_complete")elif event_type == "error":@@ -183,6 +215,19 @@ class _OpenAIRealtimeSession:async def interrupt(self) -> None:await self._conn.response.cancel()+ async def send_tool_result(+ self, call_id: str, name: str, result: dict[str, Any]+ ) -> None:+ del name+ await self._conn.conversation.item.create(+ item={+ "type": "function_call_output",+ "call_id": call_id,+ "output": json.dumps(result, ensure_ascii=False, default=str),+ }+ )+ await self._conn.response.create()+async def close(self) -> None:if self._closed:returndiff --git a/tests/unit/plugins/wake/test_vosk_kws_provider.py b/tests/unit/plugins/wake/test_vosk_kws_provider.pyindex 3370fc4bcf..1455237a51 100644--- a/tests/unit/plugins/wake/test_vosk_kws_provider.py+++ b/tests/unit/plugins/wake/test_vosk_kws_provider.py@@ -252,52 +252,51 @@ async def test_cooldown_suppresses_immediate_refire(fake_vosk) -> None:# --- latency: concurrent grammar re-score + free decode -------------------------class _SlowFakeRecognizer:- """Recognizer whose ``FinalResult()`` sleeps, to prove the grammar- re-score and the free decode run CONCURRENTLY rather than sequentially.-- Grammar mode re-hears the phrase with a passing confidence; free mode- returns a sound-close transcript at the same span, so- ``_verify_candidate`` legitimately CONFIRMS — this test only cares about- the WALL-CLOCK time the call took, not the decision content (that is- covered by the tests above).+def test_verify_candidate_runs_grammar_and_free_decode_concurrently(monkeypatch) -> None:+ """Deterministic concurrency proof via a 2-party barrier — NOT a+ wall-clock margin (those flake under CI/system load; measured directly+ during this mission's benchmarking).++ Each fake recognizer's ``FinalResult()`` blocks on a barrier that only+ releases once BOTH the grammar-rescore call and the free-decode call have+ reached it. If ``_verify_candidate`` ran them sequentially, the first+ call would block forever waiting for a second party that can only arrive+ after the first one already returned — a deadlock, which the barrier+ turns into a hard, fast-failing ``BrokenBarrierError`` instead of a+ flaky timing assertion."""+ barrier = threading.Barrier(2, timeout=2.0)- SLEEP_S = 0.12-- def __init__(self, model, rate, grammar=None): # noqa: ANN001- self._model = model- self._grammar = grammar+ class _BarrierRecognizer:+ def __init__(self, model, rate, grammar=None): # noqa: ANN001+ self._model = model+ self._grammar = grammar- def SetWords(self, flag): # noqa: ANN001, N802- pass+ def SetWords(self, flag): # noqa: ANN001, N802+ pass- def AcceptWaveform(self, pcm): # noqa: ANN001, N802- return False+ def AcceptWaveform(self, pcm): # noqa: ANN001, N802+ return False- def PartialResult(self): # noqa: N802- return json.dumps({"partial": ""})+ def PartialResult(self): # noqa: N802+ return json.dumps({"partial": ""})- def Result(self): # noqa: N802- return json.dumps({"text": ""})+ def Result(self): # noqa: N802+ return json.dumps({"text": ""})- def FinalResult(self): # noqa: N802- # time.sleep releases the GIL — this stands in for a real vosk decode- # call, which likewise releases the GIL during its C++ work.- time.sleep(self.SLEEP_S)- if self._grammar is not None:- phrase = self._model.phrase.lower()+ def FinalResult(self): # noqa: N802+ barrier.wait()+ if self._grammar is not None:+ phrase = self._model.phrase.lower()+ return json.dumps({+ "text": phrase,+ "result": _timed_words(phrase, self._model.grammar_conf),+ })return json.dumps({- "text": phrase,- "result": _timed_words(phrase, self._model.grammar_conf),+ "text": self._model.free_text,+ "result": _timed_words(self._model.free_text, 0.9),})- return json.dumps({- "text": self._model.free_text,- "result": _timed_words(self._model.free_text, 0.9),- })--def test_verify_candidate_runs_grammar_and_free_decode_concurrently(monkeypatch) -> None:mod = types.ModuleType("vosk")state = {"model": None}@@ -306,7 +305,7 @@ def test_verify_candidate_runs_grammar_and_free_decode_concurrently(monkeypatch)return state["model"]mod.Model = _model_factory- mod.KaldiRecognizer = _SlowFakeRecognizer+ mod.KaldiRecognizer = _BarrierRecognizermod.SetLogLevel = lambda *_a: Nonemonkeypatch.setitem(sys.modules, "vosk", mod)@@ -314,15 +313,7 @@ def test_verify_candidate_runs_grammar_and_free_decode_concurrently(monkeypatch)p._ensure_model() # noqa: SLF001window = np.full(48000, 0.2, dtype=np.float32)- t0 = time.perf_counter()+ # Would raise threading.BrokenBarrierError (via the executor future) if+ # the two passes ran sequentially instead of concurrently.result = p._verify_candidate(window) # noqa: SLF001- elapsed = time.perf_counter() - t0-assert result is True- # Sequential execution would cost >= 2 * SLEEP_S (~0.24 s). A generous- # margin (1.7x one sleep) leaves headroom for scheduler jitter while- # still failing hard on a regression back to sequential calls.- assert elapsed < _SlowFakeRecognizer.SLEEP_S * 1.7, (- f"_verify_candidate took {elapsed:.3f}s — looks SEQUENTIAL "- f"(~2x{_SlowFakeRecognizer.SLEEP_S}s), not concurrent"- )