Files
ai-agent/backend/notif_read.py
Gabriel Vidal a82091f4fd feat(ai-agent): read-only API key + unread-notifications endpoint
Adds a read-ONLY credential and a server-side unread feed so the desk phone can
read out the latest notifications without any write access.

* READONLY_API_KEY (comma-separated): a caller presenting a matching X-API-Key
  may hit safe methods (GET/HEAD/OPTIONS) only — every mutating method is 403,
  even from an otherwise-trusted source IP. Checked before the trusted-IP path,
  so the phone (which reaches us over the trusted host loopback) is downgraded
  to read-only and can never spawn a session or PUT into .claude/.

* GET /api/notifications/unread — the last unread notifications, newest first,
  flattened server-side exactly like the frontend's buildFeed+mergeLog (same
  stable ids). Pure read: it NEVER marks anything read (listening on the phone
  isn't opening a notification).

* Server-side read ledger (notif_read.py / /data/notif-read.json): the "new"
  state used to live only in the browser. POST /api/notifications/seen|seed mark
  ids read; the PWA now mirrors its dismiss/seed into it so the phone's unread
  view agrees with what's been opened in the app.

Regenerated openapi.json + frontend types; mock handlers + tsc updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-17 02:32:01 +02:00

3.9 KiB