Find a file
Jason Monk 269e2a268c Fix usage tools returning duplicate entries per package
UsageStatsManager returns multiple UsageStats entries per package for
different internal time buckets. All usage tools (summary, per-app,
compare) now merge entries by package name, summing foreground time
before returning results. The daily breakdown in get_app_usage also
merges by date to avoid duplicate day entries.

Adds a test verifying deduplication produces one entry per package
with correctly summed time.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 13:14:55 -04:00
.claude Fix OAuth URL paths, e2e test improvements, debug logging 2026-04-09 15:54:31 -04:00
.github/workflows Exclude relay-dependent integration tests from CI with JUnit 5 @Tag 2026-04-09 21:27:51 -04:00
api Lower minSdk from 29 to 24 to support ~98% of active Android devices 2026-04-07 12:15:09 -04:00
app Fix "Finish later" on IntegrationEnabled to go to manage page 2026-04-10 10:06:28 -04:00
config/detekt Add Compose screens with mock data, Roborazzi screenshot tests, and HTML dashboard 2026-04-04 16:50:39 -04:00
core Fix test URL paths after routing moved from path-prefix to Host header 2026-04-10 11:15:55 -04:00
deploy Fix systemd unit: ReadWritePaths for device CA, positional config arg 2026-04-06 13:34:40 -04:00
device-tests Fix device integration tests: manifest, permissions, and plain-HTTP relay 2026-04-05 17:31:54 -04:00
docs Add comprehensive security overview document 2026-04-10 09:39:55 -04:00
e2e Fix ktlint: unused imports, line length in TestCommandProvider and e2e test 2026-04-09 17:08:03 -04:00
gradle Exclude relay-dependent integration tests from CI with JUnit 5 @Tag 2026-04-09 21:27:51 -04:00
health Lower minSdk from 29 to 24 to support ~98% of active Android devices 2026-04-07 12:15:09 -04:00
integration-tests Add tunnel mux protocol and integration tests against mock relay 2026-04-05 09:58:53 -04:00
notifications Show own notifications in listing, block actions on them 2026-04-10 10:15:11 -04:00
outreach Improve outreach MCP tools: broader app listing, notification priority 2026-04-09 21:24:50 -04:00
relay Fix OAuth URL paths, e2e test improvements, debug logging 2026-04-09 15:54:31 -04:00
tunnel/src/test/java/com/rousecontext/tunnel/mux Merge T-16: Tunnel + relay integration tests with mock relay server 2026-04-05 10:00:46 -04:00
usage Fix usage tools returning duplicate entries per package 2026-04-10 13:14:55 -04:00
work Fix FCM wake after idle timeout, ktlint fixes 2026-04-08 17:17:37 -04:00
.editorconfig Add Compose screens with mock data, Roborazzi screenshot tests, and HTML dashboard 2026-04-04 16:50:39 -04:00
.gitignore Remove .signing symlink, add to .gitignore 2026-04-07 21:12:08 -04:00
BLOCKERS.md Configure mTLS client cert for relay WebSocket connection 2026-04-05 19:58:55 -04:00
build.gradle.kts Add Firebase: google-services.json, Google Services plugin, debug applicationIdSuffix 2026-04-05 15:38:40 -04:00
gradle.properties Initial project scaffold: multi-module Android/Kotlin Gradle project 2026-04-03 19:38:30 -04:00
gradlew Initial project scaffold: multi-module Android/Kotlin Gradle project 2026-04-03 19:38:30 -04:00
gradlew.bat Initial project scaffold: multi-module Android/Kotlin Gradle project 2026-04-03 19:38:30 -04:00
last_session Merge T-1 interfaces: TunnelState, TunnelError, CertificateStore, TunnelClient (KMP) 2026-04-05 07:25:50 -04:00
LICENSE Initial commit 2026-04-03 19:35:18 -04:00
README.md Update README and add secret prefix bot rejection design doc 2026-04-08 10:59:23 -04:00
settings.gradle.kts Remove route("/$integration") wrapper, add e2e test framework 2026-04-09 15:26:10 -04:00

Rouse Context

Your phone has context that AI doesn't — your health data, your notifications, your app usage. Rouse Context makes that context available to AI assistants on demand, without ever syncing your data to the cloud.

It's an Android app that turns your phone into an MCP server. AI clients like Claude connect to a URL, your phone wakes up, and a direct encrypted session is established. The AI asks for what it needs, your phone responds, and then it goes back to sleep. Your data never leaves your device except through that live session.

Status: Active development. The core e2e flow works — Claude can connect, wake the phone, authorize via OAuth, and call MCP tools. Health Connect, Notifications, Outreach, and Usage Stats integrations are implemented. See docs/design/ for detailed design documents.

How It Works

AI Client ──TLS──> Relay (SNI passthrough) ──mux WebSocket (mTLS)──> Your Phone
  1. You enable an integration (e.g. Health Connect) and get a URL like https://brave-falcon.abc123.rousecontext.com/health/mcp
  2. Add that URL to Claude, Cursor, or any MCP client
  3. When the client connects, the relay wakes your phone via FCM push
  4. Your phone connects back through a mTLS WebSocket, and the relay splices the two TLS streams together
  5. The AI client talks directly to your phone over end-to-end encrypted TLS — the relay never sees the plaintext

Sessions are ephemeral. The phone goes back to sleep when the client disconnects.

Integrations

Integration What it exposes
Health Connect Step count, heart rate, sleep, HRV, workout history
Notifications Active and historical device notifications
Outreach Send messages, make calls, toggle DND
Usage Stats App usage patterns and screen time

Each integration is independently enabled and gets its own MCP endpoint with OAuth authorization (PKCE).

Architecture

Android App

Module Purpose
:app Compose UI, Koin DI, navigation, theming
:core:tunnel Mux protocol, WebSocket client, TLS accept, CertificateStore
:core:mcp MCP session routing, HTTP server, OAuth (device code + auth code + PKCE), token management
:core:bridge Bridges tunnel mux streams to MCP sessions via TLS
:api McpIntegration interface, IntegrationStateStore
:health Health Connect MCP server
:notifications Notification listener, audit persistence (Room)
:outreach Device actions — calls, SMS, DND
:usage App usage stats via UsageStatsManager
:work Foreground service, FCM receiver, WorkManager

Relay Server (relay/)

Rust binary on a small VPS. Handles:

  • TLS passthrough — routes AI client connections to devices via SNI, never terminates inner TLS
  • Mux WebSocket — multiplexes multiple client sessions over one device connection
  • FCM wakeup — sends push notifications to wake sleeping devices
  • ACME certs — issues wildcard TLS certs per device via Let's Encrypt DNS-01 (Cloudflare API)
  • Bot protection — secret URL prefix validated before waking device, plus FCM throttle and IP rate limiting

Security

  • End-to-end encrypted — TLS terminates on your phone. The relay does SNI passthrough only.
  • No cloud sync — data is read from on-device sources and served live. Nothing stored remotely.
  • Per-device ACME certs — wildcard certs via Let's Encrypt, private key in Android Keystore (hardware-backed).
  • mTLS device auth — relay authenticates the device by client certificate before allowing connections.
  • Secret URL prefix — each device URL includes a rotatable secret (brave-falcon.abc123.rousecontext.com). Bots that discover the device subdomain can't wake it without the secret.
  • OAuth per-client — each AI client must be authorized via on-device approval before accessing tools.
  • Audit trail — every tool invocation is logged locally with arguments, response, and duration.

Building

Android

./gradlew assembleDebug

Requires Android SDK (API 35) and JDK 17+.

Relay

cd relay
cargo build --release

Status

Active development. The core flow works end-to-end: Claude can connect, wake the phone, authorize via OAuth, and call MCP tools. See docs/design/ for detailed design documents.

License

Licensed under the Apache License, Version 2.0. See LICENSE for details.