Capture sources

It reads the history your Mac already keeps.

behaviornudge doesn't record your screen itself. It reads what a screen-history app has already stored on your Mac, always read-only, and turns it into a timeline of activities. Two such apps are supported: Retrace.to, where this project started, and jhammant's open-source Retrace, which it uses now.

Where it started

Retrace.to

A Rewind-style screen recorder for the Mac (retrace.to, by haseab). It was the first source behaviornudge read. Its big advantage is exact durations: it stores every stretch of time spent in one app or window.

Reads
the segment table: app, exact start and end, window title, browser URL
Database
~/Library/Application Support/Retrace/retrace.db
Setting
sources.retrace_to_db

243,576 segments since April 11, 2026, in the history the backtest used

What it uses now

Retrace by jhammant

A private, on-device “rewind” for Mac and Windows (github.com/jhammant/retrace, Apache-2.0). It captures the screen live, pulls out the text, writes a one-line caption with Apple's on-device model, and deletes the raw screenshot. It also imports Screen Time, browser history and your calendar.

Reads
captures (time, app, window title, URL, caption), Screen Time durations, Chrome and Safari visits, and calendar events through its retrace-calendar helper
Database
~/.retrace/retrace.db
Settings
sources.retrace_jhammant_db, retrace_calendar_helper, retrace_repo, retrace_api

4,122 captures · 10,103 Screen Time records · 58,529 browser visits at the hackathon

Side by side

What each source gives behaviornudge. Both are optional, and when both are present they're combined.

Retrace.toRetrace by jhammant
What a record isA segment: one app or window, with a start and an endA capture: a moment on screen, every few seconds while you're active
DurationsExactFrom Screen Time; a capture alone stands in for at most 90 s
Window title and URLYesYes, plus Chrome and Safari history between captures
What's on screenNot read by behaviornudgeA one-line on-device caption; the full text stays in Retrace
CalendarNoApple Calendar through EventKit (a Google calendar can sync into it)
Away time—Paused while you're idle, locked or asleep, so it's never counted as activity
Live API—Local only, on 127.0.0.1:8765, plus a read-only MCP server
How it keeps runningThe Retrace.to appA launchd agent from behaviornudge: starts at login, restarts within seconds if it dies

How the sources are combined

When two sources describe the same moment, the most precise one wins: exact segments first, then Screen Time durations, then point captures. Browser visits fill in the URL where an app record doesn't have one. Every record then becomes a coarse activity key such as linkedin.com/feed or linkedin.com/messaging, and keys merge into sessions.

History and live are separate

History: the Retraces

The timeline built from these sources feeds:

  • the drift episodes and the weekly backtest
  • the baseline model built from your own history
  • the history BehaviorGPT sees when it scores a moment

Live nudges: watched directly

So nudges arrive within seconds, the live engine doesn't wait for Retrace. A small native helper watches:

  • which app is in front, and the current browser tab
  • whether a call app is using the microphone (never what's said)
  • idle and lock state, and herdr agent status

Private and read-only

Every database is opened with SQLite's read-only mode, so behaviornudge can never change Retrace's data. Screen text, URLs and screenshots stay on your Mac. Only activity keys and trimmed titles go out, through an allowlisted gate that logs every request.

Keeping Retrace running

Gaps in capture become gaps in your history. behaviornudge can put jhammant's Retrace under launchd so it starts at login, restarts if it crashes, and warns you in nudge status when capture stops.

uv run behaviornudge retrace agent install --replace   # --replace stops a Retrace you started by hand
uv run behaviornudge retrace agent status              # agent, capture health, interpreter, log

Processes started by launchd don't inherit your terminal's permissions, so grant Screen Recording and Accessibility once to the Python interpreter that install names.