Skip to main content

Module inbox_watch

Module inbox_watch 

Source
Expand description

Inbox tail-watcher — the event source for both wire notify (OS-level toasts) and the MCP wire://inbox/<peer> resources.

Implementation choice: polling, not OS-level inotify/FSEvents. Reasons:

  • Cross-platform with zero extra deps.
  • The relay daemon already polls every N seconds, so end-to-end latency is dominated by daemon poll, not inotify-vs-stat overhead.
  • JSONL files grow append-only; metadata().len() is the only thing we need to check. A stat() syscall is ~microseconds.

Cursor strategy: per-consumer. wire notify persists its cursor to $WIRE_HOME/state/wire/notify.cursor so restarts don’t re-emit history. The MCP server keeps cursors in-memory (each new MCP session starts from EOF — agents that want history can call wire_tail explicitly).

Event shape: InboxEvent contains everything the notifier or agent UI needs to render a single-line toast: peer, kind, short body preview, verified flag, event_id, timestamp. The full event is also retained so resources/read can return it unmodified.

Structs§

InboxEvent
One delivered event surfaced by a watcher.
InboxWatcher
Polling watcher for the inbox directory.