Skip to main content
WS /watch/{pid} gives your agent a live feed of state changes without polling. After you establish the WebSocket connection, the daemon sends a JSON notification every time a probe cycle detects that one or more state keys have changed. The message tells you which keys changed and at what timestamp — your agent can then call GET /state/{pid} or GET /diff/{pid} to read the new values. This pattern is far more efficient than polling /state in a tight loop.

Endpoint

Path Parameters

Authentication

Pass your API key as the key query parameter. WebSocket clients do not reliably support custom HTTP headers during the upgrade handshake, so the query parameter approach is required.

Message Format

The server sends a JSON object for each state change event. Your client receives these messages asynchronously as the daemon completes probe cycles.
integer
OS process ID of the application that changed.
string
Stable semantic identifier for the application.
integer
Monotonically increasing counter for change events on this connection. If you observe a gap in sequence numbers, events were dropped or the connection was briefly interrupted.
string[]
Dot-notation state keys whose values changed since the previous probe cycle, for example "inbox.unread_count" or "inbox.emails[0].is_read".
datetime
ISO 8601 timestamp (with millisecond precision) of the probe cycle that detected the change.

Behavior

  • The daemon fires a notification on every probe cycle that detects at least one changed key. Cycles with no changes produce no message.
  • The default probe interval is 2 seconds. Your agent should not assume a specific cadence — intervals can vary based on application activity.
  • When the tracked process exits, the daemon closes the WebSocket with close code 1000 (normal closure).
  • If the daemon itself restarts, the connection is dropped without a close frame. Your client should detect this and reconnect.
  • There is no heartbeat or server-side ping. If you need to detect stale connections, implement a client-side ping or timeout.

Examples

Error Responses (HTTP Upgrade Phase)

These errors occur during the initial HTTP-to-WebSocket upgrade request, before the connection is established.