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(i18n): translate German dev-comments to English in overlay bridge/schema/server (batch 05_3_jarvis, part 3)
Ruben Lütkec364530bda38
diff --git a/jarvis/overlay/__init__.py b/jarvis/overlay/__init__.pyindex 09a3d630d8..9200665ec9 100644--- a/jarvis/overlay/__init__.py+++ b/jarvis/overlay/__init__.py@@ -1,6 +1,6 @@-"""Overlay-Bridge Public-API. Plan §9.1.+"""Overlay bridge public API. Plan §9.1.-Hauptjarvis-Code importiert ausschliesslich von hier::+Main-Jarvis code imports exclusively from here::from jarvis.overlay import (get_overlay,@@ -9,9 +9,9 @@ Hauptjarvis-Code importiert ausschliesslich von hier::ActionKind,)-Sub-Agent-Detection (Plan §8.7 / AD-6) ist transparent: in Sub-Agents-returnt ``get_overlay()`` einen ``NoOpOverlayBridge``-Stub mit der-gleichen API. Caller-Code merkt strukturell nichts.+Sub-agent detection (Plan §8.7 / AD-6) is transparent: in sub-agents+``get_overlay()`` returns a ``NoOpOverlayBridge`` stub with the+same API. Caller code notices nothing structurally."""from __future__ import annotationsdiff --git a/jarvis/overlay/bridge.py b/jarvis/overlay/bridge.pyindex 9bbe8ee48e..ecfab8ec5b 100644--- a/jarvis/overlay/bridge.py+++ b/jarvis/overlay/bridge.py@@ -1,15 +1,15 @@-"""``OverlayBridge`` — Hauptjarvis-seitige IPC-Faceade.+"""``OverlayBridge`` — main-Jarvis-side IPC facade.Phase 9.2:-- ``send`` / ``send_nowait`` mit bounded ``asyncio.Queue(maxsize=256)``.-- Drop-Policy nach Plan §10.4: drop oldest non-state first, drop state last.-- WS-Handler-Coroutine fuer ``websockets.serve(...)``. Validiert eingehende- Messages via ``IPCMessage.validate_json``.-- Aktuellen State cachen (``last_state_envelope``) damit ein Reconnect den- Resync-Frame als erstes bekommt (§10.5).--Noch NICHT in 9.2: Coalescing (AD-17), Cursor-SHM, State-Machine. Phase 9.3-liefert die State-Machine ueber dieser Bridge.+- ``send`` / ``send_nowait`` with a bounded ``asyncio.Queue(maxsize=256)``.+- Drop policy per Plan §10.4: drop oldest non-state first, drop state last.+- WS handler coroutine for ``websockets.serve(...)``. Validates incoming+ messages via ``IPCMessage.validate_json``.+- Caches the current state (``last_state_envelope``) so a reconnect gets+ the resync frame first (§10.5).++NOT YET in 9.2: coalescing (AD-17), cursor SHM, state machine. Phase 9.3+delivers the state machine on top of this bridge."""from __future__ import annotations@@ -46,25 +46,25 @@ logger = logging.getLogger(__name__)OUTBOUND_QUEUE_MAX = 256INBOUND_QUEUE_MAX = 64-# Mock-Type fuer ``websockets.WebSocketServerProtocol``. Wir typen lose,-# damit der Modul-Import nicht von ``websockets`` abhaengt (Headless-Tests).+# Mock type for ``websockets.WebSocketServerProtocol``. We type loosely,+# so the module import doesn't depend on ``websockets`` (headless tests).WSConn = Anyclass _BoundedOutbox:- """Bounded Outbound-Queue mit Drop-Policy (§10.4).+ """Bounded outbound queue with drop policy (§10.4).- Implementiert als ``deque(maxlen=N)`` plus ``asyncio.Event`` fuer- Wake-Up. Wir benutzen kein ``asyncio.Queue.put_nowait``, weil dessen- Full-Behavior ``QueueFull``-Exception ist; wir wollen Drop-Oldest-Non-- State, also brauchen wir handcrafted Drop-Logic.+ Implemented as a ``deque(maxlen=N)`` plus an ``asyncio.Event`` for+ wake-up. We don't use ``asyncio.Queue.put_nowait`` because its+ full-behavior is a ``QueueFull`` exception; we want drop-oldest-non-+ state, so we need handcrafted drop logic."""def __init__(self, maxsize: int = OUTBOUND_QUEUE_MAX) -> None:self._max = maxsize- # ``deque`` ohne maxlen — Eviction machen wir selbst.+ # ``deque`` without maxlen — we handle eviction ourselves.self._buf: deque[bytes] = deque()- self._types: deque[str] = deque() # parallel zur _buf+ self._types: deque[str] = deque() # parallel to _bufself._wake = asyncio.Event()self._dropped = 0@@ -76,12 +76,12 @@ class _BoundedOutbox:return len(self._buf)def put(self, envelope_type: str, raw_json: bytes) -> bool:- """Non-blocking enqueue. Returnt ``True`` bei Aufnahme.+ """Non-blocking enqueue. Returns ``True`` on acceptance.- Drop-Policy: Wenn voll, droppe das aelteste *Non-State*-Element.- Wenn nur State-Elemente in der Queue sind, droppe nichts und- verwerfe stattdessen den NEUEN Non-State-Eintrag (state wird nie- gedroppt).+ Drop policy: if full, drop the oldest *non-state* element.+ If only state elements are in the queue, drop nothing and+ instead discard the NEW non-state entry (state is never+ dropped)."""if len(self._buf) < self._max:self._buf.append(raw_json)@@ -89,10 +89,10 @@ class _BoundedOutbox:self._wake.set()return True- # Voll. Suche aelteste Non-State.+ # Full. Look for the oldest non-state.for idx, t in enumerate(self._types):if not is_state_type(t):- # Diesen Eintrag rauswerfen.+ # Evict this entry.del self._buf[idx]del self._types[idx]self._buf.append(raw_json)@@ -101,9 +101,9 @@ class _BoundedOutbox:self._wake.set()return True- # Queue komplett State. Dann darf nur ein State-Element rein.+ # Queue is entirely state. Then only one state element may go in.if is_state_type(envelope_type):- # Aeltesten State droppen.+ # Drop the oldest state.self._buf.popleft()self._types.popleft()self._buf.append(raw_json)@@ -112,12 +112,12 @@ class _BoundedOutbox:self._wake.set()return True- # Non-State + nur State in Queue -> neuen droppen.+ # Non-state + only state in queue -> drop the new one.self._dropped += 1return Falseasync def get(self) -> bytes:- """Async pop. Blockiert bis ein Element verfuegbar ist."""+ """Async pop. Blocks until an element is available."""while not self._buf:self._wake.clear()await self._wake.wait()@@ -132,7 +132,7 @@ class _BoundedOutbox:class OverlayBridge:- """Hauptjarvis-seitige WS-Server-Bridge.+ """Main-Jarvis-side WS server bridge.Lifecycle:bridge = OverlayBridge()@@ -140,7 +140,7 @@ class OverlayBridge:# ... bridge.emit_state(...) etc ...await bridge.stop()- WS-Handler:+ WS handler:await websockets.serve(bridge.handler, "127.0.0.1", port)"""@@ -166,7 +166,7 @@ class OverlayBridge:returnself._running = Trueself._started_at_ns = now_ns()- # Heartbeat-Pump alle ``_heartbeat_interval`` Sekunden.+ # Heartbeat pump every ``_heartbeat_interval`` seconds.self._tasks.append(asyncio.create_task(self._heartbeat_loop(), name="overlay-heartbeat"))@@ -188,15 +188,15 @@ class OverlayBridge:# --- public emit-API (sync, queue-only) ---def send_nowait(self, envelope: Any) -> bool:- """Sync-API. Serialisiert das Envelope und pusht in die Outbox."""+ """Sync API. Serializes the envelope and pushes it into the outbox."""raw = envelope.model_dump_json().encode("utf-8")if isinstance(envelope, StateEnvelope):self._last_state_envelope = envelopereturn self._outbox.put(envelope.type, raw)async def send(self, envelope: Any) -> bool:- """Async-API. Aktuell identisch zu ``send_nowait`` weil die Queue- non-blocking ist; signature bleibt async fuer 9.3+ Erweiterungen."""+ """Async API. Currently identical to ``send_nowait`` because the+ queue is non-blocking; the signature stays async for 9.3+ extensions."""return self.send_nowait(envelope)def emit_state(@@ -222,8 +222,8 @@ class OverlayBridge:duration_hint_ms: Optional[int] = None,action_id: Optional[str] = None,) -> str:- """Plan §8.4 — vor Function-Call. Returnt die action_id damit- emit_action_ended sie referenzieren kann."""+ """Plan §8.4 — before the function call. Returns the action_id so+ emit_action_ended can reference it."""aid = action_id or new_ulid()env = ActionStartedEnvelope(payload=ActionStartedPayload(@@ -242,7 +242,7 @@ class OverlayBridge:succeeded: bool = True,duration_actual_ms: Optional[int] = None,) -> bool:- """Plan §8.4 — im finally-Block (auch bei Exception)."""+ """Plan §8.4 — in the finally block (also on exception)."""env = ActionEndedEnvelope(payload=ActionEndedPayload(action_id=action_id,@@ -261,7 +261,7 @@ class OverlayBridge:button: str = "left",modifiers: Optional[list[str]] = None,) -> bool:- """Plan §14.3 — emit BEFORE pyautogui.click() so Visual reicht+ """Plan §14.3 — emit BEFORE pyautogui.click() so Visual reachesWebView before OS Click Event finished propagating."""env = ClickEnvelope(payload=ClickPayload(@@ -282,7 +282,7 @@ class OverlayBridge:recoverable: bool = True,context: Optional[dict[str, Any]] = None,) -> bool:- """Plan §8.4 — bei Exception in @overlay_action."""+ """Plan §8.4 — on exception in @overlay_action."""env = ErrorEnvelope(payload=ErrorPayload(code=code,@@ -313,10 +313,10 @@ class OverlayBridge:# --- WS handler ---async def handler(self, websocket: WSConn) -> None:- """``websockets.serve(...)``-kompatibler Handler.+ """``websockets.serve(...)``-compatible handler.- State-Resync per §10.5: erstes Frame nach Connect ist der zuletzt- bekannte State (falls vorhanden).+ State resync per §10.5: the first frame after connect is the last+ known state (if any)."""self._connected.add(websocket)try:@@ -381,12 +381,12 @@ class OverlayBridge:def envelope_to_json(envelope: Any) -> bytes:- """Helper fuer Tests."""+ """Helper for tests."""return envelope.model_dump_json().encode("utf-8")# --------------------------------------------------------------------------# Sub-Agent No-Op-Stub. Plan §8.7 / AD-6.+# Sub-agent no-op stub. Plan §8.7 / AD-6.# -------------------------------------------------------------------------@@ -394,8 +394,8 @@ JARVIS_DEPTH_ENV: str = "JARVIS_DEPTH"def is_sub_agent_process() -> bool:- """True wenn ``JARVIS_DEPTH > 0`` env. Sub-Agent-Code laeuft mit- Depth >= 1 (Phase-5-Convention)."""+ """True when the ``JARVIS_DEPTH > 0`` env is set. Sub-agent code runs with+ depth >= 1 (Phase-5 convention)."""raw = os.environ.get(JARVIS_DEPTH_ENV, "0")try:return int(raw) > 0@@ -404,16 +404,16 @@ def is_sub_agent_process() -> bool:class NoOpOverlayBridge:- """No-Op-Stub fuer Sub-Agents. Plan §8.7 / AD-6.+ """No-op stub for sub-agents. Plan §8.7 / AD-6.- Hat dieselbe Public-API wie ``OverlayBridge``, aber alle Methoden- sind Lifeless-Stubs. Sub-Agent-Code kann daher dasselbe Pattern- schreiben (``bridge.emit_click(...)``) ohne Special-Casing — die- Events landen einfach im Void.+ Has the same public API as ``OverlayBridge``, but all methods+ are lifeless stubs. Sub-agent code can therefore write the same+ pattern (``bridge.emit_click(...)``) without special-casing — the+ events simply vanish into the void.- Wichtig: Wir vererben NICHT von OverlayBridge weil dessen __init__- eine asyncio.Queue baut und in Sub-Agent-Sync-Pfaden gibt es ggf.- keinen Event-Loop. Stattdessen duck-typed Stub.+ Important: we do NOT inherit from OverlayBridge because its __init__+ builds an asyncio.Queue, and sub-agent sync paths may have no+ event loop. Instead: a duck-typed stub."""@property@@ -444,7 +444,7 @@ class NoOpOverlayBridge:self,_state: str,*,- intensity: float = 1.0, # noqa: ARG002 — API-Symmetrie+ intensity: float = 1.0, # noqa: ARG002 — API symmetryreason: Optional[str] = None, # noqa: ARG002) -> bool:return False@@ -456,7 +456,7 @@ class NoOpOverlayBridge:duration_hint_ms: Optional[int] = None, # noqa: ARG002action_id: Optional[str] = None,) -> str:- # Stub returnt eine action_id damit Caller-Code weiterlaufen kann.+ # Stub returns an action_id so caller code can keep going.return action_id or "noop"def emit_action_ended(diff --git a/jarvis/overlay/schema.py b/jarvis/overlay/schema.pyindex b12959b6d2..ecc2bbb033 100644--- a/jarvis/overlay/schema.py+++ b/jarvis/overlay/schema.py@@ -1,18 +1,18 @@-"""IPC-Schemas (Hauptjarvis-Seite) — Re-Export aus dem OS-Level-Package.+"""IPC schemas (main-Jarvis side) — re-export from the OS-Level package.-AD-15: Single-Source. Jede Aenderung am Wire-Format passiert in-``OS-Level/src/overlay/schema.py``; hier nur Re-Imports.+AD-15: single source. Every change to the wire format happens in+``OS-Level/src/overlay/schema.py``; here only re-imports.-Das ``OS-Level/src``-Verzeichnis muss im ``sys.path`` liegen, damit-``import overlay.schema`` greift. Der Hauptjarvis-Bootstrap-Pfad-(``jarvis.overlay.server.start_ipc_server``) erweitert ``sys.path`` lazy-beim ersten Aufruf, damit der Import nicht beim Modul-Load schon failt-falls jemand ``jarvis.overlay`` einzeln importiert.+The ``OS-Level/src`` directory must be on ``sys.path`` for+``import overlay.schema`` to work. The main-Jarvis bootstrap path+(``jarvis.overlay.server.start_ipc_server``) extends ``sys.path`` lazily+on first call, so the import doesn't already fail at module load+if someone imports ``jarvis.overlay`` in isolation."""from __future__ import annotations-# sys.path-Erweiterung lazy in jarvis/overlay/__init__.py geregelt.+# sys.path extension handled lazily in jarvis/overlay/__init__.py.from overlay.schema import ( # noqa: F401 (re-exports)AckEnvelope,AckPayload,diff --git a/jarvis/overlay/server.py b/jarvis/overlay/server.pyindex 92814f6d37..45e7637809 100644--- a/jarvis/overlay/server.py+++ b/jarvis/overlay/server.py@@ -1,8 +1,8 @@-"""WS-IPC-Server fuer den Hauptjarvis-Prozess.+"""WS IPC server for the main-Jarvis process.-Plan §10.5 + §20.3: WS-Server bindet auf 127.0.0.1 + freien Port aus-``[overlay].ws_port..ws_port_range_max``. Bridge ist die Faceade,-``websockets.serve()`` ist der Wire-Layer.+Plan §10.5 + §20.3: the WS server binds to 127.0.0.1 + a free port from+``[overlay].ws_port..ws_port_range_max``. The bridge is the facade,+``websockets.serve()`` is the wire layer."""from __future__ import annotations@@ -22,7 +22,7 @@ logger = logging.getLogger(__name__)@dataclassclass IPCServerHandle:- """Was ``start_ipc_server`` zurueckgibt."""+ """What ``start_ipc_server`` returns."""bridge: OverlayBridgeserver: Server@@ -43,18 +43,18 @@ async def start_ipc_server(bridge: Optional[OverlayBridge] = None,path: str = "/overlay",) -> IPCServerHandle:- """Suche freien Port in ``[port, port_range_max]`` und starte WS-Server.+ """Search for a free port in ``[port, port_range_max]`` and start the WS server.- Plan-Constraint: ``host`` muss Loopback sein (Pydantic-Validator- erzwingt das beim Config-Load; hier defensiv nochmal pruefen).+ Plan constraint: ``host`` must be loopback (a Pydantic validator+ enforces this at config load; checked defensively again here).- ``path`` wird bewusst nicht enforced — der Plan §10 nennt- ``/overlay`` als Convention; der ``websockets``-Lib-Handler sieht- aber alle URIs unter dem Bind-Host. Pfad-Filter machen wir im- Bridge-Handler nur wenn noetig (aktuell nicht).+ ``path`` is deliberately not enforced — Plan §10 names+ ``/overlay`` as the convention; the ``websockets`` library handler,+ however, sees all URIs under the bind host. We only do path+ filtering in the bridge handler if needed (currently not)."""if host not in {"127.0.0.1", "::1", "localhost"}:- raise ValueError(f"WS-Server muss auf Loopback binden, host={host!r}")+ raise ValueError(f"WS server must bind to loopback, host={host!r}")if port_range_max < port:raise ValueError(f"port_range_max < port ({port_range_max} < {port})")@@ -71,10 +71,10 @@ async def start_ipc_server(logger.info("overlay WS-Server listening on ws://%s:%d%s", host, candidate, path)return IPCServerHandle(bridge=bridge, server=server, host=host, port=candidate)- # Alle Ports belegt.+ # All ports taken.await bridge.stop()raise RuntimeError(- f"kein freier Port in [{port}, {port_range_max}] (last={last_err!r})"+ f"no free port in [{port}, {port_range_max}] (last={last_err!r})")