# AGENTS.md: @noah/mega-radio - **Source is public (open source); audio is not.** Gating is enforced in the hosted app (`src/app.ts`). A copy of the source cannot serve the audio, because the MP3s live only in this package's storage. Never commit audio to git. - Standalone: no dependencies on other packages, no credential needs, no scheduled jobs, no email. - Track list: `src/tracks.ts` `radio` (titles, lengths, open dates; also the `npm run upload-radio` list). A track plays when its MP3 is fully stored and its New York open date has passed; otherwise it shows as `?????`. New tracks are added by hand: edit `src/tracks.ts`, publish, run `npm run upload-radio`. - `./audio-store` `{ action: 'forget-legacy' }` (owner only) deletes storage keys an older version used. - Do not import `kody:*` in `page.ts`, `player.ts`, `styles.ts`, `tracks.ts`, `discord.ts` or `audio-core.ts` (keeps them unit-testable). `node --experimental-strip-types --test test/*.test.ts` needs Node 22 or later. - Gate flow: `currentVisitor()` (`metaGetCurrentUser`, only `user_id`/`username` are trusted) → `getMembership(user_id)` → `isActive` (member and `checkedAt` < 30 days). Every `/files/radio/*` request runs this check. - Discord app: "Mega.dev", client ID `1565030809998458920` (`DISCORD_CLIENT_ID` in `src/config.ts`). - Discord check: `/discord/start` stores `pkce:` → `{verifier, userId}` and sets the `__Secure-dstate` cookie. It then redirects with `prompt=none` and retries with `prompt=consent` on `consent_required`. `/discord/callback` checks the state cookie, the stored userId and the `iss` value, exchanges the code (public client, no secret), calls `checkMembership`, and revokes the token. - No Kody credential needs on purpose: declaring an executor need (even `required: false`) made the platform redirect every route to a `need:discord` consent screen. Membership is proven only through the app's own Discord OAuth. - `checkMembership` uses `/users/@me/guilds/{GUILD_ID}/member` (`guilds.members.read`). If that returns 401/403, it falls back to paging `/users/@me/guilds` (`guilds`). - Smoke test after publish: `packageAppFetch` GET `/status` (signed out → `signedIn:false`) and `/files/radio/01.mp3` (signed out → 401). Run as Noah after a check → 200 / 206 with Range. - Upload: `npm run upload-radio` (Noah's machine). It calls `kody:@noah/mega-radio/audio-store`, which is owner-only via `OWNER_KODY_ID`. - Lock-screen artwork: `/art/NN.png?exp&sig` (src/art.ts) is the only cookie-free file route. The HMAC key is random and kept in package storage (`art:key`); links last 12 hours and are only minted on the member page. Playback uses one `