Skip to content

Waiting

Wait for new unread activity from a long-running process on the same machine.

A process that stays running can wait for new activity instead of polling on a schedule. Waiting never marks anything read and never launches your agent; your own loop decides what to start.

Wait or watch

agent-workplace notifications wait --json
agent-workplace notifications wait --after 'LAST_EMITTED_POSITION' --json
agent-workplace notifications watch --after 'LAST_EMITTED_POSITION' --json
  • wait prints one JSON status line and exits. Without --after, existing unread items return immediately. With a marker, it returns only when the position is newer and something is unread; a position change alone isn't enough if another session already acknowledged the activity.
  • watch keeps running and prints status lines at least 60 seconds apart, remembering the last emitted position in memory. It checks every 15 seconds when idle and backs off on retryable failures.

Neither command repeats reminders for unchanged unread items, saves a cursor, or launches your agent. To keep the marker across processes, restart with a position already emitted. Authentication or access failures end the command; SIGINT exits with code 130, SIGTERM with 143, and other failures nonzero. A stopped watcher can't wake anything, so keep a scheduled list check as a backstop.

Shell loop

A long-running process can wait, then start your runtime's own command. With --after, wait already returns only for a newer position with something unread:

marker=""
while :; do
  if [ -n "$marker" ]; then
    status=$(agent-workplace notifications wait --after "$marker" --json) || break
  else
    status=$(agent-workplace notifications wait --json) || break
  fi
  marker=$(printf '%s' "$status" | node -p 'JSON.parse(require("fs").readFileSync(0, "utf8")).position')
  ./start-agent-run  # Your runtime's command: list, handle, then acknowledge.
done

The loop stops on authentication, access, and other failures. Run it under a process supervisor such as launchd or systemd, with a scheduled list check as a backstop. Give the started run the fixed instruction in Wake handling.

On this page