Skip to content

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.

chore: auto-save WIP via Claude stop-hook safety net (2026-07-02 09:40)

Ruben Lütke901f04473407
diff --git a/README.md b/README.md
index 042101fd6c..cb58768419 100644
--- a/README.md
+++ b/README.md
@@ -17,8 +17,14 @@
</p>
<p align="center">
- <img src="assets/video/personal-jarvis-demo.gif" alt="Demo: a spoken command delegates real work to an agent, which edits the code, runs the tests, and opens the pull request" width="860" />
+ <a href="assets/video/personal-jarvis-demo.mp4">
+ <img src="assets/video/personal-jarvis-demo.gif" alt="Demo: a spoken command delegates real work to an agent, which edits the code, runs the tests, and opens the pull request" width="860" />
+ </a>
</p>
+<!-- Fallback: if the GIF ever fails to render inline (proxy/size limits), swap
+ the <img> above for the static poster frame — same click-through to the MP4:
+ <img src="assets/video/personal-jarvis-demo-poster.png" alt="Demo poster: the agent finished the job — pull request #129 is open" width="860" />
+-->
<p align="center">
<b><a href="assets/video/personal-jarvis-demo.mp4">▶ Watch the full 60-second demo with sound</a></b>
diff --git a/jarvis/cu/actuate/__init__.py b/jarvis/cu/actuate/__init__.py
index 5c12d26300..86b975df1d 100644
--- a/jarvis/cu/actuate/__init__.py
+++ b/jarvis/cu/actuate/__init__.py
@@ -14,10 +14,10 @@ tools remain the ToolExecutor-gated choke points (AP-3) and delegate their
raw input to this package.
"""
from jarvis.cu.actuate.base import (
+ LANDING_TOLERANCE,
ActResult,
ActuationUnavailable,
Actuator,
- LANDING_TOLERANCE,
get_actuator,
verified_move,
)
diff --git a/jarvis/cu/brain_call.py b/jarvis/cu/brain_call.py
index 1c371ef506..370473c3ad 100644
--- a/jarvis/cu/brain_call.py
+++ b/jarvis/cu/brain_call.py
@@ -20,8 +20,9 @@ credential readback the legacy engine had.
from __future__ import annotations
import logging
+from collections.abc import Callable
from dataclasses import dataclass
-from typing import Any, Callable
+from typing import Any
from jarvis.core.protocols import BrainMessage, BrainRequest, ImageBlock
diff --git a/jarvis/cu/capture.py b/jarvis/cu/capture.py
index 8e30fce895..ee7f0847f6 100644
--- a/jarvis/cu/capture.py
+++ b/jarvis/cu/capture.py
@@ -27,9 +27,10 @@ import hashlib
import io
import logging
import time
+from collections.abc import Callable
from dataclasses import dataclass
from pathlib import Path
-from typing import Callable, Protocol
+from typing import Protocol
from jarvis.cu.geometry import CoordinateMapper, MonitorInfo, input_space
diff --git a/jarvis/cu/engine.py b/jarvis/cu/engine.py
index 4b87a38b90..b6c506ebd2 100644
--- a/jarvis/cu/engine.py
+++ b/jarvis/cu/engine.py
@@ -282,7 +282,7 @@ async def _dispatch_tool(
),
timeout=_ACT_TIMEOUT_S,
)
- except asyncio.TimeoutError:
+ except TimeoutError:
return False, f"{tool_name} timed out after {_ACT_TIMEOUT_S:.0f}s"
except Exception as exc: # noqa: BLE001
return False, f"{tool_name} crash: {type(exc).__name__}: {exc}"
@@ -506,31 +506,43 @@ async def run_cu_loop(
t0 = time.monotonic()
conventions_used: dict[str, CoordinateConvention] = {}
- def _build_prompt(provider: str, brain: Any) -> tuple[str, str]:
+ def _build_prompt(
+ provider: str,
+ brain: Any,
+ *,
+ # Bind THIS step's perception explicitly (B023): the builder runs
+ # inside the same iteration, but explicit defaults make that a
+ # structural guarantee instead of a timing accident.
+ _frame: Frame = frame,
+ _title: str = window_title,
+ _labels: list[str] = labels,
+ _field_hint: str = field_hint,
+ _conv_used: dict[str, CoordinateConvention] = conventions_used,
+ ) -> tuple[str, str]:
convention = conv_mod.resolve_convention(
provider, brain, config_override=coordinate_space,
)
- conventions_used[provider] = convention
+ _conv_used[provider] = convention
system = (
_SYSTEM_BASE
+ conv_mod.coordinate_prompt_block(
- convention, frame.image_width, frame.image_height,
+ convention, _frame.image_width, _frame.image_height,
)
+ "\n\n"
+ conv_mod.action_grammar_block()
)
lines = [f"GOAL: {goal}"]
- if window_title:
- lines.append(f"FOREGROUND WINDOW: {window_title}")
- if labels:
- lines.append("CLICKABLE ELEMENTS: " + ", ".join(labels))
- if field_hint:
- lines.append(field_hint.strip())
+ if _title:
+ lines.append(f"FOREGROUND WINDOW: {_title}")
+ if _labels:
+ lines.append("CLICKABLE ELEMENTS: " + ", ".join(_labels))
+ if _field_hint:
+ lines.append(_field_hint.strip())
tail = history[-_HISTORY_TAIL:]
lines.append(
"PREVIOUS STEPS:\n" + ("\n".join(tail) if tail else "(none)"),
)
- if not frame.stable:
+ if not _frame.stable:
lines.append(
"NOTE: the screen was still changing when this screenshot "
"was captured — verify carefully before acting.",
diff --git a/jarvis/cu/geometry.py b/jarvis/cu/geometry.py
index 4bb862e138..f78748163a 100644
--- a/jarvis/cu/geometry.py
+++ b/jarvis/cu/geometry.py
@@ -34,9 +34,10 @@ from __future__ import annotations
import logging
import os
+from collections.abc import Iterator
from contextlib import contextmanager
from dataclasses import dataclass
-from typing import Iterator, Literal
+from typing import Literal
logger = logging.getLogger(__name__)
diff --git a/jarvis/harness/computer_use_context.py b/jarvis/harness/computer_use_context.py
index 5ca54f47c4..b528da0d04 100644
--- a/jarvis/harness/computer_use_context.py
+++ b/jarvis/harness/computer_use_context.py
@@ -257,7 +257,7 @@ def _refresh_context_from_config() -> None:
pass
-def subscribe_context_reload(bus: "EventBus | None") -> None:
+def subscribe_context_reload(bus: EventBus | None) -> None:
"""Subscribe the CU context to ``ConfigReloaded`` (idempotent per bus).
Called once after the context is wired (jarvis/brain/factory.py). On every
diff --git a/jarvis/plugins/harness/computer_use.py b/jarvis/plugins/harness/computer_use.py
index f53ea97cc3..20591371ea 100644
--- a/jarvis/plugins/harness/computer_use.py
+++ b/jarvis/plugins/harness/computer_use.py
@@ -24,6 +24,7 @@ from jarvis.harness.computer_use_context import (
register_active_cu_token,
unregister_active_cu_token,
)
+
_log = logging.getLogger(__name__)
_TIMEOUT_EXIT_CODE = 124
@@ -153,7 +154,7 @@ class ComputerUseHarness:
while True:
remaining_s = deadline - time.monotonic()
if remaining_s <= 0:
- raise asyncio.TimeoutError
+ raise TimeoutError
try:
chunk = await asyncio.wait_for(
anext(stream),
@@ -164,7 +165,7 @@ class ComputerUseHarness:
yield chunk
if chunk.is_final:
return
- except asyncio.TimeoutError:
+ except TimeoutError:
token.cancel("computer_use_harness_timeout")
duration_ms = (time.time_ns() - t_start) // 1_000_000
yield HarnessResult(
diff --git a/jarvis/plugins/tool/click.py b/jarvis/plugins/tool/click.py
index bdb382e56c..04c84e5cc4 100644
--- a/jarvis/plugins/tool/click.py
+++ b/jarvis/plugins/tool/click.py
@@ -23,6 +23,8 @@ from jarvis.control.cursor_motion import glide_os_cursor
from jarvis.core.protocols import ExecutionContext, ToolResult
from jarvis.cu.actuate.windows import (
_MOUSE_FLAGS_DOWN,
+)
+from jarvis.cu.actuate.windows import (
normalize_virtualdesk as _normalize_virtualdesk, # noqa: F401 — re-export (tests + callers)
)
from jarvis.overlay.virtual_cursor import get_virtual_cursor
diff --git a/jarvis/plugins/tool/hotkey.py b/jarvis/plugins/tool/hotkey.py
index 7a0c621947..435183e895 100644
--- a/jarvis/plugins/tool/hotkey.py
+++ b/jarvis/plugins/tool/hotkey.py
@@ -17,12 +17,13 @@ from typing import Any
from jarvis.core.protocols import ExecutionContext, ToolResult
-
# Key-name resolution + combined-token expansion ("ctrl+v" -> ["ctrl", "v"])
# live in the shared CU v2 Windows backend; re-exported here so callers and
# tests keep their import path. The vocabulary is unchanged.
from jarvis.cu.actuate.windows import ( # noqa: E402
expand_combo_keys as _expand_combo_keys,
+)
+from jarvis.cu.actuate.windows import (
resolve_vk as _resolve_vk,
)
diff --git a/jarvis/plugins/tool/scroll.py b/jarvis/plugins/tool/scroll.py
index e29601c4de..d347078aa1 100644
--- a/jarvis/plugins/tool/scroll.py
+++ b/jarvis/plugins/tool/scroll.py
@@ -18,7 +18,6 @@ from typing import Any
from jarvis.core.protocols import ExecutionContext, ToolResult
-
# One wheel notch in Windows units (WHEEL_DELTA).
_WHEEL_DELTA: int = 120
diff --git a/jarvis/plugins/tool/type_text.py b/jarvis/plugins/tool/type_text.py
index 598de838f5..c7ad2f1866 100644
--- a/jarvis/plugins/tool/type_text.py
+++ b/jarvis/plugins/tool/type_text.py
@@ -12,7 +12,6 @@ from __future__ import annotations
import asyncio
import logging
import os
-import time
from typing import Any
from jarvis.core.protocols import ExecutionContext, ToolResult
diff --git a/jarvis/speech/wake_phrase.py b/jarvis/speech/wake_phrase.py
index 9e1ef9f64e..a54ed2a167 100644
--- a/jarvis/speech/wake_phrase.py
+++ b/jarvis/speech/wake_phrase.py
@@ -32,6 +32,7 @@ from jarvis.speech.wake_constants import (
DEFAULT_WAKE_PHRASE,
JARVIS_WAKE_PATTERN,
WAKE_ENGINES,
+ WAKE_PREFIXES,
match_known_oww_model,
normalize_phrase_for_match,
phrase_core,
@@ -86,9 +87,13 @@ class WakeMatcher:
- jarvis-default: wraps the canonical :data:`JARVIS_WAKE_PATTERN`.
- arbitrary phrase: fuzzy token-window match against a normalised
- transcript using ``difflib.SequenceMatcher``. A phrase that explicitly
- starts with a wake prefix ("Hey Athena") must match that prefix too, so a
- bare core word does not re-trigger the listener.
+ transcript using ``difflib.SequenceMatcher``. When the configured phrase
+ starts with a known wake prefix ("Hey Fable"), the matched window must be
+ IMMEDIATELY preceded by a prefix token too (``require_known_prefix``) —
+ the bare core word inside ordinary speech must NOT activate (user mandate
+ 2026-07-02; measured 71.7 % false accepts on real bare-core windows
+ before this). Any known prefix counts, not just the configured one, so an
+ STT that writes "Hallo Fable" for a spoken "Hey Fable" still matches.
"""
def __init__(
@@ -98,6 +103,7 @@ class WakeMatcher:
core_tokens: list[str] | None = None,
fuzzy_ratio: float = 0.8,
is_jarvis_default: bool = False,
+ require_known_prefix: bool = False,
) -> None:
self._pattern = pattern
# Sound-fold the core so a sound-equivalent ASR spelling of the wake word
@@ -105,6 +111,10 @@ class WakeMatcher:
self._core = [sound_fold(c) for c in (core_tokens or [])]
self._ratio = fuzzy_ratio
self._is_jarvis = is_jarvis_default
+ self._require_prefix = require_known_prefix
+ # Folded prefix family: the window before the core must fuzzy-match ANY
+ # of these when the configured phrase itself carries a prefix.
+ self._folded_prefixes = tuple({sound_fold(p) for p in WAKE_PREFIXES})
@property
def is_jarvis_default(self) -> bool:
@@ -130,6 +140,14 @@ class WakeMatcher:
one_sub_ratio = (n - 1) / n if n else 1.0
return min(self._ratio, max(0.6, one_sub_ratio - 0.01))
+ def _is_prefix_token(self, folded_token: str) -> bool:
+ """True when ``folded_token`` fuzzy-matches ANY known wake prefix."""
+ return any(
+ SequenceMatcher(None, p, folded_token).ratio()
+ >= self._effective_ratio(p)
+ for p in self._folded_prefixes
+ )
+
def search(self, text: str) -> Any | None:
"""Return a match object (``.group(0)``) or ``None``. Never raises."""
if not text:
@@ -139,26 +157,37 @@ class WakeMatcher:
# Compare on sound-FOLDED tokens so a sound-equivalent ASR spelling of the
# wake word lines up with the (also folded) core, but return the ORIGINAL
# heard text as the match so the yielded keyword / logs are unchanged.
- # Prefix stripping already happened for the core, and the transcript is
- # only window-scanned for the core token, so folding here has no prefix
- # side effect.
orig = normalize_phrase_for_match(text)
folded = [sound_fold(t) for t in orig]
n = len(self._core)
if n == 0 or len(folded) < n:
return None
- # Length-aware threshold: average the per-core-token required ratios so a
- # short name tolerates a little pronunciation drift while a longer one
- # (or a multi-word phrase with long tokens) keeps the strict bar.
- threshold = sum(self._effective_ratio(c) for c in self._core) / n
+ # EVERY core token must individually clear its own length-aware bar
+ # (short names tolerate ~one character of ASR drift, longer tokens keep
+ # the configured ratio). Averaging across tokens is deliberately NOT
+ # used: with the prefix in the window a perfect "hey" would subsidise a
+ # half-matching core word — exactly the loosening the 2026-07-02
+ # fire-only-on-the-phrase mandate forbids.
for i in range(0, len(folded) - n + 1):
window = folded[i : i + n]
- score = sum(
- SequenceMatcher(None, c, w).ratio()
+ ok = all(
+ SequenceMatcher(None, c, w).ratio() >= self._effective_ratio(c)
for c, w in zip(self._core, window, strict=False)
- ) / n
- if score >= threshold:
- return _FuzzyMatch(" ".join(orig[i : i + n]))
+ )
+ if not ok:
+ continue
+ if self._require_prefix:
+ # The configured phrase has a wake prefix ("Hey Fable") -> the
+ # core must be IMMEDIATELY preceded by a prefix token. The bare
+ # core word inside ordinary speech ("1 Fable Pro", "Nico, mein
+ # Barsch.") stays silent — the 2026-07-02 user mandate that
+ # REVERSED the 2026-06-29 "prefix optional" trade-off. Any
+ # known prefix counts ("Hallo Fable" still wakes a "Hey Fable"
+ # config; ASR often localises the greeting).
+ if i == 0 or not self._is_prefix_token(folded[i - 1]):
+ continue
+ return _FuzzyMatch(" ".join(orig[i - 1 : i + n]))
+ return _FuzzyMatch(" ".join(orig[i : i + n]))
return None
@@ -166,28 +195,36 @@ def compile_wake_matcher(phrase: str, *, fuzzy_ratio: float = 0.8) -> WakeMatche
"""Build a :class:`WakeMatcher` for ``phrase``.
The default "Hey Jarvis" (and any jarvis-only phrase) is matched by the
- strict legacy pattern. Every other phrase fuzzy-matches on its CORE tokens —
- the distinctive word(s) after any leading wake prefix ("Hey", "Hallo", "Ok",
- ...). So "Hey Nico" fires on "nico", whether or not the "Hey" prefix made it
- into the transcript.
-
- Why the prefix is OPTIONAL, not required (live forensic 2026-06-29, custom
- wake "Hey Nico"): the rolling-whisper poll transcribes ~1.8 s windows, and on
- a slow local model the effective cadence (~1.7 s) is close to the window
- length, so a short spoken "Hey Nico" routinely lands SPLIT across snapshots —
- one window catches only "Hey", the next only "…nico". Requiring "hey"+"nico"
- ADJACENT then drops both halves and the user has to repeat the wake many
- times ("I have to say it ten times"). Matching the distinctive core alone
- catches the "…nico" / "nico" windows too, which is exactly the user's
- "trigger super easily" mandate. The cost is that the bare name spoken in
- ambient speech while IDLE can wake the listener — an accepted trade ("lieber
- leichter triggern als schwer"); the no_speech / RMS / fuzzy guards still
- reject silence and unrelated words, and the wake loop only listens when IDLE.
+ strict legacy pattern. Every other phrase fuzzy-matches on its CORE tokens;
+ when the configured phrase itself starts with a known wake prefix ("Hey
+ Fable"), the prefix is REQUIRED immediately before the core (any known
+ prefix counts — "Hallo Fable" still wakes a "Hey Fable" config).
+
+ History: 2026-06-29 deliberately made the prefix OPTIONAL ("lieber leichter
+ triggern als schwer") because the slow poll cadence (~1.7 s vs a 1.8 s
+ window) split the phrase across snapshots. That trade-off is REVERSED by
+ explicit user instruction (2026-07-02): the bare core word in ordinary /
+ dictated speech kept activating Jarvis (live: 'WAKE matched fable in
+ "1 Fable Pro"', 'nico in "Nico, mein Barsch."'; bench: 71.7 % false accepts
+ on real bare-core windows). Fire ONLY on the configured phrase. The
+ split-window concern is addressed by the faster transcription cadence
+ (2026-07-02 wake-latency work) — consecutive windows overlap by more than a
+ spoken two-word phrase, so a genuine wake still lands whole in at least one
+ window. A single-word phrase ("Computer") has no prefix to require; the
+ word itself is the phrase, matched anywhere (inherent to one-word wakes).
"""
+ tokens = normalize_phrase_for_match(phrase)
core = phrase_core_for_match(phrase)
if core == ["jarvis"]:
return WakeMatcher(pattern=JARVIS_WAKE_PATTERN, is_jarvis_default=True)
- return WakeMatcher(core_tokens=core, fuzzy_ratio=fuzzy_ratio)
+ # A leading known prefix was stripped from the core -> the user's phrase
+ # carries one -> demand it in the transcript too.
+ has_prefix = len(core) < len(tokens)
+ return WakeMatcher(
+ core_tokens=core,
+ fuzzy_ratio=fuzzy_ratio,
+ require_known_prefix=has_prefix,
+ )
def _canonical_keyword(phrase: str) -> str:
diff --git a/tests/unit/speech/test_wake_phrase.py b/tests/unit/speech/test_wake_phrase.py
index cbff10f558..ee855f0a9b 100644
--- a/tests/unit/speech/test_wake_phrase.py
+++ b/tests/unit/speech/test_wake_phrase.py
@@ -114,29 +114,32 @@ def test_arbitrary_phrase_tolerates_diacritic_transcription_drift() -> None:
assert m.search("hey rubén") is not None
-def test_prefix_phrase_also_fires_on_bare_core() -> None:
- # Mission 2026-06-29 ("trigger super easily" / "I say it ten times"): the
- # leading wake prefix is OPTIONAL. The slow rolling-whisper poll routinely
- # splits a short "Hey Nico" so one window holds only "Hey" and the next only
- # "…nico"; requiring "hey"+"athena" ADJACENT drops both halves. Firing on the
- # distinctive CORE ("athena"/"nico") alone catches the partial windows — the
- # accepted easy-trigger trade. Still matches the full phrase too.
+def test_prefix_phrase_requires_the_prefix() -> None:
+ # User mandate 2026-07-02 (REVERSES the 2026-06-29 "prefix optional"
+ # trade-off): Jarvis kept activating on the bare core word inside ordinary
+ # speech (live: 'WAKE matched fable in "1 Fable Pro"'; bench: 71.7 % false
+ # accepts on real bare-core windows). A phrase configured WITH a prefix
+ # fires ONLY when a wake prefix immediately precedes the core.
m = compile_wake_matcher("Hey Athena")
- assert m.search("hey athena") is not None # full phrase still fires
- assert m.search("athena") is not None # bare core now fires (easy trigger)
- assert m.search("the weather is nice") is None # unrelated still rejected
+ assert m.search("hey athena") is not None # full phrase fires
+ assert m.search("hallo athena") is not None # prefix family counts
+ assert m.search("athena") is None # bare core stays silent
+ assert m.search("i met athena today") is None # core mid-sentence: silent
+ assert m.search("the weather is nice") is None # unrelated rejected
-def test_hey_nico_fires_on_partial_and_drifted_windows() -> None:
- # The user's real phrase. The prefix-split windows + STT drift that made it
- # "need ten tries" must now all wake: full phrase, bare name, name-only tail,
- # and a one-char mishearing — while unrelated speech is still rejected.
+def test_hey_nico_fires_only_on_the_full_phrase() -> None:
+ # The user's real-world case. Full phrase + STT spelling drift must wake;
+ # the bare name in ordinary/dictated speech must NOT (that was the
+ # "Jarvis spawns although I did not call it" bug, live-logged 2026-07-02).
m = compile_wake_matcher("Hey Nico")
- assert m.search("hey nico") is not None # full phrase
- assert m.search("nico") is not None # prefix split — name-only window
- assert m.search("ja nico komm") is not None # name mid-utterance
- assert m.search("niko") is not None # STT drift (one char)
- assert m.search("wie spät ist es") is None # unrelated -> no wake # i18n-allow
+ assert m.search("hey nico") is not None # full phrase
+ assert m.search("hey niko") is not None # STT drift (one char)
+ assert m.search("hallo nico alles gut") is not None # localised greeting
+ assert m.search("nico") is None # bare name: silent
+ assert m.search("ja nico komm") is None # name mid-utterance: silent
+ assert m.search("nico mein barsch") is None # the live false fire: silent
+ assert m.search("wie spät ist es") is None # unrelated -> no wake # i18n-allow
def test_multi_word_core_phrase_matches_in_order() -> None: