# BYO-agent authoring (D43)

Build or edit decks on **your** machine with **your** agent and **your** tokens. cue
only runs the deterministic parts server-side (validation gate, preview build,
publish) — no platform model spend on submissions.

## Two lanes: remote connector vs local shim

Same account, same decks, same tools, same gate — two ways to reach it.

**Remote (the hosted connector)** — most agents speak OAuth 2.1 straight to
`https://cue.humanmeetsai.com/mcp`: nothing to install, no token to mint or paste, and
auto-discovery walks you through consent in the browser. Per-client shape:

- **Claude Code**: `claude mcp add --transport http cue https://cue.humanmeetsai.com/mcp`
- **Cursor**: one-click install link on `/connect`, or add manually to
  `~/.cursor/mcp.json`:
  `{ "mcpServers": { "cue": { "type": "http", "url": "https://cue.humanmeetsai.com/mcp" } } }`
- **VS Code**: `code --add-mcp '{"name":"cue","type":"http","url":"https://cue.humanmeetsai.com/mcp"}'`
  (or the one-click install link on `/connect`)
- **Codex CLI**: `codex mcp add cue --url https://cue.humanmeetsai.com/mcp` — the command
  registers the client and opens the browser for consent by itself (codex-cli 0.160.0,
  2026-10-08); approve there, then `codex mcp list` to confirm. If no browser opened,
  `codex mcp login cue` starts the sign-in again. That writes the `[mcp_servers.cue]` entry in
  `~/.codex/config.toml`, which is also where you edit it by hand:
  ```toml
  [mcp_servers.cue]
  url = "https://cue.humanmeetsai.com/mcp"
  ```
- **Codex app** (the Codex surface of the ChatGPT desktop app — the standalone app was
  folded in, 2026-07): Settings → MCP servers → Add server → name `cue`, transport
  Streamable HTTP, paste the URL → Save → Restart → Authenticate next to `cue`. It reads
  the SAME `~/.codex/config.toml` as Codex CLI and the IDE extension, so a server added in
  any one of them is available in all — with Codex CLI installed, the one `codex mcp add`
  command above adds the server and signs you in; restart the app, and if `cue` still shows
  Authenticate, click it once.
- **Gemini CLI**: `gemini mcp add cue https://cue.humanmeetsai.com/mcp --transport http`,
  then `/mcp auth cue` inside the CLI
- **claude.ai / ChatGPT / Claude Desktop** — no CLI: paste
  `https://cue.humanmeetsai.com/mcp` into Settings → Connectors (claude.ai: "Add custom
  connector"; ChatGPT: Advanced → Developer mode → "Add connector"; Claude Desktop:
  Connectors → Add custom connector), sign in, approve. OAuth 2.1 mints and refreshes the
  credential in the browser — there is no token to copy. (Watch the setup — claude.ai:
  https://cue.humanmeetsai.com/connect?agent=claude-ai&play=1, 1:10, silent; ChatGPT:
  https://cue.humanmeetsai.com/connect?agent=chatgpt&play=1, 1:56, silent.)
- **WorkBuddy** (Tencent's desktop agent) — has no OAuth lane, but its `mcp.json` takes a
  URL entry with a bearer header: `/connect?agent=workbuddy` generates the `mcpServers` JSON
  (`"type": "http"`, the hosted URL, and `Authorization: Bearer cue_…` carrying a personal
  token minted on that page); paste it via sidebar Plugins → MCP Server → Configure MCP
  (`~/.workbuddy/mcp.json`). No Node.js, nothing to install. Verified 2026-09-02 on
  WorkBuddy 5.5.1. (Watch the setup:
  https://cue.humanmeetsai.com/connect?agent=workbuddy&play=1 — 0:47, silent.)

- **QwenWork** — `/connect?agent=qwenwork`: Extensions → Connectors → + Add →
  Fill in Config Manually. Choose **Streamable HTTP**, name it `cue`, and enter
  `https://cue.humanmeetsai.com/mcp` as Server URL. Leave Headers and Timeout empty,
  click Add, and complete cue sign-in/approval if prompted. Check that `cue` is enabled
  under Installed. Then download [cue-decks.zip](https://cue.humanmeetsai.com/cue-skill.zip)
  and open Extensions → Skills → + Add → Upload skill to install it locally. The ZIP
  contains the remote-lane `cue-decks/SKILL.md`; no local MCP shim is needed. Setup based
  on the operator's working QwenWork connection and screenshots, 2026-09-20.
  Marketplace and kit distribution findings: [QwenWork distribution](docs/runbooks/QWENWORK-DISTRIBUTION.md).

See "Remote MCP" (§3c) below for the full auth/scope model.

**Local (the shim)** — for agents on your machine that read/write files in a directory,
or any client without OAuth support. One file, no dependencies, installed to a stable
path:

```sh
mkdir -p ~/.cue && curl -fsSL https://cue.humanmeetsai.com/cue-mcp.mjs -o ~/.cue/cue-mcp.mjs
claude mcp add cue --env CUE_TOKEN=cue_... -- node ~/.cue/cue-mcp.mjs
```

or drive it as a CLI (`node ~/.cue/cue-mcp.mjs decks | pull <deckId> | submit <dir> | ...`)
— §2 below has the full API and §3 the tool/verb list.

Both lanes reach the SAME decks through the SAME validation gate; only the tool surface
for EDITING diverges (pull-to-disk vs a server-held draft workspace), because that's the
one place the filesystem itself diverges. Use both lanes on one deck without re-pulling
or re-seeding between them and the second write reports `stale: true` — see §3c.

## 1. Mint a token

Sign in → **Connect** (top bar, or `/connect` — `/tokens` now redirects there) →
*Create token*. Copy it immediately; it is shown once and stored hashed. Revoke from
the same page — for a hand-minted token this deletes just that row; for an OAuth
connection (the remote lane, §3c) it kills the WHOLE connection: the refresh token and
every access token it ever minted, not just the row on screen. A token acts as you
(same decks, same quota) — treat it like a password.

**Minting is free** (D216, "author free, deliver paid"): every account that can author on cue
can mint a token, including a brand-new one with no plan — writing decks with your own agent
costs cue nothing, so it is not behind the paywall. The caps are on DELIVERY, and the free lane
hits them as 403s whose body is `{ error, code: "needs_pro", capability }` — the sentence names
the number, `code` lets a client branch without matching prose, and `capability` says which
door (`published_decks_max`, `share_links_max`, `invitees_max`, `receipts`, `documents`,
`translate` — the last also covers live captions, `screens_claim` — registering a screen of
your own; CASTING to one is `screens_cast` and free): **five published decks live at once**
(unpublish or delete one to free a slot — drafts are unlimited), **one share link per deck**
(the deck's original `?k=` link; a named additional link is Pro), **ten named invitees per
gated deck**, no per-recipient tracked `?r=` links, print-grade documents are Pro (refused at
publish, submit, restore and fork/duplicate alike), and `GET /api/decks/:id/readers` returns
aggregate totals (opens, unique viewers, by language) marked `aggregateOnly: true` rather than
who read what — the empty `identities`/`byRecipient`/`recent` arrays under that flag mean "not
shown", never "nobody opened it". **Hosted generation is OFF on cue.humanmeetsai.com** (D251): `POST /api/author` answers
**403 `hosted_generation_off`** for prompt-driven and edit requests alike — cue no longer
writes decks, your agent does. Nothing on this page changes: the BYO lane
(`/api/decks/submit`, the MCP write tools, the skill), token minting and the no-model
`backend: "template"` door are all unaffected, and whole-deck AI translation keeps running on
its own switch. Submits from your own agent never spent generations anyway: they
draw on a separate compile budget (60/day per account, plus per-IP and deployment-wide
ceilings). On Pro — and on the other author plans — submits get a far larger budget of their
own: 60 an hour and 300 a day per account, so an agent that iterates a deck all afternoon
never runs into a delivery cap. An account whose plan has LAPSED or is on hold cannot mint at
all — that 403 is the author-plan gate, not a delivery cap. Minting is also bounded for
everyone by an abuse cap of 20 ACTIVE tokens per account (409, not a plan gate): revoke one on
/connect to free a slot.

## 2. The machine API

All endpoints accept `Authorization: Bearer cue_...`. Base: `https://cue.humanmeetsai.com`.

| Verb | Path | Purpose |
|---|---|---|
| GET | `/api/decks` | list your decks (id, slug, title, status) |
| GET | `/api/shelf` | decks shared WITH you (∪ saved), as shelf cards → `{ cards: [...] }` (recipient side; each card carries `canEdit` — you hold an active edit grant, so you may pull/submit, provided your own account has authoring access; a revoked share you had opened returns a withheld stub — `authorized: false`, `canEdit: false`, no sender/thumb/link) |
| GET | `/api/decks/:id/source` | pull a deck's source as `{ files: { "name.tsx": "..." } }` + `rev: { ref, kind, digest }`. `?rev=<ref>` (owner-only; `draft` \| `live` \| a versionId \| a 64-hex digest) pulls that point on the timeline instead of the draft — unknown or aged-out ref → `404`. A co-editor grantee always gets the version their grant is served, and passing `?rev` → `403`. The owner's draft pull adds `studioOverrides: { fields, title?, rule }` when the owner has studio edits (D256) |
| POST | `/api/decks/:id/submit` | replace that deck's source (body `{ files, message? }`) → `202 { jobId, ignored, studioOverrides? }` — `overrides.json` is never accepted (it lands in `ignored`); the deck's studio overrides are re-applied field by field, most recent edit wins (D256) |
| POST | `/api/decks/submit` | create a NEW deck from source (body `{ title?, files, message? }`) → `202 { deckId, jobId }` |
| GET | `/api/jobs/:id` | job status; `result.previewUrl` on success, gate report in `result.error` on failure |
| GET | `/api/jobs/:id/events` | live job stream (SSE, resumable via `Last-Event-ID`) |
| GET | `/api/decks/:id/preview` | see the CURRENT draft: builds (or reuses) a preview of the deck's working source and returns `{ previewUrl }` — a short-lived (~15 min) signed URL; treat it as a credential (never log or embed it durably). Unchanged source answers in ~100 ms; a changed draft may take one build (~10-30 s). Owner bearer with `read` scope suffices, and it keeps working through an author-plan lapse or moderation hold — you always keep *seeing* your own draft |
| POST | `/api/decks/:id/publish` | publish the current gated source (optional `{ access, invitees }`) → `access` + `viewUrl` (self-paced share) + `liveUrl` (live session) |
| POST | `/api/decks/:id/fork` | fork a deck SHARED TO YOU with fork permission into a new deck you own → `202 { deckId, jobId, slug }` (copies the version you're served; you must be able to author on cue — any plan with authoring, including a brand-new account's free lane, which since D216 CAN mint a bearer token: `POST /api/tokens` is free for every account that can author) |
| POST | `/api/decks/:id/propose` | (id = YOUR fork) propose the fork's changes back to the deck you forked from → `{ proposalId, status, staleBase }` |
| GET | `/api/decks/:id/proposals` | (owner-only) list proposals made to your deck (`?all` includes resolved) → `{ proposals: [...] }` |
| POST | `/api/decks/:id/proposals/:pid/accept` | (owner-only) accept — body `{ fromVersionId }` (the reviewed version); the proposed source becomes your deck's next draft (credited to the proposer) → `202 { jobId, staleBase }` |
| POST | `/api/decks/:id/proposals/:pid/decline` | (owner-only) decline (optional body `{ reason }`) → `{ status: "declined" }` |
| POST | `/api/decks/:id/proposals/:pid/withdraw` | (proposer-only) withdraw your own open proposal → `{ status: "withdrawn" }` |
| GET | `/api/decks/:id/history` | (owner-only; version entries carry `ordinal` / `sameAs`, D361) the deck's timeline: publishes + accepted revisions, newest first → `{ deckId, current, live, draftAhead, entries: [...] }`; `?limit=1..500`, `?text=1` adds a one-line-per-entry rendering |
| GET | `/api/decks/:id/diff` | (owner-only) `?from=<ref>&to=<ref>` (default `live`→`draft`) or `?proposal=<pid>` → `{ from, to, summary, files, overrides }`; `?text=1` adds the agent-readable rendering. Unknown ref → `404`; a real ref whose bytes aged out → `404` + `missing: "from" \| "to"` |
| POST | `/api/decks/:id/restore` | (owner-only) move the DRAFT: body `{ digest }`, `{ versionId }` or `{ discard: true }`, optionally `+ { files: ["slides.tsx"] }` to move only those files (with `+ { restoreDeletedContentKeys: true }` the copy keys that point's `content.ts` has and the draft lost are spliced back too → `contentKeysRestored`) → `202 { jobId, digest }` (poll it), or `200 { alreadyClean: true }` when the draft already matches |
| POST | `/api/decks/:id/rollback` | (owner-only) SET LIVE: body `{ versionId, syncDraft? }` re-points the published artifact and (with `syncDraft`) stages a restore of the draft → the deck record + `restoreJobId` / `restoreError` |
| GET | `/api/decks/:id/revisions` | (owner-only) the raw revision index → `{ revisions: [...] }` |
| GET | `/api/templates` | the template library (public — curated showcase styles) |
| GET | `/api/templates/:slug/source` | a template's source files (public) |
| GET | `/api/library` | the pattern library index (public): `contract`, `patterns`, `identities`, `diagrams` — each identity carries `slug, title, tagline, voice, scheme, swatch` |
| GET | `/api/library/:identity/source` | one identity's vendoring set → `{ identity, files }` (public; 404 on unknown identity) |

**Before that: one round of intake.** If the request is thin (no audience, no length, no
language, no visual direction given), ask audience & occasion, language(s), length and
visual identity in a SINGLE batch — one call to the host's structured question tool if it
has one, each option carrying a default — never a second round. Otherwise print a
one-line defaults summary ("Defaults I'm using: …") before building. When the occasion is
a workshop, a lecture or class, a quiz or a live poll, that same round asks one more
thing: should the room ANSWER, and how many times (see *asks*, below). Full rule in the
skill's "Before building a NEW deck" section.

**Starting a new deck? Outline first, then compose from the library.** `GET /api/library`
lists PATTERNS (structure only — each with `bestFor`/`density` to map an outline beat to,
`slots`/`arity` to generate content from, and `steps` for `SlideSpec.steps`), IDENTITIES
(the whole visual + kinetic voice, one choice per deck) and a DIAGRAM kit. Then
`GET /api/library/:identity/source` returns the five files a deck vendors —
`contract.ts`, `patterns.tsx`, `diagrams.tsx`, `id-<identity>.tsx` and a generated
`identity.tsx` one-line re-export. Copy them into your source unchanged (patterns are
byte-identical across decks; all voice comes from the identity), write `index.ts`
(`theme: identity.theme`, `transition: identity.motion.transition`), `slides.tsx`
(patterns wired to content keys, `steps: PATTERN_STEPS.X`) and `content.ts` beside them,
and `submit` without `--deck`. **Your deck has as many slides as the outline has beats.**

**Active content language (D283, requires the worker SDK update).** `useContent()` from the allowed
`@/lib/content` module exposes readonly `lang` alongside `c(key)`, `entry(key)` and `keys`. Use `lang` for
language-specific rendering policies; equal translated strings do not identify a language. `c()` keeps its
nullish fallback and preserves empty values. Do not import `@/lib/lang` into authored deck code. Existing
artifacts retain their baked SDK; use this property only after the worker release and artifact rebuild.

**Templates are worked examples.** `templates` → pick the closest style →
`pull-template <slug>` → adapt `content.ts` (and theme tokens if needed) → `submit`
without `--deck`. Complete, gate-clean showcase decks — adapt one whole when the user
asks for exactly that look; its slide count is scaffolding, not a target. `workshop` is
the one built on **asks** (D248): a deck that puts questions to the room it is presented
to. Declare them on the manifest as `asks: Record<id, AskSpec>` (kinds `choice`, `multi`,
`scale`, `number`, `rank`, each localized in every declared language), name the ids on the
`SlideSpec` that asks (`asks: [...]`) and the one that reveals (`reveals: [...]`), and read
them with `useRoom()` from `@/lib/room`. Every asking and revealing slide needs a designed
EMPTY state: a reader of the published deck, a PDF and a PPTX export never see a room. The
schema, the bounds and the craft rules are in the skill's *Asking the room*; the room-token
routes behind it are below, and they are not yours to call.

Submission rules (enforced server-side with named errors):
- The submission is the **complete source** — submit replaces, it does not merge. Pull first.
- Flat file names only; allowed extensions `.ts .tsx .json .css .md`; `index.ts` required.
- ≤ 80 files, ≤ 512 KB each, ≤ 8 MB total. `tsconfig.json` is ignored (platform-managed).
  Names starting with `__` are reserved for the platform.
- Everything faces the same gate authoring does (typecheck, forbidden-API lint, esbuild
  dry-build). Gate failure leaves the deck unchanged and reports honestly.

curl sketch:

```sh
TOKEN=cue_...
curl -s -H "authorization: Bearer $TOKEN" https://cue.humanmeetsai.com/api/decks
curl -s -H "authorization: Bearer $TOKEN" \
  https://cue.humanmeetsai.com/api/decks/<id>/source > deck.json
# ...edit... then submit files back:
curl -s -X POST -H "authorization: Bearer $TOKEN" -H "content-type: application/json" \
  -d '{"files": {...}, "message": "reworked slide 2"}' \
  https://cue.humanmeetsai.com/api/decks/<id>/submit
```

### Language: what you read in (D243)

Two nullable fields on the account decide which language cue resolves things in FOR YOU:

| Verb | Path | Purpose |
|---|---|---|
| GET | `/api/me/prefs` | `{ readingLang, spokenLang }` — both `null` when you have stated nothing |
| PATCH | `/api/me/prefs` | body `Partial<{readingLang, spokenLang}>` → the row after the write |

- `readingLang` — any BCP-47 tag a deck manifest may declare (`en`, `de-AT`, `zh-Hant`);
  `null` = automatic.
- `spokenLang` — a caption language that can be spoken: any code from `GET /api/caption-languages`
  with `canSpeak: true` (the catalogue, D308 — `en de es fr ja zh ko` and many more); `null` = "same as
  reading" (folded to the reading language's base tag when that is one of the seven built-in caption
  languages).
- PATCH semantics: a field ABSENT from the body is untouched, a field present and `null` is
  CLEARED. Invalid values are `400` and name the field.
- **SESSION ONLY, not bearer.** Unlike every other endpoint here, `/api/me/prefs` does not
  accept `Authorization: Bearer cue_...`: a token is a delegation minted for authoring, and
  "which language this person reads in" is a statement about the PERSON. Set it in the browser
  at `/account` (or in the iOS/Android Settings screens); an agent READS its effect.

What it changes for a bearer caller: **deck-list titles resolve in your reading language.**
`GET /api/decks` and `GET /api/shelf` pick each title from the deck's own `title` map by your
reading language (matched exact → case-insensitively → by base tag, so `zh` finds `zh-Hant`),
then the deck's `defaultLang`, then `en`, then the slug — and each row reports the
`titleLang` it actually landed on, so you can say "shown in English" when it differs. With no
preference set, both endpoints also honour the request's `Accept-Language`; with neither, the
resolution is exactly what it always was. Nothing about a deck's CONTENT changes: the
artifact carries every declared language and viewers switch live.

**Caption languages (D308).** Live captions translate into languages from a catalogue the operator
switches on and off, not a fixed list. `GET /api/caption-languages` (public, no auth) lists the ones
in use: `{ languages: [{ code, endonym, englishName, beta, dir, script, canSpeak, lane, speechLocale,
streamingCode }] }` — `canSpeak` means it can be a presenter's spoken language, `lane` is `streaming`
(translated word by word) or `sentence` (per finished sentence) or `null` (cannot be translated into). The
same list (without `englishName` and `beta`) is `captionLanguages` in `GET /api/app-config`. A talk's
languages are chosen by its presenter in the console (`PUT /api/presentations/:id/caption-languages
{spoken, langs[]}`, session only, up to the plan's languages-per-talk number) or ahead of time for the deck
(`GET`/`PUT /api/decks/:id/caption-languages {spoken, langs[]}`, owner, same validation; the owner's talk
saves are remembered there too). A talk uses its own set, else the deck's (narrowed to what can still be
offered and to the cap), else NOTHING: with no set chosen a talk offers no translations and captions only in
the spoken language (D351; `source: "legacy"` on the GET now means "nothing chosen", `offered` is `[]`). A set
is the audience's languages and may include the spoken language; the talk translates into the set minus
whatever is spoken now, and the cap counts the set minus the spoken language (a save that only changes
`spoken` is never refused for the cap). Captions start off; the presenter turns them on.

### Assets: image uploads for deck source

Deck graphics are inline SVG/CSS by default — the artifact CSP blocks every external
host, so `<img src="https://…">` never renders. For a PHOTO or SCREENSHOT that isn't
practical to draw, upload it once and reference it relatively in source.

| Verb | Path | Purpose |
|---|---|---|
| POST | `/api/decks/:id/assets/grants` | mint a single-use upload URL (body `{ filename, contentType, maxBytes? }`) → `{ uploadUrl, method: "PUT", expiresAt, maxBytes, curl }` |
| GET | `/api/decks/:id/assets` | list this deck's assets → `{ assets: [{ assetId, ref, bytes, width?, height?, kind, embedded, ladder, duration?, variants? }] }` |
| DELETE | `/api/decks/:id/assets/:assetId` | remove one asset from the draft store |

The grant's `uploadUrl` IS the credential — no auth header, no cookie, single use,
expires in 10 minutes. PUT the raw bytes with the declared `content-type`; the response
is `{ assetId, ref, kind, ladder, width, height, bytes }` (plus `duration` for a video and
`jobId` when the ladder is built in the background). Put `ref` in deck source as a RELATIVE
path exactly as returned, never absolute or external:

```sh
# 1. request a grant
curl -s -X POST -H "authorization: Bearer $TOKEN" -H "content-type: application/json" \
  -d '{"filename": "hero.jpg", "contentType": "image/jpeg"}' \
  https://cue.humanmeetsai.com/api/decks/<id>/assets/grants
# → {"uploadUrl": "https://cue.humanmeetsai.com/u/<token>", "method": "PUT",
#    "expiresAt": "2026-08-01T12:10:00.000Z", "maxBytes": 8388608,
#    "curl": "curl -sS -T hero.jpg -H 'content-type: image/jpeg' https://cue.humanmeetsai.com/u/<token>"}

# 2. run the curl line the grant gave you (any shell — no auth header needed)
curl -sS -T hero.jpg -H 'content-type: image/jpeg' https://cue.humanmeetsai.com/u/<token>
# → {"assetId": "ab12cd34ef56ab78.jpg", "ref": "assets/ab12cd34ef56ab78.jpg",
#    "width": 1600, "height": 900, "bytes": 214031}

# 3. reference it in deck source, THEN submit:
#    <Image asset="assets/ab12cd34ef56ab78.jpg" fit="cover" alt="..."
#           style={{ position: "absolute", inset: 0 }} />   (from @/lib/primitives;
#    a plain <img> skips the viewer's tier and Studio's crop — keep it for a QR or an icon)
```

UPLOAD BEFORE SUBMIT — the gate rejects source that references an asset the deck's
store doesn't hold yet; upload, note the `ref`, then submit. Accepted types: PNG, JPEG,
WEBP, GIF, and video: `video/mp4` (H.264 video, AAC audio or none, `moov` before `mdat` —
`ffmpeg … -c:v libx264 -c:a aac -movflags +faststart out.mp4`) or `video/quicktime`
(transcoded to MP4 on upload). A video's ref is always `assets/<id>.mp4`. **No SVG** —
vector art belongs inline in deck source (animatable, themeable there; an uploaded SVG
could also carry script). Every upload is decoded and re-encoded server-side — EXIF/GPS
stripped, your original image bytes are never stored or served verbatim — and
content-addressed, so uploading identical bytes twice returns the same `assetId`/`ref`
without spending budget twice.

**The media ladder (D260).** Every upload is also turned into a set of sized variants on
the media host (`MEDIA_ORIGIN`, never the artifacts origin): images → `stage` (lossless
WebP at native size, long edge ≤ 4320), `desktop` (≤ 1920), `phone` (≤ 1080), `lite`
(≤ 640) and a 32 px `placeholder`; videos → `stage` (the upload itself when it is already
≤ 1080p H.264/AAC — remuxed with all metadata such as GPS stripped — else a 1080p transcode),
`desktop` (720p) and `phone` (480p), each capped at its bitrate, and `poster-*` stills at every
image tier. Images up to 8 MB get the ladder inside the upload request (`ladder: "ready"`);
every video and every larger image answers at once with `ladder: "pending"` and a `jobId`, and
`GET .../assets` shows `ready` (or `failed` + `error`) when the background job finishes. Videos
are limited to 5/15/60 minutes total per deck on Free/Pro/Event; a finished ladder's total bytes count against the deck budget. Large media never enters the artifact or the compile request; small images are
still also embedded in the artifact exactly as before.

**The media manifest (D260 WP2).** Keep referencing assets as `assets/<id>.<ext>`. At build
time the platform maps every referenced asset to its ladder and ships `media.json` in the
artifact (and inlines the same JSON in `index.html` as
`<script type="application/json" id="cue-media">`): `{ v: 1, origin, access, tiers,
slides?, assets: { <16-hex id>: { kind, w, h, duration?, placeholder?, embedded?,
variants: { <name>: { key, url?, bytes, w, h, sha256, contentType, duration? } },
acrossSlides? } } }`. Public and link decks carry plain variant `url`s; gated decks carry
none — the viewer shell fetches `GET /api/decks/:id/media-urls?tier=stage|desktop|phone|lite`
(viewer admission, `no-store`) → `{ deckId, versionId, tier, expiresAt, urls: { <key>: <signed
24 h URL> } }` and posts it into the artifact as `deck:media-urls`. An asset uploaded before the
ladder existed is a single `embedded` variant. The gate adds a **media** step: a submit whose
source names a media-only asset whose ladder is still `pending` fails with "ladder still
running, retry"; a `failed` ladder fails with its error. Optional source file
`media-slides.json` — `{ "<slideIndex>": ["<assetId>", …] }` with 16-hex ids your source
references and slide indices that exist — becomes `media.json`'s `slides` (the player
prefetches ahead of the presenter; an id on two consecutive slides is `acrossSlides`).
`GET /api/decks/:id/offline-manifest?tier=<tier>` adds that tier's `media` list
`[{ assetId, variant, key, url, bytes, sha256 }]` beside the unchanged `files`.

**Rendering media, and the event-deck engine (D260 WP3).** The engine's media primitives read
that manifest: `<Image asset="assets/<id>.<ext>" fit position alt />` (inline placeholder, then
the viewer's tier) and `<Video asset="assets/<id>.mp4" playOnStep loop muted playsAcrossSlides
controls poster start end volume />` (`controls`: native controls; a presenter's play/pause/seek with them is
mirrored on every follower in a live room; `poster` — an image asset — wins over the ladder's poster;
`start`/`end` trim playback, seconds; `volume` 0..1) from `@/lib/primitives` — a plain `<img>`/`<video>` pointing at a media-only asset
renders nothing (only small embedded images are in the artifact). Neither primitive has an intrinsic
height (the picture inside is absolutely positioned): give it a size (`style` width/height) or
`style={{ position: "absolute", inset: 0 }}` inside a sized, positioned parent, or it draws nothing.
An unmuted `<Video muted={false}>` whose play the browser's autoplay policy refuses (the step reached
the frame by postMessage, with no click in it) is retried muted (D272): the element is marked
`data-muted-by-policy`, an icon-only sound control unmutes it with a click (or Enter / Space) inside the frame,
and the surface's own `deck:media-state` play carries `mutedByPolicy: true`. Only the self-paced viewer and a room
screen's deck frame delegate `allow="autoplay"`. `<MotionBackground stops angle scale speed period phase offset
clockMode reverse still grain />` (D272) fills its parent with a gradient repeating first → last → first stop,
scrolling toward the first stop's edge: `angle` on the slide stretched to a square, a cycle of 5 / `scale` slide
extents lasting 800000 / `speed` ms; `stops` take CSS colours or the import IR's stops as they are (a null colour is
skipped; an unreadable one is reported as `motionBackground:stop` in `buildFallbacks` and the `still` — else a solid
fill of the first usable stop — is drawn; `scale` is clamped to 0.5..50, `period` to 10 minutes, 32 stops at most);
`params` carry the importer's "86" angle / "64" scale / "70" speed. One compositor animation; the clock runs on
across slides (`clockMode="slide"`: from `offset` at each entry); still (`still` image, or clock 0) under reduced
motion and for render contexts (`?render=1`, or `?nav=0` without `chrome=shell`); a `deck:seek` sample draws the
frame at `offset` + its `clock` — in a render context only when the seek carries an explicit `clock` (without one
the still stays; a bare `nav=0` artifact is still by design, the background moves under `chrome=shell` or in the viewer). The engine picks the tier
(`deck:tier` from a shell wins; otherwise device + connection, never `stage` by itself), loads in
slide priority inside a ±8-slide window, and hidden slides only on demand. Manifest additions the
same engine understands: `stage: { w, h }` (the layout canvas, default 1280×720),
`SlideSpec.hidden` (skipped by navigation, the presenter's reserve; projected as
`hidden: boolean[]`), `SlideSpec.id`, `transition: "none"` (hard cut), `<Build>` (a timed build
timeline in milliseconds — `onClick` / `afterPrevious` / `withPrevious`; set
`steps: buildSteps(builds)`; `delivery` `byWord` / `byParagraph` staggers text, and `options` carry
wipe `feather`, blur `blur`, scale `origin`, `stagger`, blink `count` / `period` (default 361 ms) /
`minOpacity` — a smooth raised cosine since D272; default count 3; keyboard `perChar` / `cursor` / `caret: { keys }` —
D277: one time per keystroke incl. spaces and line breaks (`null` = not typed), positions from the outline's `data-caret-*` attributes,
Keynote's measured cursor; fallbacks reported as `keyboardCaret:keys` / `keyboardCaret:outline` in
`buildFallbacks`; `caps` names `keyboard-cursor`; D280: on live text — other languages, `mode="live"`, a patched layer —
a keyboard types grapheme by grapheme (word by word for Indic, Thai and similar scripts), measured times kept by
position, with a cursor measured from the laid-out text, and byWord uses `Intl.Segmenter` words; right-to-left text and
layers over 20 000 units keep the stepped clip, reported as `textBuild:script` / `textBuild:units`; keyboard `count`
is ignored there; `caps` names `live-text-builds`) and `<Text obj k mode box />` (generated exact-text outlines over live
text). Shell seam additions (all additive; `caps` names them): inbound `deck:seek {slideIndex,
step, t, clock?}` (`clock`: the motion background's drift clock in ms, a finite number ≥ 0, else `t` — except in a render context, where a seek without `clock` keeps the still), `deck:tier`, `deck:next {slideIndex}`, `deck:preload {tier}`, `deck:verify`,
`deck:media {assetId, action, t}`, `deck:media-urls`; `deck:report` gains, only when they say
something, `hidden`, `visibleCount`, `tier`, `cachedThrough`, `cachedCount`, `bytes`, `preload`,
`verify`, `fonts`, `stale`, `buildFallbacks` and `needsMediaUrls`. `caps` also names `seek-clock`,
`muted-by-policy` and `motion-background` on an engine that has them (D272), and `shell-nav` on one
that honours `?nav=shell` (D297): that value hides the deck's own navigation rail for a host that
draws its own and changes nothing else. Do not use `?nav=0` for that: it is the renderers' flag and
also turns off the media loader's background work, the warm-up and the sprite prefetch. The rail a
raw artifact draws is a position bar and a counter button (`g` or a digit opens its jump field).
`?tap=zones` (capability `tap-zones`) makes the deck step on a tap at its edges on a touch device
(portrait 35 / 65, landscape 30 / 40 / 30) while leaving interactive elements alone; mark an element
that handles its own taps `data-cue-interactive`.
`caps` names `video-gesture-unlock` (D300) on an engine that, on the viewer's first tap, key or click INSIDE the frame,
grants a few long-lived video elements that every later slide's videos mount on, so they play however the slide is
then reached (a swipe, a shell's `deck:goto` / `deck:nav`); and draws a tap-to-play control on a video that does not
start (refused even muted, or stalled 2.5 s). A parent page's gesture grants no activation inside the frame, so
until the viewer has touched the frame itself in-app browsers show that control; a shell that wants to avoid it should
let the engine take the taps (`?tap=zones`).
`caps` names `image-crop` (D317) on an engine that, when a shell arms edit mode with `deck:edit {on: true,
imageCrop: true}`, lets the author click an `<Image>` to select it, then drag to pan it, zoom it (wheel, pinch, or
the −/+ on the stage) and Reset it, posting `deck:image-crop-commit {slideIndex, asset, occurrence, crop: {x, y, zoom}
| null}` (source slide index, the image's `asset`, its 0-based occurrence among that asset's images on the slide) only
when the crop changed, and `deck:image-crop-state {active}` while an image is selected (a shell should not swap the
frame then); the studio stores it as the `imageCrops` override (key `"<slide>:<asset>#<n>"`, compiler 1.3.0) and the
artifact applies it before first paint. Never armed by itself; a published deck only shows the stored crops.
An image covering ≥ 90 % of the stage is a background: a plain click there selects nothing, Alt/Option+click does.
While an image is selected Esc is the crop layer's; a shell whose own page took the key sends
`deck:image-crop-clear` instead of acting on it.

Media budgets are separate from the 8 MB SOURCE budget:

| Allowance | Free | Pro | Event |
|---|---:|---:|---:|
| Image upload | 16 MiB | 32 MiB | 32 MiB |
| Video upload | 256 MiB | 1 GiB | 2 GiB |
| Stored media/deck | 512 MiB | 2 GiB | 8 GiB |
| Stored media/account | 1 GiB | 10 GiB | 40 GiB |
| Total distinct video/deck | 5 min | 15 min | 60 min |

Promo uses Free; Team, Early and Comp use Pro. Normal plans keep 40 assets/deck, Event 2,000,
imports 600. Account media grants override each field upwards independently of the plan;
the default grant allows 32 MiB images, 8 GiB videos, 20 GiB/deck, 100 GiB/account and 60 minutes/deck.
A grant can also raise the assets/deck count (up to 2,000) when the operator sets one; `cue_list_assets`
reports the effective number as `usage.maxAssets`, so read it instead of assuming 40.
Grants expire/revoke without deleting existing presentations. Read the upload grant's
`maxBytes` rather than hard-coding a number. For videos the response also includes
`resumableUrl` and `chunkBytes` (8 MiB). The browser page and local shim use this protocol
above 32 MiB, retry chunks automatically, and resume on the same link. The shim saves
private resume state in `~/.cue/uploads`; rerun the same upload command after interruption.

Resumable protocol (24-hour session, capability URL is the credential):
1. POST `{totalBytes, chunks}` to `resumableUrl`, where `chunks` is the ordered list of
   SHA-256 hex digests of every 8 MiB chunk (the final chunk may be shorter).
2. GET that URL for `offset`, `state`, and expiry. PATCH the next chunk with `Upload-Offset`.
   After a lost response, GET the committed offset before retrying. A different manifest is refused.
3. POST `?complete=1` to validate the video and queue processing. Completion is idempotent;
   the response's `result` holds the usual asset ref and job ID. DELETE cancels an unfinished upload.

Deleting an asset that source still references is allowed, but the NEXT submit
fails the gate on the dangling reference — remove the reference in the same round of
edits.

**MCP/CLI:** `cue_request_upload { deckId, filename, contentType }` mints the grant (you
run the curl yourself — or, with no shell, give the user the `uploadUrl`: opened in a
browser it is an upload page with a file picker that performs the same PUT, after which
`cue_list_assets` confirms the asset landed); the shim additionally offers `cue_upload_asset { deckId, file | url }`
(CLI `upload <deckId> <file-or-url> [--type <mime>]`), which streams the local file — or
fetches the public http(s) URL from the agent's own machine — and performs the PUT itself;
the bytes never enter the agent's context, only the small JSON result does. (The web UI's
"Import from URL" on `/library` is the browser-side equivalent: a server-side, SSRF-guarded
fetch into the user's private library, D127.) `cue_list_assets { deckId }` (CLI `assets <deckId>`); `cue_delete_asset { deckId,
assetId }` (CLI `delete-asset <deckId> <assetId>`).

### Import: a legacy deck becomes a cue deck (D352)

`POST /api/decks/import` — `multipart/form-data` with the file in `file` (optional `title`, optional `options`), bearer
token or session, author plan — turns a PowerPoint (`.pptx`), Keynote (`.key`) or PDF into a NEW,
born-gated deck and answers `202 { deckId, jobId, kind }`. The size limit follows the account's per-deck
media allowance (D401: Pro 2 GiB, Event 8 GiB, more with an operator media grant; never below 100 MiB
for PowerPoint/PDF and 512 MiB for Keynote, never above the deployment's ceiling, 20 GiB by default; a
PDF tops out at 256 MiB, as pdf.js holds the whole file in memory);
`GET /api/decks/import` (same auth) answers `{ maxBytes: { pptx, keynote, pdf }, resumable }` in bytes. The kind is
read from the file's bytes, never its name (400 when it is none of the three, 413 over the account's
limit — the message names it, and a declared `content-length` over it is refused before the body is
read — 503 when the server's staging disk is full, 429 after 10 imports an hour). No model runs and no generation is spent: the `import` job
extracts the slides, generates a normal deck project (live text, content keys `s<slide>.<layer>`),
uploads its media into the deck's asset lane and submits the project through the same gate as
`/api/decks/<id>/submit`. Poll `GET /api/jobs/<jobId>` (or tail `/events`, whose `kind: "import"`
frames carry the step: `extract`, `generate`, `media`, `build`, `done`/`failed`); a succeeded job's
`result.import` is `{ deckId, slides, hidden, report }` (≤ 64 KiB). D411: `report.review` is the import's static
self-check, `[{ slide, code, what }]` ordered by slide (1-based; `reviewMore` counts what its bound left out) with
the codes `text-outside-frame`, `number-out-of-range`, `off-stage`, `invisible-paint`, `media-missing`,
`media-inert`, `not-rendered`, `slide-degraded`, `font-script` and `group-scale`; `report.coverage` is `{ slides,
layers, layersRendered, chars, charsEmitted }`; then the fonts substituted, `report.unsupported` (every kind the
extractor drew approximately or left out, one line each with `slide` and, for several, `slides`), `warnings` and
`info`. Every slide number in the report is 1-based. Media (spec 24 B): pictures in PNG, JPEG, WebP, GIF, BMP, TIFF,
HEIC (where the server decodes it), SVG (rasterised when self-contained, else its PNG fallback) and EMF / WMF (their
embedded bitmap, else a labelled placeholder — a `warnings` line with its slide, a `media-missing` review line and
`report.media.placeholders`); video in MP4, MOV, M4V, AVI, WMV, MPEG, WebM and MKV (converted to MP4); audio in MP3,
M4A, AAC and WAV, and a WAV or MP3 inside an embedded OLE package (read by magic bytes only), wrapped as an MP4 under
the layer's icon picture. `cue_job` leads an import's result with `slidesToCheck`
("Slides to check: 3, 9–12") and `reviewSummary`; read those first and check the slides with the owner. A failed import that never built removes its deck again.
**Media still processing (D417):** a video whose processing outlasts the import is counted in
`report.media.pending` (one-based slides in `report.media.pendingSlides`) and its slide holds a `sha256:<hex>`
placeholder ref. When it is ready cue places the real `assets/<id>.<ext>` ref in the DRAFT itself — a revision
`via: "media-heal"` after the deck's other jobs; `report.media.healed` (`[{ files, assets, slides, kind, at }]`) lists
what was placed. Pull again before editing: a submit of an older copy that still holds a placeholder puts that file
back on pending and cue places it again. Live never changes: a publish while files are still processing answers
`mediaPending: { count, slides, message }` (also on an async publish job's `result.publish`).
**Import options (D412)**: `options` is JSON (at most 512 bytes, only these keys; anything else is a 400 with the
reason) `{ video?: "as-authored" | "entry" | "click", sound?: "as-authored" | "muted", language?: "en" | "de" | "es" |
"fr" | "ja" | "zh" | "nl" | "ar" | "ko" }`. As authored (the default), each video starts as the file says: with its
slide (`playOnStep={0}`), on a click (a Start Movie build), or — "when clicked on" or no play command — from its own
controls, which a presenter's play/pause/seek drives for every follower; a video with sound plays with sound
(muted with tap-for-sound where the browser refuses). `entry` starts every video with its slide, `click` gives every
video its controls, `sound: "muted"` mutes them, `language` sets the deck's source language over the script guess.
The report echoes them as `report.options`.
**Re-import (D416):** `deckId` (in the query string, checked before the body is read; a form field may only repeat
it) imports the file INTO that deck instead: the caller's own deck with an import record, made by the import route, or empty; anything
else answers 404, the same as a deck that does not exist; a deck under a moderation hold answers 403 `deck_held`. No new deck, no quota; the result is a new DRAFT revision
(`via: "import"`; live changes on publish), `202 { deckId, jobId, reimport: true }`. Content keys are
`s<source slide id>.<layer id>`, so studio overrides, notes and translations carry to the moved slide; unchanged
media are reused. `onEdits` (`"refuse"` default, or `"replace"`): a deck whose generated source was edited in cue
since its import answers `409 { code: "deck_edited_since_import", edits: { files, slides } }` (or `edits: { unchecked:
true }` for a deck imported before re-import whose imported version is gone) unless it is `"replace"`.
**Edits kept per slide (D418):** the generated source wraps each slide's component in `// cue:slide-begin <key>` …
`// cue:slide-end <key>`. A slide's unit is that block, its `s<key>.*` strings in `content-<lang>.ts` and its row in
`media-slides.json` (its translations travel with it). Edits inside units never refuse: a slide the file did not
change keeps the cue version; one it changed (its slide, master, theme, the options or the generator) takes the file's
and is listed in `report.reimport.replaced`, unless `onConflict` (`"take-file"` default, or `"keep-cue"`; query string
only, needs `deckId`) is `"keep-cue"`. Only edits outside the units answer the 409, with `edits.outsideBlocks: true`
and only those files and slides listed. If the merged deck fails the gate, the file's version is built instead
(`merge: "fallback"`, every edited slide replaced). Slides map by
one scored, order-preserving alignment of their content (the source id only adds to content evidence;
`report.reimport.mode` is "aligned", `idOnly` counts pairs matched on id and structure alone). Owner notes move with
their slides and a restore to before the import moves them back; reviewer notes keep their anchor. An owner note
`POST /api/decks/<id>/notes` may carry `draftRevision` (the draft it was composed against); after a re-import its
slide is translated to the new draft (or the note is created detached when its slide was removed). Without `options` the deck's last import options apply. The job result's `report.reimport` is
`{ mode, bestEffort?, unchanged, changed, added, removed, moved, mediaReused, mediaNew, carried: { overrides, notes,
translations }, notesUnanchored?, dropped, replacedEdits?, kept?, replaced?, merge? }` (one-based slides; `kept` /
`replaced` are the slides whose cue edits were kept or replaced, `merge` "merged" or "fallback").
**Kept package, re-run, slim re-import (D419):** a succeeded PowerPoint or Keynote import keeps its package's
"skeleton" beside the deck — the parts the importer read, without media or fonts — until the deck is deleted;
`report.skeleton` is `{ kept, bytes, media, omitted, rerun?, reason? }`. `GET /api/decks/<id>/reimport` answers
`{ rerun: { available, fileName?, kind?, importedAt?, skeletonBytes?, media?, options? } }`; `POST
/api/decks/<id>/reimport { options?, onEdits? }` re-imports that skeleton with no upload (the current importer;
without `options` the last ones) → `202 { deckId, jobId, reimport: true, rerun: true }`, with the re-import's 404,
409 `deck_edited_since_import` and limits, and `409 no_skeleton` when nothing is kept (imported before this, a PDF,
too large, or a restore went back to an older import). A SLIM re-import sends only the media the deck lacks: `POST
/api/decks/<id>/reimport/have { manifest: [{ path, bytes, sha256 }] }` (the file's `ppt/media/*`,
`ppt/embeddings/*` or Keynote `Data/*` entries, sha256 of the uncompressed bytes, ≤ 10 000) → `{ have: [sha256…] }`,
answered from THAT deck's own media only (120 calls an hour). Then upload, with `deckId`, a ZIP of every other
entry plus the media not in `have` plus a stored (uncompressed) `cue-manifest.json` `{ "v": 1, "omitted": [{ path,
bytes, sha256 }] }` naming what was left out; an omitted entry the deck does not hold fails the job with
`media_not_on_deck` (the whole file is always valid). The
shim's `cue_import { file, title?, cancel_pending?, options?, deckId?, onEdits?, onConflict?, slim? }` (or `{ deckId,
rerun: true, options?, onEdits? }` with no file) imports a local path; with `deckId` it sends the slim form
(`result.slim`: `sentBytes` of `fileBytes`; `slim: false` sends the whole file) (it checks the file against the
GET's caps first, then uses the resumable flow below, or the single POST on a server without it); afterwards the
deck is pulled, edited and submitted like any other. Each `report.fonts[]` line carries an `action`: `upload`
(no library holds the family — with the owner's licence, `cue_upload_font` / `POST /api/fonts/grants`
on an event or team plan, then resubmit the unchanged source so the build resolves it), `accept`
(a metric-compatible stand-in keeps the layout) or `none` (`inLibrary: true` when the owner's own font library
already holds the family — never ask for an upload then), plus a one-sentence English `hint`,
`usedOnSlides` and `embedded` (`{ fsType, sha256 }` when the PPTX embeds that face). Act on it with
the owner; offer to redraw what `report.unsupported` lists rather than re-authoring the deck.

**Resumable upload (D402)** — for large files or flaky links; the single POST stays for small ones. When the GET
answers `resumable: { path: "/api/decks/import/uploads", chunkBytes }`: `POST <path>` with JSON `{ filename,
totalBytes, title?, chunkBytes?, options?, deckId?, onEdits?, onConflict? }` (`options` as above, as a JSON object; `deckId` /
`onEdits` / `onConflict` for a re-import, checked here and again at finalize; `onConflict` without `deckId` is 400) → `201 { token, offset, chunkBytes, state, expiresAt, firstChunkSha256,
lastChunkSha256 }` (413 over the cap, 503 `staging_busy`, 409 `session_open` with `existing` — one open upload
per account; `DELETE <path>` cancels it, `GET <path>` returns `{ session }` — and a plain 409 while an import job
is already running). Then `PATCH <path>/<token>` each chunk in order as `application/octet-stream` with
`Upload-Offset` (its byte offset) and `Upload-Sha256` (its hex SHA-256); each answer is the new status, and a 409
carries the server's `status` to continue from. To resume after a drop or a restart, `GET <path>/<token>` and
continue at its `offset` (check `firstChunkSha256`/`lastChunkSha256` against the local file first). `POST
<path>/<token>/complete` classifies the bytes and answers `202 { deckId, jobId, kind, … }` (or the same 400/403/413
as the single POST); follow the job as above. An idle or overdue session answers 410 `expired`: start again.
`DELETE <path>/<token>` cancels one session.

### Fonts: the account font library (event-decks WP10)

Fonts are ACCOUNT assets, never deck assets: an account on the **event or team plan** keeps
licensed fonts in its library, and every build of a deck that account owns ships a SUBSET of
each declared face (only the glyphs the deck's source uses) as a same-origin WOFF2 plus
`fonts.css`. Nobody — the owner included — can download a font back; there is no byte route.

| Verb | Path | Purpose |
|---|---|---|
| GET | `/api/fonts` | the caller's fonts (family, weight, style, format, bytes, `embedPermission`, `noSubsetting`, label — never bytes) + `usage` + `canUpload` (`read` scope) |
| POST | `/api/fonts/grants` | mint a single-use font upload URL (body `{ attest: true, label? }`) → `{ uploadUrl, method: "PUT", expiresAt, maxBytes, curl }`; PUT the raw OTF/TTF/WOFF/WOFF2 bytes there (`author` scope) |
| POST | `/api/fonts` | multipart `file` + `attest=on` (the /account page's form; `author` scope) |
| DELETE | `/api/fonts/:id` | remove one font from the library (soft delete; built versions keep their subset) |

Every upload requires the attestation — `attest: true` records the user's statement "I hold a
licence permitting use of this font in content served by cue on my behalf." with its time and
IP; ask the user, never attest on their behalf. A font whose licence flags (`OS/2.fsType`)
forbid embedding (restricted, bitmap-only) is refused (`422`); a no-subsetting flag ships the
whole face. 12 MB per file; above 40 fonts / 100 MB the account is logged, not refused.

A deck declares faces in the `theme` object of its `theme.tsx`, as a LITERAL (the build reads only that
file, as data; a variable or spread fails the gate; at most 24 MB of fonts ship per artifact):
`fonts: [{ family: "GT Haptik", weight: 500, style: "normal", local: ["GT Haptik Medium"], fallback: { family: "Inter", sizeAdjust: 101 } }]`
and `fontsAllowLocal: false` (default; `true` also emits `local()`). Resolution per face: the
deck owner's library (family case-insensitive, same style, weight exact or ±100) → cue's
licensed library → `local()` if allowed → the declared fallback (a `"<family> Fallback"` face
carrying the metric overrides — put it second in the token's font stack). The gate prints one
`fonts` line per face (`library` / `cue` / `fallback` / `missing`) and a successful job's
`result.fonts` repeats them; a face that resolves nowhere without a fallback FAILS the gate.

**MCP/CLI:** `cue_upload_font { attest: true, sourceUrl?, label? }` (remote: `sourceUrl`
has the server fetch a public font URL, otherwise it returns the `uploadUrl` — which, opened
in a browser, is an upload page the USER can use), `cue_upload_font { path, attest: true,
label? }` (local shim: reads the file and PUTs it itself), `cue_list_fonts {}`,
`cue_delete_font { fontId }`.

**Outlines travel with the deck (event-decks WP10b).** Fonts stay with the licensee's account;
the text's vector OUTLINES are deck assets. A deck that ships a `text-layout.json` (+
`text-layout-NN.json` parts; written by the Keynote import generator — per text layer: box,
lines with boxes + baselines, font, size, tracking, align, colour, `textHash`, `lang`) gets, at
every build, `outlines/<slideId>.svg` — one `<defs>` holding each glyph the slide uses once
(`<path id="g-…">`, font units), then one `<symbol id="o-<layerId>" viewBox="0 0 w h"
overflow="visible">` per source-language text layer whose lines are `<use href="#g-…"
transform="translate(x y) scale(s -s)">` per glyph, stage px relative to the layer box (inline the
whole sprite so the nested `<use>` resolves) — and `outlines/index.json` `{ v: 1, source: "en", objects: { <layerId>: {
slideId, textHash, font, source: "library"|"fallback", generatedAt, sha256, stale?, lines,
boxDelta } } }`. Lines are shaped with HarfBuzz from the face the deck OWNER's account resolves
(the real font from the font library → `library`; else its fallback family → `fallback`);
line breaks come from the layout. The set lives with the deck and is carried by fork (only the
layers + text hashes the forked source contains), duplicate and an accepted proposal (a
`library` outline replaces a `fallback`, stale or missing one, never the reverse). A rebuild
never overwrites a `library` outline with a fallback one: it keeps it, and marks it `stale`
when the text changed. A successful job's `result.outlines` reports shipped / library /
fallback / stale / generated; the gate's `fonts` step adds an advisory outline line (never
blocking).

### Room operators (event-decks WP10b)

A talk's owner can let other accounts RUN the room of that talk without owning the deck. The
talk id is the presentation id (`p_…`, the console's `?room=`).

| Method | Path | What |
|---|---|---|
| GET | `/api/talks/:id/operators` | the talk's operators `{ operators: [{ email, addedBy, addedAt }] }` (owner only) |
| POST | `/api/talks/:id/operators` | `{ email }` — add one (owner only, idempotent) |
| DELETE | `/api/talks/:id/operators` | `{ email }` — remove one (owner only); their next room-token re-mint is refused |

An operator opens `/present/<deckId>?room=<talkId>` (the console, published decks only), mints
presenter room tokens (`POST /api/rooms/token`, role `presenter` — the owner's room credential,
`sub` naming the operator), creates/revokes screen links, drives captions and the question
queue. They cannot edit, publish, unpublish, delete or re-share the deck. MCP:
`cue_talk_operators { talkId, add?, remove? }` (remote and local shim).

### Calls: a call for decks (D362)

A Call has a brief, a deadline in a stated IANA time zone and an entry mode; participants ENTER
it with a published deck of their own (one entry per person; re-entering before the deadline
replaces). The deadline is a cut, not a lock: publishing later is allowed. `:id` is the Call id
(`call_…`) or its slug (the code people type on `/call`). Errors carry `{ error, code }`.

Agents reach the same endpoints through five MCP tools, identical on the local shim and the remote
connector (L2-5): `cue_call_create` (POST `/api/calls`; requires `entryMode`), `cue_call_entries {call,
format?: "csv"}` (GET `…/entries`), `cue_call_enter {call, deckId, team?, members?, key?}` (POST
`…/entries`), `cue_call_withdraw {call, deckId}` (DELETE `…/entries` with `deckId`) and (D370)
`cue_call_decide {call, entryId | deckId, decision, note?, organizerNote?}` (PATCH `…/entries/:entryId`;
a `deckId` names that deck's active entry in the Call). CLI:
`node cue-mcp.mjs call-create <title> --deadline <iso> --tz <zone> [--mode …]`, `call-entries <call>
[--csv]`, `call-enter <slug> <deckId>`, `call-withdraw <slug> <deckId>`, `call-decide <call>
<entryId|deckId> <decision> [--note <text>] [--organizer-note <text>]`. Remote refusals read
`<error> [<code>] (<status>)`.

| Method | Path | What |
|---|---|---|
| POST | `/api/calls` | open a Call (`author` scope; needs a live Calls grant — no plan includes Calls, cue enables them per account on request — else 403 `{ code: "needs_grant", capability: "calls", error, contact }`; `contact` is the address to write to). Body `{ title, deadlineAt (ISO, future), tz (IANA), entryMode?: "link" \| "allow_list" \| "secret_key", allowList? (emails, @domains), brief?, templateDeckId? (your own deck), maxEntries? (default and ceiling: the entries limit on your Calls grant, 100 unless set), slug? }` → 201 `{ call, link, secret?, secretLink? }`; a secret-key Call's `?k=` is shown ONCE. 400 invalid, 409 `slug_taken` |
| GET | `/api/calls/:id` | public Call info `{ call: { id, slug, title, brief, deadlineAt, tz, entryMode, period: "open" \| "judging" \| "archived", link, hasTemplate }, viewer: { signedIn, entry, admission: { ok, reason? }, template? } }` — never the allow-list, secret or roster; pass `?k=` to have `admission` checked against a secret-key Call (`read` scope with a token) |
| PATCH | `/api/calls/:id` | organizer controls (`author` scope; organizers only — anyone else gets the 404 `not_found`): `{ archived?: true, afterDeadlinePolicy?: "show_marked" \| "closed", rotateSecret?: true }` → 200 `{ call, link, secret?, secretLink? }` (a rotated `?k=` is shown ONCE; the old one stops working). Archive is one-way (`archived: false` is 400) and ends the Call; an archived Call takes no other change (409 `archived`); `rotateSecret` on a non-secret-key Call is 400 |
| POST | `/api/calls/:id/entries` | enter or replace: `{ deckId, team?, members?: string[], key? }` (`publish` scope). The deck must be yours (404 `deck_not_found`) and published (409 `publish_first`). 201 `{ entry, replaced: null }`, 200 on a replace `{ entry, replaced }`. 403 `not_listed` / `bad_key`; 409 `after_deadline` / `archived` / `full` / `deck_taken` |
| DELETE | `/api/calls/:id/entries` | withdraw your own entry (`publish` scope); optional `{ deckId }` (body or `?deckId=`) must be the deck your active entry holds, else 409 `deck_mismatch` `{ entryDeckId }` → 200 `{ entry }`; 409 `after_deadline` / `archived`, 404 `not_entered` |
| GET | `/api/calls/:id/entries` | the entries table (`read` scope; organizers and judges only — anyone else gets the 404 `not_found`) → `{ call, role, rows: [{ entryId, team, members, entrant? (organizer only), enteredAt, status: "active" \| "withdrawn" \| "replaced", withdrawnAt, deck: { id, title, published } \| { id, deleted: true }, counting: { ordinal, createdAt, minutesBeforeDeadline } \| null, latest: { ordinal, createdAt, late } \| null, opens: [{ judge? (organizer only), ordinal, lastOpenedAt }], decision? (organizer only: { decision, decidedAt, decidedBy, decisionNote, organizerNote }) }], roster? (organizer only) }`. A judge sees active entries only, no emails, and only their own opens. `?format=csv` (organizers only, else 403 `organizer_only`) returns the same rows as CSV, one line per entry, withdrawn included, ending with `decision` and `decided_at`; cells a spreadsheet would read as a formula get a leading `'` |
| PATCH | `/api/calls/:id/entries/:entryId` | an organizer's decision on an entry (D370; `author` scope; organizers only — a judge gets 403 `organizer_only`, anyone else the 404 `not_found`): `{ decision?: "pending" \| "shortlisted" \| "accepted" \| "declined" \| "waitlisted", decisionNote?: string \| null (shown to the entrant, ≤ 500 characters), organizerNote?: string \| null (organizers only — never the entrant or a judge, ≤ 2000) }`, at least one → 200 `{ entry }` with `decision`, `decidedAt`, `decisionNote`, `decidedBy`, `organizerNote`. A changed decision stamps `decidedAt`/`decidedBy`; `pending` clears both; `null` or `""` clears a note. 400 `invalid`, 404 `not_found` (no such entry in this Call), 409 `entry_inactive` (withdrawn or replaced), 409 `archived`. The entrant reads `decision`, `decidedAt` and `decisionNote` on their own `viewer.entry` (GET `/api/calls/:id`) — `decisionNote` is null there while the decision is `pending`; withdraw is unaffected, and a replacement carries the decision, its stamp and both notes forward |
| GET | `/api/calls/:id/roles` | the roster (`read` scope; organizers only, else 404) → `{ roster: [{ email, role: "organizer" \| "judge", addedAt }] }` |
| POST | `/api/calls/:id/roles` | add, revive or change a person's role (`author` scope; organizers only, else 404): `{ email, role: "judge" \| "organizer" }` → 200 `{ role, roster }`; demoting the last organizer is 409 `last_organizer`; an archived Call is 409 `archived` |
| DELETE | `/api/calls/:id/roles` | remove a person from the roster (`author` scope; organizers only, else 404): `{ email }` → 200 `{ removed: true, roster }`; their Call-lane access ends at once. 409 `last_organizer`, 404 `not_on_roster`, 409 `archived` |

An entered deck holds no publish slot while the Call is open (not archived), so a free-lane
account whose slots are full can still publish its entry.

An entered deck cannot be deleted while its entry is active in a non-archived Call:
`DELETE /api/decks/:id` and `cue_delete_deck` answer 409 `{ code: "entered_in_call", error: "entered in an open Call
<title>", calls: [{ id, slug, title, deadlineAt }] }`, and account deletion (`DELETE /api/account`) refuses the
same way before anything is removed. Withdraw the entry before the deadline, or ask the organizer to archive the
Call. Unpublishing stays allowed (the entry stays with the organizer), and every version of a deck with any entry in
a non-archived Call is kept from retention pruning until the Call is archived.

### Programmes: a run of show built on Calls (D370)

A programme owns stages, slots, roles (`organizer`, `committee`, `stage`) and holds; a Call created with `programmeId`
is its slides deadline. Creating a programme needs a live Programmes grant (cue enables it per account; else 403
`{ code: "needs_grant", capability: "programmes", error, contact }`); a Call with `programmeId` needs an organizer role
on the programme and that grant on the programme's organizer — not a Calls grant. A programme organizer is an implied
organizer of its Calls and a committee member an implied judge. A Call with a programme carries `programme` and the
fixed `consent` line on `GET /api/calls/:id` and in the enter result (`POST …/entries` → `{ entry, replaced,
programme, consent, slotId }`): the entry binds to the entrant's earliest open slot with the same email (planned →
confirmed); a replace rebinds, a withdraw unbinds. A deck bound to a slot of a non-archived programme cannot be
deleted (409 `entered_in_call`, with `programmes`) and keeps every version, past its Call's archive. `:id` is the
programme id (`pg_…`) or slug. Session or Bearer; errors carry `{ error, code }`.

| Method | Path | What |
|---|---|---|
| GET | `/api/programmes` | your programmes (any live role) → `{ programmes: [{ …programme, role, link }], canCreate }` (`read`) |
| POST | `/api/programmes` | `{ title, tz, brief?, startsOn?, endsOn? (YYYY-MM-DD), venue?, slug?, alwaysLatest?, autoCloseOnHandBack? }` → 201 `{ programme, link }` (`author`; 403 `needs_grant`) |
| GET | `/api/programmes/:id` | members → `{ programme, role, stages, slots, calls, roster, holds, speakers, limits: { slotsMax, speakersMax } }`; anyone else → the public view of a PUBLISHED programme `{ programme, stages, slots (speaker names, never emails), calls, role: null }`, else 404 |
| PATCH | `/api/programmes/:id` | organizers (`author`; committee/stage 403 `organizer_only`): `{ title?, brief?, startsOn?, endsOn?, tz?, venue?, alwaysLatest?, autoCloseOnHandBack?, published?: boolean, archived?: true }` → `{ programme }`. Archive is one-way and ends the speaker allowance |
| GET/POST/DELETE | `/api/programmes/:id/roles` | roster: GET organizers + committee (each row `{ email, role, addedAt, stageId }`); POST `{ email, role: "organizer" \| "committee" \| "stage", stageId? }` (D374: `stageId`, stage role only, places a stage member on their OWN stage, where they may approve latest; `null` clears it), DELETE `{ email }` organizers (409 `last_organizer`, 404 `not_on_roster`) |
| GET/POST/PATCH/DELETE | `/api/programmes/:id/stages` | GET members; POST `{ name, screenId?, screenIds?, sort? }` (201), PATCH `{ stageId, name?, sort?, screenId?, screenIds? }` (D404: `screenIds` is the ordered list of screens the stage shows on at once, at most 8, the first the primary; `screenId` = a list of one; a change also answers `bookingsSynced`, `warnings` (e.g. `screen_not_owned`) and `screenWarnings`); every stage carries `screenIds`, DELETE `{ stageId }` organizers |
| GET | `/api/programmes/:id/slots` | members → `{ programmeId, slots: [{ id, stageId, startsAt, endsAt, title, speakerName, speakerEmail, format, track, state, callEntryId, approvedVersionOrdinal, entry: { id, deckId, callId, callSlug } \| null, versions: { counting, latest, approved, stage }, readiness: { booked: "accepted" \| "pending" \| null, bookingId, preloaded, readyVersionId, blockedReason, stageVersionId, warnings: ("terms_block_room" \| "screen_not_owned" \| "not_preloaded")[] }, remote: { pairedAt, readyAt, devices }, approval: { by, name, at } \| null, closedAt, bookingId, presentationId, talkId, … }] }` (D374 `approval`: who approved the version and when; a stage member's read carries `by` only for their own approval) (the same slot objects ride `GET /api/programmes/:id`) |
| POST | `/api/programmes/:id/slots` | organizers: `{ slots: [{ id?, title, speakerName?, speakerEmail?, format?, track?, stageId?, startsAt?, endsAt? }] }` → `{ created, updated, slots }`; 409 `slot_cap` (grant `entries_max`, default 200), 409 `speakers_full` (grant `speakers_max`, default the slot cap) |
| PATCH | `/api/programmes/:id/slots/:slotId` | organizers — and (D374) a stage member for `{ action: "approve", ordinal: "latest" }` on their own stage only (403 `not_your_stage` elsewhere, 403 `organizer_only` for an explicit ordinal or any other action): `{ action: "bind", entryId }` \| `{ action: "unbind" }` \| `{ action: "approve", ordinal: n \| "latest" }` \| `{ action: "cancel" }` \| `{ action: "move", stageId?, startsAt?, endsAt? }` → `{ slot }`; 409 `entry_bound` / `entry_inactive` / `not_bound` / `no_version` / `cancelled`, 404 `unknown_version`. `:id` may be `-` (resolved from the slot) |
| GET | `/api/programmes/:id/stages/:stageId/live` | PUBLIC once the programme is published (members while unpublished; else 404), no auth: the per-stage live page's read → `{ state: "live" \| "hold" \| "off", programme: { slug, title, tz }, stage: { id, name }, talk: { slotId, roomId, title, speakerName, joinUrl } \| null, upNext: { slotId, title, speakerName, startsAt, endsAt } \| null, hold: { kind, label } \| null, liveUrl }` — `liveUrl` (`/programme/<slug>/live/<stageId>`) is the public address per stage; `joinUrl` is the running room's door — it carries the room pass only with the stage's live secret `?s=` (the QR cue draws in the room; organizers print it from the console), else the deck's own gate answers. 404 once archived. Names and titles only, cached ~3 s |
| GET/POST/PATCH/DELETE | `/api/programmes/:id/holds` | GET members (each hold carries `slide`: 0-based, null = loop); POST `{ stageId, startsAt, kind: "idle" \| "deck" \| "up-next", deckId? (yours), label?, slide? (kind deck: 0-based slide to hold on; absent loops the deck) }` (201), PATCH `{ holdId, slide?: number \| null, label?, startsAt?, deckId? }` → `{ hold }` (only the fields present change), DELETE `{ holdId }` organizers |
| POST | `/api/programmes/:id/import` | organizers: `{ csv, callId? }` — header `name,email,title,format,track` (+ `stage,starts_at,ends_at`) → `{ created, updated, unchanged, skipped: [{ line, reason }], callId, allowListAdded, bound }`; 409 `call_ambiguous`, `allow_list_full` |
| GET | `/api/me/upcoming` | your upcoming slots as a speaker (`read`; `?deckId=` narrows) → `{ upcoming: [{ programme: { id, slug, title, tz }, stage, slot: { id, title, startsAt, endsAt, state, format, track }, call: { id, slug, title, deadlineAt, tz, link } \| null, entry: { id, deckId } \| null, deckId, versions: { counting, latest, approved, stage }, phase: "deliver" \| "delivered" \| "cut" \| "day", late }] }` |

MCP (both lanes): `cue_programme_create`, `cue_programme_slots {programme, action?: "list" | "upsert", slots?}`,
`cue_programme_bind {slot, entry}`, `cue_programme_approve_version {slot, ordinal | "latest"}`, `cue_programme_import
{programme, csv, callId?}`; `cue_call_create` takes `programmeId`; `cue_talks` without `deckId` returns `{ upcoming }`
and with one adds the deck's `upcoming`.

**Recap term (D374).** A programme Call may carry an optional recap-publication term: `cue_call_create` /
POST `/api/calls` take `recapTerm: true` and `recapTermNote?` (at most 500 characters; a standalone Call is 400
`invalid`); PATCH `/api/calls/:id {recapTerm?, recapTermNote?}` turns it off any time, but on or reworded only while
the Call has no entries (409 `term_locked`). `GET /api/calls/:id` shows it as `call.recapTerm {note}` (null without
one). The entrant answers with `recapConsent` on `cue_call_enter` / POST `…/entries` (true agrees, false declines,
omitted carries a replaced entry's answer; optional — the entry stands without it) and changes it at any time with
PATCH `…/entries {recapConsent}` (409 `no_recap_term`, 404 `not_entered`); entries carry `recapConsentAt`. When the
slot's entry agreed, an organizer's share of the programme talk opens the talk's RECAP (never the deck, its slides or
the transcript) to the share's audience even when the deck is gated: `GET /api/decks/:id/talks/:talkId` answers such
a reader `recapOnly: true` with empty `segments` and `navTitles`, and `/programme/<slug>/recap/<slotId>` is its page. CLI: `programme-create <title> --tz <zone>`, `programme-slots <programme>
[--upsert <slots.json>]`, `programme-import <programme> <file.csv> [--call <callId>]`, `programme-bind <slot> <entry>`,
`programme-approve <slot> <ordinal|latest>`, `upcoming`. Operators grant the feature with `pnpm ops features grant
<email> --feature programmes [--entries N] [--speakers N]` or on `/admin/users`.

**The day is not an agent lane.** The slot's talk is started, handed back and closed by a signed-in organizer or
stage member from the stage console and the phone remote (`POST /api/programmes/:id/slots/:slotId/start | hand-back
| close`, session only — a Bearer token does not authenticate there), and there are no MCP tools or CLI verbs for
it. The room and the talk are the Programme's; the version on stage is the slot's `versions.stage`, and a slot whose
stage has a screen is booked on that screen two hours ahead (`readiness`); during the slot that screen shows the room,
between slots the stage's hold (the up-next card, an organizer's deck or the screen's idle content). The stage console
(`/programme/<slug>/stage/<stageId>`, its read `GET /api/programmes/:id/stages/:stageId/console`) and a finished talk's
share (`GET | PUT { scope: "deck" \| "attendees" } | DELETE /api/programmes/:id/slots/:slotId/share`, organizers) are
session only too. An agent reads the run of show and its
readiness (`GET /api/programmes/:id`, `cue_programme_slots`) and prepares it (bind, approve, import); it does not
run it.

### My notes: private notes per person (D314)

Two layers of notes ride a deck. **Speaker notes** live in the source and travel to everyone who
presents it. **My notes** ("private notes") belong to one account on one deck: only that account
reads them — never the owner, another presenter, an operator or an admin surface — and they are
never in the source, a fork or a proposal. The owner and anyone who may present the deck
(Presenter, Can fork, Co-editor, on the published version) keep their own.

| Method | Path | What |
|---|---|---|
| GET | `/api/decks/:id/my-notes` | your notes for the served (latest) version: `{ deckId, versionId, slideCount, notes: [{ slideIndex, ref, body, updatedAt, matchedBy, seq }], orphaned: [{ ref, slideIndex, title, body, updatedAt }] }` |
| PUT | `/api/decks/:id/my-notes` | `{ versionId, slideIndex, body, seq? }` or `{ ref, body, seq? }` — set one note (≤ 8000 characters; empty clears) → `{ deckId, versionId, slideCount, written: { slideIndex, ref, applied }, orphaned }` |
| DELETE | `/api/decks/:id/my-notes` | `{ versionId, slideIndex }`, `{ ref }` or `{ all: true }` — clear one or all of yours → the PUT shape plus `removed` |

`slideIndex` is 0-based in the version the read returned, and a write by index must send that
`versionId`: after a republish it is refused `409 { error: "version_changed", versionId,
slideIndex }` (where that slide now sits when it maps by key and title, else null) and nothing is
written (a presenter gets `slideIndex: null`). `seq` orders your writes: one whose `seq` is not newer than the
stored note's answers `applied: false` (omitted = now). `ref` is an opaque, stable handle for one of your stored
notes, orphaned ones included. The slide
identity behind it is derived server-side from the published source, so a note follows its slide
through reorders and inserts; a note whose slide is gone is returned under `orphaned` instead of
landing on another slide, and a write never overwrites a different note. Decks only (a document is refused);
bodies over 100 KB are refused 413;
writes are rate limited per account and deck. Read needs the `read` scope, writes `author`; anyone
else gets the same 403/404 any owner route gives a non-owner. MCP: `cue_my_notes { deckId, action:
"read" | "write" | "clear", versionId?, slideIndex?, ref?, body?, all? }` (remote and local shim).

### Access tiers on publish

A deck carries an access tier, enforced on EVERY viewing surface (the /view page, the
raw artifact fetch, PDF, PPTX, thumbnail, live-room viewers), not just the share page. **New
decks are born `gated`** — opening a deck to anyone with the link is an explicit choice.
`POST /api/decks/:id/publish` accepts an optional `{ access, invitees, notify }` body (the
same fields the `PATCH /api/decks/:id` lane takes), and the response echoes `access` plus
the URLs to hand back — read that `access` field and relay the resulting tier to the user:

- **`gated`** (the default for a new deck): private to the owner and explicitly named
  `invitees` (an email array). Empty or omitted `invitees` means owner-only. The URLs are
  unchanged, but anyone who is not the owner or a named person is stopped before the deck
  loads.
- **`public`**: anyone with the link — pass `access: "public"` explicitly to open the
  deck up. `viewUrl`/`liveUrl` are the plain share URLs.
- **`link`**: an unguessable, rotatable share token, no account needed. The returned
  `viewUrl`/`shareUrl` carry it as `?k=<token>`, so hand the user THAT URL. Settable only
  when cue enables secret links for the deck's owner; otherwise publish
  rejects `access: "link"`. A `link` deck may carry MANY named links — one per channel,
  each with its own secret, optional expiry and its own revocation: `POST
  /api/decks/:id/sharing` takes `addShareLink: {label, expiresInDays?}` (the URL comes back
  once, in `mintedShareLink`), `revokeShareLink: <id>` (kills exactly that door) and
  `rotateShareLink: <id>`; `rotateLink: true` stays the wholesale panic button that burns
  the deck key and every named link. Live links are listed as `shareLinks` — labels and
  ids, never secrets.

`notify` — optional boolean, **off by default**, on both `publish` and `PATCH`. `true`
emails a share notification (deck title, cover thumbnail, sender identity, a no-secret
`/view/:id` link) to every email in `invitees` that this call NEWLY added — people already
on the list are never re-notified. Sends are best-effort and rate-limited, so they never
fail the request itself; the response gains `notified: [<emails actually sent>]` whenever
`notify: true` was passed.

```sh
# publish privately to two named people and email the newly-added invitees
curl -s -X POST -H "authorization: Bearer $TOKEN" -H "content-type: application/json" \
  -d '{"access": "gated", "invitees": ["alice@acme.com", "bob@acme.com"], "notify": true}' \
  https://cue.humanmeetsai.com/api/decks/<id>/publish
# → {..., "notified": ["alice@acme.com", "bob@acme.com"]}
```

Omit `access` to keep the deck's current tier. The record is the source of truth for the
tier; the `?k=` key is a presented credential compared against it, never policy.

### Named shares: grants

`invitees` (above) is a wholesale replacement list — every call sets the complete set of
admitted emails, and everyone on it sees the deck's `current` version. **Grants** are the
other way to name individual people: additive and idempotent (each call adds or retargets
one person without touching anyone else's share), and each one can optionally **pin** the
recipient to a specific published version, so they keep seeing exactly that version no
matter how many times the deck is republished afterward. A grant admits its recipient
regardless of the deck's access tier — same as `invitees` — and, when pinned, decides which
version they're served on `/view`, the PDF, and the PPTX download; live-presentation
surfaces always show `current` regardless of any pin.

**Version numbers and `?v=` (D361).** Every original publish carries an ordinal (v1, v2, …;
`ordinal` on `GET /api/decks/:id/history` entries); a set-live entry reads "same as vN" and
carries `sameAs` (the original's id). `createdAt` is the commit time. `/view/:id?v=N` serves
version N to the owner, a co-editor and a grantee with `history`; anyone else gets what they
would get without it (no existence oracle). `history` on a grant therefore means "may browse
this deck's published versions" — not revisions, diffs or restore. `GET /api/decks/:id/versions`
(session-based, same policy, `404` otherwise) → `{ current, versions: [{ ordinal, id, createdAt,
sameAs?, current }] }`, newest first. `/live` and room tokens ignore `v`. A Call's organizers and
judges (D362) browse an entered deck the same way, landing on its counting version; their list
entries also carry `afterDeadline`, and a closed Call omits those (and refuses them by `?v=`).

| Verb | Path | Purpose |
|---|---|---|
| GET | `/api/decks/:id/grants` | list this deck's grants (owner-only; includes revoked rows) |
| POST | `/api/decks/:id/grants` | create or retarget one grant (body below) → `{ grant, grants, notified, notifyReason? }` |
| DELETE | `/api/decks/:id/grants?email=<e>` | revoke a grant (idempotent; `404` if none exists for that email) |
| GET | `/api/decks/:id/readers` | (owner-only) read receipts → `{ totals: { opens, uniqueViewers, avgDepth }, byLanguage, byVersion, byRecipient, identities, recent }` (D361: `byVersion` counts readers by the version they last opened; each `identities[]` row carries `lastVersion` — "v3", "same as v3", or `null`). **`aggregateOnly: true`** is present only when the per-viewer half was withheld (D216 — the owner is on the free lane, or the account is on hold): `totals` and `byLanguage` are real and complete, and `byRecipient`/`identities`/`recent` come back EMPTY. Empty arrays under that flag mean "not shown", never "nobody opened it" — report the totals and say who-read-what is Pro. **`detailUntil: <ISO instant>`** is the other, narrower case (D216 freeze-at-lapse): the owner's author plan ended then, so the per-viewer rows are real but stop there while `totals`/`byLanguage` still count every session — the difference is opens that are counted and not identified, and Pro brings the names back. The two are mutually exclusive and both are absent entirely for every other plan, so an unchanged payload means unchanged meaning |
| GET | `/api/decks/:id/talks` | (owner, D229; or — D314 — a Presenter grantee, who gets only the talks THEY presented, with their own `captionAllowance`) the talks a deck was presented in, newest first; each carries `presentedBy` (`{ email, name }` or `null` for the owner), `plannedMinutes` (the length the presenter planned in the console, minutes, or `null`) and — the owner's read only, D374 — `roomOpenedBy` (`{ email, name, at }`: the Presenter grantee or talk operator who last opened the room to the audience pass, or `null`) → `{ talks: TalkSummary[] }` — date, duration, joined count, caption count, spoken/caption languages, share status, recap status; a talk with caption time also carries `captions` (as on the single talk below), and the body carries the owner's `captionAllowance` |
| GET | `/api/decks/:id/talks/:talkId?lang=` | (the owner, or an admitted viewer the talk is shared with — D229) one talk's slide-keyed transcript in `lang` (the owner's and the presenter's read also carry `presentedBy` and `plannedMinutes`; an attendee's never does) (default: the language spoken; one of the languages the talk was captioned in — its spoken language plus the languages the presenter offered — only the spoken language when none were chosen (D351); also listed as `captionLanguages`) → talk meta + `segments` + `translated` (true when `lang` came from the cached machine translation, not the source) + `recap` (the AI-written recap body in `lang`, `null` until one has been written) + `recapLanguages` (every language the recap exists in). **For the OWNER only** it also carries `results` (D248) — what the room ANSWERED, one entry per ask and round: `{ askId, round, kind, slide, question, options?, order?, n, joined, agg, byLang, openedAt, closedAt, revealedAt }`, where `agg` is the aggregate for that kind (`{ counts, top }` · `{ histogram, mean, median }` · `{ bins, mean, median }` · `{ scores, firsts, top }`). The owner's copy is UNFLOORED — the three-answer floor is a room-facing rule, not a records rule — and still anonymous: no client hash, no participant id, nothing per person. Absent when the talk had no asks. The owner's copy also carries `captions` — `{ seconds, languages: [{ lang, seconds }], moreLanguages }`, the talk's caption time and reader seconds per language (top five; counts only), absent when nothing was captioned — and `captionAllowance` `{ unlimited, remainingSeconds, totalSeconds }` |
| GET | `/api/decks/:id/talks/:talkId/results?format=csv\|json` | (owner-only, D248) the same results as a download (`content-disposition: attachment`). `format=json` is the `results` block above; `format=csv` is one row per response with the header `talk_id,ask_id,round,kind,slide,asked_at,answered_at,lang,value,label` — multi/rank values joined with `\|`, `label` in the deck's default language, and any cell starting `= + - @` prefixed with `'` so a spreadsheet cannot execute it. Neither format carries the client hash or the participant id |
| POST | `/api/decks/:id/talks/:talkId/recap` | (owner-only, Pro, D229) write or regenerate the talk's recap: `{ languages?: string[] }` → `202 { jobId, languages }`; poll `GET /api/jobs/:jobId`. `403 { code: "needs_pro" }` on the free/promo lane; `429 { code: "quota", used, limit }` at the monthly `recaps_per_month` allowance (a regenerate counts against it); `409` if a recap is already being written or the talk has no transcript yet |

`POST` body: `{ email, ref?, canComment?, canFork?, canEdit?, canPresent?, hideNotes?,
presentUntil?, history?, notify? }` → `{ grant, grants, notified, notifyReason? }`.

- `email` — required, the recipient.
- `ref` — optional; omit for the default (follow `current`). Otherwise `{ kind: "version",
  value: "<a published version id>" }` to pin — or its number, `"v2"` / `"2"` (D361; stored as that
  version's original build id) — `{ kind: "edition", value: "current" }`
  to say the same thing explicitly, or `{ kind: "edition", value: "<name>" }` to bind the
  grant to a named edition (release channel — see below) so the recipient follows that
  channel instead of every publish. An unknown version id, or an edition name that doesn't
  exist yet, is a `400`, never a silent fall-forward to `current`; so is an unknown number.
  `cue_share grants[].pin` takes the same: a version id, or a number (`2` or `"v2"`).
- `canComment`, `history` — optional booleans. Default grant is view (+ optional comment). `history` = may browse the deck's published versions (D361, see above).
- `canFork` — optional boolean, **off by default**. `true` lets the recipient FORK the deck:
  copy the version they're served into a new deck they own (`POST /api/decks/:id/fork`).
  Hands over source — a bigger disclosure than viewing — so it's opt-in.
- `canEdit` — optional boolean, **off by default**. `true` lets the recipient CO-AUTHOR the
  deck: pull the version they're served (`GET /api/decks/:id/source`) and submit revised
  source back to your deck (`POST /api/decks/:id/submit`), which replaces its draft + builds
  a preview. You stay the owner and only you publish (which mints the version — credited to
  the co-author). Both `canFork` and `canEdit` require the recipient to be able to author on cue (any plan with authoring, including the free BYO lane a brand-new account gets — D216).
- `canPresent` (alias `present`) — optional boolean, **off by default** (D314). `true` makes the
  recipient a **Presenter**: they may start and run a live talk of the deck's published version
  (`POST /api/presentations`, `/present/:id`) on THEIR OWN plan and caption time, without the
  source. `canFork` and `canEdit` include presenting. Presenters read the published version's
  speaker notes unless `hideNotes: true`. `presentUntil` — ISO date or date-time, future, at most
  366 days out (`null` clears) — ends the present right without ending the view. A share pinned
  to an older version (or bound to an edition elsewhere) does not present. The talk stays yours;
  its record carries `presentedBy`. A presenter ends their own talk with `DELETE /api/presentations/:id`, reads their
  console's source (served slide titles and order, notes unless hidden, asks, thumbnails flag) from
  `GET /api/decks/:id/present-source?room=<talk>`, and may put screens on their own talk (scan or cast) — never on
  yours (D355). Each grant in the response carries `canPresent`, `hideNotes`
  and `presentUntil`; `cue_share` (and `POST /api/decks/:id/sharing` `grants[]`, which takes
  `present`/`hideNotes`/`presentUntil`) also report `rung` and `seesNotes`. A revoke (`DELETE`),
  or a write that leaves the share no longer presenting (rung lowered, `presentUntil` moved into
  the past), ends the talks that person started on the deck in the same transaction and revokes
  their presenter credentials; a `presentUntil` that simply passes takes effect at the next
  re-mint (about 2.5 minutes), when the sweep re-proves the grant.
- **Rights combine upward (D314 PR C).** These fields set the person's DIRECT share; omitted
  fields keep the direct share's value. Each grant row in a response is the person's EFFECTIVE
  right: the union of the direct share and every group share that reaches them (booleans OR;
  notes hidden only if every presenting reason hides them; `presentUntil` none if any presenting
  reason has none, else the latest; the ref is the direct share's, `current` for group-only).
  `GET` adds `reasons: [{ email, direct, groups: [{ groupId, name, rung, … }] }]` — what each
  reason grants — and `cue_share` / `POST /api/decks/:id/sharing` report `directRung` and
  `via: [{ groupId, group, rung }]` per grant. A group share is set through the sharing
  endpoint's `shareGroups` entries: a group id/name (Viewer), or `{ group, present?, fork?,
  hideNotes?, presentUntil? }` (Presenter / Can fork; never co-editing). `DELETE` withdraws only
  the direct share: a Presenter group keeps the person a Presenter. `presents` / `seesNotes` are evaluated live: a direct pin to an older version does not present
  (even under a Presenter group), and the notes switch follows whichever reasons present right now.
- **Team groups (D314 PR D).** A deck owner who is a JOINED member of a team may name that team's
  groups (its built-in "Everyone" included) in `shareGroups` / `revokeGroups` / `cue_share`
  `groups` **by id only** (`grp_…`; names resolve the owner's personal groups). Anyone else gets
  the same 404 as an unknown group. Team group shares in responses carry `teamName` (and
  `everyone`), `via` entries carry `team`, and `reasons[].groups[]` carry `teamName`. A deck's
  team-group shares are revoked when its owner leaves or is removed from the team. Teams
  themselves are managed only in the app (`/api/teams/**` is session-only, no bearer or MCP path).
  Roles: the owner (one, fixed; archives the team, cannot leave), admins (invite, change roles,
  remove, maintain groups — including demoting or removing OTHER admins, never the owner) and
  members. An invite is the team's, not the inviting admin's: it stays valid if that admin is
  later demoted or removed, until it is accepted, declined, withdrawn by an admin or expires
  (14 days). An invite grants nothing until the invited address accepts.
- `notify` — optional boolean, **off by default**. `true` emails the grantee a share
  notification (deck title, cover thumbnail, sender identity, a link to `/view/:id` that
  carries no secret — the recipient signs in and their grant admits them). The response's
  `notified` boolean says whether the send actually went out; on `false` a `notifyReason`
  explains why (`"throttled"` — per-sender 30/hr or per-recipient 5/day exceeded,
  `"send-failed"`, or `"no-transport"` — mail isn't configured). A throttled or failed send
  never fails the grant itself, so `grant`/`grants` in the response are unaffected either way.

Owner-only, same auth as every other deck route (bearer token or session).

**Identified readers — the door (spec 23, Pro).** `POST /api/decks/:id/sharing` (and `cue_share`)
take `door: "invite" | "signin" | "email"` and `doorNotify: boolean`. `door: "signin"` or `"email"` needs the gated tier
(this request's `access` or the deck's — 400 otherwise) and the `door` capability (403
`{ code: "needs_pro", capability: "door" }`); `"invite"` is always allowed and keeps every reader
who already came through. With the door open, anyone with the bare `/view/:id` URL sees the
deck's title, cover and author, signs in with their email, and gets a VIEW-ONLY grant (reason
`door`): the deck is on their shelf (`GET /api/shelf`) and the readers summary names them with
`group: "door"`. With `door: "email"` the reader only types an address (no code, never verified)
and gets a personal 30-day recipient link — never a grant, never a shelf entry; the readers summary
lists them with `group: "email"` and `verified: false`. Door readers are not in `grants`, `invitees`
or `GET /grants`, and email-door links are not in `recipients`; the sharing response reports
`door`, `doorNotify` and `doorReaders` (their count, both kinds). With `doorNotify` on, the owner
gets one muteable mail per deck at most every 15 minutes naming the new readers who opened it. Changing the door bumps the
deck's privacy generation like a tier change. `removeDoorReaders: true` withdraws every door entry
at once (people also named directly or through a group keep that access; the door stays as it is)
and revokes every live email-door link, and bumps the privacy generation; the response adds
`doorReadersRemoved` / `doorReadersKept` / `doorRecipientsRemoved`.
`DELETE /api/decks/:id/grants?email=…` and `revokeGrants` remove a person however they got in —
their direct share and their door entry (the DELETE answer carries `doorRemoved: true` when it took
one); only a group that still names them keeps them. Each `identities[]` row of
`GET /api/decks/:id/readers` carries `group` (`invited | door | email`) and `verified`. The
reader-side routes (`POST /api/decks/:id/door` — the gate's Continue, or `{ email }` at an email
door — and its sign-in return) are browser routes, not agent endpoints. An author's photo appears on
their door gates and `/by/<handle>` only when they opt in on `/account`
(`GET /api/avatars/<token>`); otherwise the gate shows their initial. `GET /api/decks/:id/viewer` answers a denied
reader of a door deck `403 { error: "forbidden", reason: "door" }`.

**Reading terms (spec 23 PR C, Pro).** The same sharing call (and `cue_share`) takes `terms`: plain
text up to 2,000 characters (trimmed; 400 longer), or `null` / `""` to clear. Setting text needs the
gated tier (this request's `access` or the deck's — 400 otherwise) and the `door` capability (403
`{ code: "needs_pro", capability: "door" }`); clearing is always allowed. Any change bumps the
deck's terms revision and its privacy generation, so outstanding artifact grants die and an open
reader is re-asked at the next re-mint; off the gated tier the stored text is inert. The response
reports `terms` and `termsRev`. While terms bind, every identified non-owner reader (a grantee,
a tracked link, a door reader, a Call judge) who has not accepted the current revision is refused
by the read policy on every surface: the page shows the terms gate, `GET /pdf` / `GET /pptx`
answer `403 { error: "terms-required" }`, the artifact and media re-mints a bare 403, and
`GET /api/decks/:id/viewer` `403 { error: "forbidden", reason: "terms-required" }` (the apps open
the web page). Acceptance is a browser step (`POST /api/decks/:id/door/terms`, or the door entry
itself) recorded for the admitted identity — the session's address, or the tracked link's own
credential, never a typed address. The readers summary carries `termsRev` and, per identity,
`termsAccepted: { rev, acceptedAt, current, verified } | null` (`verified: false` when accepted
through an unverified email-door link). Delegates are bound too: a grant presenter, operator,
co-editor or forker gets `403 { reason: "terms-required" }` from the presenter, source, fork and
screen-link routes until they accept. A reader shown the terms may report them
(`POST /api/decks/:id/report` with `reason: "terms"`) before accepting. The terms text is never
rendered as HTML.

```sh
# share with one person, pinned to a specific version
curl -s -X POST -H "authorization: Bearer $TOKEN" -H "content-type: application/json" \
  -d '{"email": "reviewer@acme.com", "ref": {"kind": "version", "value": "<versionId>"}}' \
  https://cue.humanmeetsai.com/api/decks/<id>/grants

# revoke it later
curl -s -X DELETE -H "authorization: Bearer $TOKEN" \
  "https://cue.humanmeetsai.com/api/decks/<id>/grants?email=reviewer@acme.com"
```

### Asks: the room routes are NOT agent endpoints (D248)

A deck can put questions to the room it is presented to — manifest `asks`, `useRoom()` in
the slides (see the skill's *Asking the room*). Three routes carry that loop, and none of
them is part of this integration: they authenticate with a **room token**, the short-lived
per-presentation credential a phone gets by scanning the join QR, and they refuse a bearer
token. An agent never calls them. They are listed here so the surface is complete and so
nobody builds a client against the wrong door — the agent-facing half of asks is authoring
the deck (above) and reading `results` off the talk afterwards (the two `talks` rows above).

| Verb | Path | Credential | Body → answer |
|---|---|---|---|
| POST | `/api/presentations/:id/respond` | VIEWER room token | `{ token, askId, value, client, slide?, lang? }` → `201`/`200 { ok, askId, round, value }`. `client` is a talk-scoped random id (`/^[A-Za-z0-9_-]{16,64}$/`) the device mints once per presentation and keeps — it is what makes "one answer per person" true without an account. `value` is an option key (`choice`), 1..`max` distinct keys (`multi`), an integer in range (`scale`), a number snapped to `step` and ECHOED back as stored (`number`), or a full permutation of the option keys (`rank`). Answers stay editable until the ask closes: re-POST with the same `client`. Refusals: `409 { code: "closed" }`, `404 unknown ask`, `400` bad value, `429 { code: "rate" }` + `retry-after` (min 2 s per client per ask, and a per-IP lane above it), `429 { code: "cap" }`, `403`, `410` (talk over) |
| POST | `/api/presentations/:id/asks` | PRESENTER room token (the clicker is not required) | `{ token, askId, action: "open" \| "close" \| "reveal" \| "reopen" \| "discard", slide? }` → `200 { ok, changed, relayed, ask }`. `open` starts round 1 (already open → `changed: false`); `close` stops answers without publishing; `reveal` closes AND publishes to the room; `reopen` (closed only) starts round n+1 and keeps the earlier one; `discard` deletes the current round — the recovery from a botched or stuffed one. `relayed: false` means the write landed but the room did not hear it: offer the action again. `409 { code: "rehearsal" \| "idle" \| "open" \| "closed" \| "rounds" }` names the state that refused. The ask ids are the talk's PUBLISHED version's (D355), not the draft's |
| POST | `/api/presentations/:id/asks/state` | any live room token of that room | `{ token, client? }` → presenter scope: `{ asks: { [askId]: AskFrame } }`, and a re-relay to the room (how a restarted room server heals); viewer: `{ mine: { [askId]: { round, value } } }` for the current round, so a phone that reconnects knows what it already answered; an output surface: `{}` |

What the room itself receives rides the existing presentation SSE stream: the `state` frame
gains `asks`, and a new `ask` event carries one `AskFrame`
(`{ askId, round, kind, status, revealed, n, floor, rev, slide?, agg?, rounds? }`) or the
tombstone `{ askId, removed: true }`. A presenter-scope client always gets `agg`; everyone
else gets it only once the ask is `revealed` **and** `n >= floor` — where `floor` is the
number the AUTHOR declared on the ask (D249), an integer 0–20 whose default is **0**, so by
default a revealed round is a visible one. `n`, `floor`, `status` and `revealed` always
travel to every scope, and a missing `agg` means "not yet" — never compute one.

### The room pass: presenter surfaces, NOT agent endpoints (D373)

A live room has a door (`open` | `invitees`) and an audience pass that lets a phone follow the talk whatever the
deck's tier, while it runs. The routes below serve the presenter's own console, stage, screens and apps; an agent
does not start or run talks, so there is no MCP tool for them. `POST /api/presentations` takes an optional
`door: "open" | "invitees"` (absent: Open on a public or link deck, Invitees only on a gated one) and answers `door`
and `audienceLink`.

| Verb | Path | Credential | Body → answer |
|---|---|---|---|
| GET | `/api/presentations/:id/audience-link` | the presenter seat's session (owner, operator, grant presenter of their own talk), or a delegated output's room token in `x-cue-room-token` | → `200 { url, door, epoch, passUnavailable? }`; `url` is `/live/<deck>?room=<id>&a=<pass>` while Open, without `a` when Invitees only (or when `passUnavailable`: no pass key on this deployment), never a `k`; `404` for everyone else and for an ended room |
| POST | `/api/rooms/token` (room pass) | none, or a session the deck's tier refuses | viewer role plus `a` (the pass) for a fresh join, or `roomToken` (the phone's own live pass-seat token) + `continuationNonce` (a fresh 16–128 char base64url string per attempt; resend the SAME one when retrying that attempt) to keep the seat across a rotate → the usual credential plus `admittedBy: "pass"`. A seat continues once; a retry with the same nonce within 5 s gets the same seat back, any other request gets the tier's refusal. `429 { code: "room_full" }` at the room's cap, `429` past the per-room rate |
| POST | `/api/presentations/:id/audience-link` | the presenter seat's session | `{ door?, rotate?: true, eject?: true }` → `200 { url, door, epoch, ejected }`. `rotate` stops new joins, seated phones stay; `eject` removes every pass seat and rotates; `door: "invitees"` removes every pass seat and erases the pass (reopening mints a new one). `409 { code: "not_openable" }` on a rehearsal, held deck or document; `503` without a configured pass key |

### Proposals: the PR loop

Fork + the validation gate = merge protection. If you own a **fork** (created with
`POST /api/decks/:id/fork`), you can propose its changes back to the deck you forked from;
the upstream **owner** accepts, declines, or you withdraw.

| Verb | Path | Who | Purpose |
|---|---|---|---|
| POST | `/api/decks/:id/propose` | fork owner | `id` = **your fork**. Target is derived from the fork's provenance (unspoofable — you can only propose to a deck you forked). Optional body `{ fromVersionId }` (a published version of your fork; default current) → `{ proposalId, status, staleBase }` |
| GET | `/api/decks/:id/proposals` | target owner | list open proposals (`?all` for resolved history) → `{ proposals: [{ proposalId, fromDeckId, fromVersionId, baseVersionId, proposerEmail, staleBase, createdAt, status }] }` |
| POST | `/api/decks/:id/proposals/:pid/accept` | target owner | body `{ fromVersionId }` = **the version you reviewed** (from the list above); the accept is pinned to it. Runs the proposed source through YOUR gate → your deck's next **draft** (credited to the proposer); `202 { jobId, staleBase }`. If the proposer re-proposed a newer version since you listed → `409` "changed since you reviewed it" (re-list and review) |
| POST | `/api/decks/:id/proposals/:pid/decline` | target owner | optional `{ reason }`; source untouched → `{ status: "declined" }` |
| POST | `/api/decks/:id/proposals/:pid/withdraw` | proposer | withdraw your own open proposal → `{ status: "withdrawn" }` |

- **`staleBase`** is `true` when the upstream has published past the version the fork
  branched from. Accepting is **verbatim** — the whole fork source replaces the owner's
  current draft; there is no auto-merge/rebase. A stale base is a signal to review carefully;
  rebasing is a manual re-pull-and-edit of the fork.
- **Accept lands a draft, not a version.** The owner reviews, then `POST /api/decks/:id/publish`
  mints the version — whose author (`createdBy` in the version history) is the proposer, via
  the same draft-attribution chain a co-author submit uses. Accepting REPLACES the owner's
  current draft.
- **Accept is pinned to the version you reviewed.** Pass `{ fromVersionId }` from the proposal
  you listed. A re-propose swaps the fork version on the *same* proposal id, so the pin makes
  "accept what you saw" true: a revive since your last list yields `409` rather than silently
  accepting newer bytes. Omitting `fromVersionId` is a `400`.
- **Authorization**: only the target owner accepts/declines; only the proposer withdraws.
  There is **one open proposal per fork** — re-proposing revives the open one rather than
  stacking a second. Publish your fork before proposing so it has the version you want to send.

```sh
# (as the fork owner) propose your fork's changes back upstream
curl -s -X POST -H "authorization: Bearer $TOKEN" \
  https://cue.humanmeetsai.com/api/decks/<forkId>/propose

# (as the upstream owner) see incoming proposals, then accept one — pin to the fromVersionId
# the list returned (accept what you reviewed)
curl -s -H "authorization: Bearer $TOKEN" \
  https://cue.humanmeetsai.com/api/decks/<id>/proposals
curl -s -X POST -H "authorization: Bearer $TOKEN" -H "content-type: application/json" \
  -d '{"fromVersionId":"<fromVersionId from the list>"}' \
  https://cue.humanmeetsai.com/api/decks/<id>/proposals/<pid>/accept
# → watch the jobId, then publish to mint the version (credited to the proposer)
```

### The timeline: history, diff, restore, set live

Every deck keeps an **append-only** log of everything that happened to its source: each
publish (a milestone readers saw) and each accepted draft revision — a submit, a studio
quick-edit, a co-editor's edit, an accepted proposal, a restore — with the author, the source
digest, and the chat prompt that produced it. Going back is an *event* on that log; nothing
is ever rewritten or deleted, so "who changed this, and what did it say before?" always has
an answer.

The four verbs, and what each one moves:

| Verb | Moves | Reader-visible? |
|---|---|---|
| `GET /diff` | nothing (a read) | no |
| `GET /source?rev=` | nothing (a read) | no |
| `POST /restore` | the DRAFT | no |
| `POST /rollback` (set live) | the published artifact (and, with `syncDraft`, the draft) | **yes, immediately** |

- **Refs** are one vocabulary across `/diff`, `/source?rev=` and `/restore`: `draft`, `live`,
  a version id on this deck, or a 64-hex revision digest **this deck's own timeline knows**.
  A digest off another deck is a `404`, not a peek — these endpoints are not a probe for
  stray snapshots.
- **A submit REPLACES the whole source.** `GET /diff` (default `live` → `draft`) is the
  cheap way to see what is unpublished before you overwrite it — especially on a deck a
  human or another agent has been editing. The diff renders `overrides.json` semantically:
  content cells per key **and language**, nav titles, notes, slide order, theme tokens — so a
  change made in one language and not another is visible rather than buried in a re-
  serialized blob.
- **Restore goes through the gate.** `POST /restore` stages the recovered source as a push
  job (the same lane a submit uses), so it answers `202 { jobId }` — poll `/api/jobs/:id` —
  and the promote appends a new entry with `via: "restore"`. `{ discard: true }` is the
  common case: put the draft back to exactly what is published. Adding `files: ["slides.tsx"]`
  makes it SELECTIVE — only those files go back and every other draft change stays (a file the
  target does not have is deleted from the draft); a partial revert records no `restored_from`,
  since its bytes are a mix rather than a copy of one revision. `restoreDeletedContentKeys:
  true` alongside `files` also splices back the `content.ts` keys that point has and the draft
  lost — the copy a deleted slide took with it, without which the restored slide renders
  `⟦points.title⟧` — and lists them in `contentKeysRestored`; every other byte of `content.ts`
  is untouched.
- **Retention is honest.** Index rows outlive their bytes: an entry whose snapshot aged out
  of retention still appears in `/history` with `restorable: false`, and restoring it answers
  `404` rather than pretending. `GC_KEEP_REVISIONS` (default 50) plus every published
  version's digest and the current draft pointer are always kept.

```sh
# what is unpublished right now, as readable text
curl -s -H "authorization: Bearer $TOKEN" \
  "https://cue.humanmeetsai.com/api/decks/<id>/diff?text=1" | jq -r .text

# the log, and the source behind one entry
curl -s -H "authorization: Bearer $TOKEN" \
  "https://cue.humanmeetsai.com/api/decks/<id>/history?text=1" | jq -r .text
curl -s -H "authorization: Bearer $TOKEN" \
  "https://cue.humanmeetsai.com/api/decks/<id>/source?rev=<digest>" | jq -r '.files|keys'

# throw away the unpublished changes, then watch the job
curl -s -X POST -H "authorization: Bearer $TOKEN" -H "content-type: application/json" \
  -d '{"discard":true}' https://cue.humanmeetsai.com/api/decks/<id>/restore
```

MCP/CLI equivalents: `cue_history`, `cue_diff`, `cue_restore`, `cue_set_live`, and
`cue_pull { rev }` — CLI `history` / `diff` / `restore --discard` / `set-live` /
`pull --rev` (§3).

### Named editions: per-audience release channels

An **edition** is a named pointer to a published version (a slug like `"board"` or
`"investors"`) that moves ONLY on an explicit **promote** — never on a plain publish, which
only moves the implicit `current` edition every deck has. Grants can bind to an edition
(`ref: { kind: "edition", value: "<name>" }`, above) instead of following `current` or being
pinned to one version forever — promoting the edition moves what that audience sees, on your
schedule, independent of both ongoing publishes and any version-pinned grants. Use it to ship
a new cut to one audience deliberately (a board deck, an investor update, a public-facing
build a version behind an internal one) rather than either "always latest" or "frozen".

| Verb | Path | Purpose |
|---|---|---|
| GET | `/api/decks/:id/editions` | list this deck's editions → `{ editions: [{ name, versionId, promotedAt }] }` |
| POST | `/api/decks/:id/editions` | promote a channel (body `{ name, versionId, notify? }`) → `{ edition, editions, notified? }` |
| DELETE | `/api/decks/:id/editions?name=<n>` | delete a channel |

`POST` body: `{ name, versionId, notify? }`.

- `name` — required, a slug (lowercase letters, digits, hyphens, starting alphanumeric).
  `"current"` is reserved — `400` if you pass it, since that edition is implicit and moves
  via publish, not promote. A non-slug name is also a `400`.
- `versionId` — required, a published version id belonging to this deck (from the deck
  record's `versions`). A `versionId` that isn't one of this deck's published versions is a
  `400` — an edition may only ever point at something the deck actually published.
- `notify` — optional boolean, **off by default**. `true` emails every grant currently bound
  to THIS edition a share notification (deck title, cover thumbnail, sender identity, a
  no-secret `/view/:id` link) — best-effort, same throttling and failure semantics as the
  grants `notify`. The response's `notified` array reports `{ email, notified, reason? }`
  per grantee when `notify: true` was passed.

`DELETE ?name=<n>` removes a channel; `400` on `"current"` (not deletable). Grants bound to a
deleted edition then fail closed — their `/view` reports the version as unavailable — until
retargeted to a different ref.

Owner-only, same auth as every other deck route (bearer token or session).

```sh
# promote the "board" edition to a specific published version, notifying its grantees
curl -s -X POST -H "authorization: Bearer $TOKEN" -H "content-type: application/json" \
  -d '{"name": "board", "versionId": "<versionId>", "notify": true}' \
  https://cue.humanmeetsai.com/api/decks/<id>/editions

# bind a grant to that edition (see Named shares above)
curl -s -X POST -H "authorization: Bearer $TOKEN" -H "content-type: application/json" \
  -d '{"email": "director@acme.com", "ref": {"kind": "edition", "value": "board"}}' \
  https://cue.humanmeetsai.com/api/decks/<id>/grants

# delete the channel later
curl -s -X DELETE -H "authorization: Bearer $TOKEN" \
  "https://cue.humanmeetsai.com/api/decks/<id>/editions?name=board"
```

### Exports: PDF & PowerPoint

A published deck downloads as a file, access-checked exactly like the viewer above.

| Verb | Path | Purpose |
|---|---|---|
| GET | `/api/decks/:id/pdf` | print-ready PDF, one page per slide; `?lang=<code>` selects a language; slides the published version hides are left out (renderer 1.4.0 and later), `?includeHidden=1` gives the owner or a co-author every slide and is ignored for anyone else; `?download=1` serves it as an attachment named `<title>.<lang>.pdf` (without it the PDF opens inline) |
| GET | `/api/decks/:id/pptx` | exact-look PowerPoint (enabled per deck owner); `?lang=<code>` selects a language; hidden slides, `?includeHidden=1` and `?download=1` as for the PDF |

Both take an optional `?lang=<code>` — the deck's default language is the bare path, other
declared languages carry `?lang=` (an unknown language 404s) — and, for a non-public deck,
the same `?k=<token>` share credential the viewer needs. The first request for a fresh
version may render on demand (a cold render can take ~1–2 min, longer for a very large deck):
a PDF or PPTX that is still being prepared answers `202 {"status":"preparing","lang":…,"pollAfterMs":…}`
(or `503` while a fresh publish's render is still baking) — poll after `pollAfterMs` until the
route 302s to the artifact CDN, which serves every later download instantly.

Each language renders on its own first request (D261 for PDFs, D265 for the PPTX). The PPTX is
a **faithful rendered snapshot** — one full-bleed image per slide (JPEG, 2560 px wide) plus the
speaker notes, NOT editable text or shapes — and, like secret links, is **enabled per deck owner** (an operator
can also pause it for everyone): where the export isn't enabled the `/pptx` route 404s. Documents have no PPTX
export.

## Review & feedback

Reviewers leave per-slide or whole-deck notes on a published deck — via a review link,
not an account. Owners mint the link, read the notes back, and resolve them once
addressed. Since D256 the OWNER also leaves notes — change requests for their own agent,
written in the studio's "Notes for your agent" panel and anchored to a slide and, often, a
picked content key. Every note carries `kind: "review" | "owner"`, `slideIndex` (0-based, null
= whole deck) and `elementKey` (null unless the owner picked an element); both kinds are in
the unresolved list and both are closed the same way. Every note also carries `lang` — the deck
language its author was looking at (null on older notes and replies) — and `versionId`, the
published version a reviewer's note was written against (null for owner notes, which are
written on the draft); the owner listing adds `latestVersionId` and a per-note `stale` (its
version is no longer the latest, so its `slideIndex` may have drifted) (D327).

| Verb | Path | Purpose |
|---|---|---|
| POST | `/api/decks/:id/reviews` | mint (or reuse the newest open) review link → `{ review, reviewUrl }` |
| GET | `/api/decks/:id/reviews` | list this deck's reviews |
| PATCH | `/api/decks/:id/reviews` | close a review (body `{ reviewId?, status: "closed" }`, defaults to the newest open one) — the token dies |
| GET | `/api/decks/:id/notes` | list notes; owner sees all (`?resolved=false` for unresolved only), a reviewer's `?k=` sees only their own review's notes |
| POST | `/api/decks/:id/notes` | a reviewer posts a note (body `{ k, slideIndex, reaction?, body, authorName, lang?, versionId? }` — an undeclared `lang` or a foreign `versionId` is stored as null); an owner session may reply one level deep to a reviewer's note (`{ replyToId, body }`); the owner (session or author-scoped bearer) leaves a note for their agent (`{ kind: "owner", body, slideIndex: n\|null, elementKey?, lang? }`) |
| PATCH | `/api/notes/:id` | resolve/unresolve a note (body `{ resolved: true|false }`) → `{ note }` |
| DELETE | `/api/notes/:id` | the owner deletes one of their OWN notes (`kind: "owner"`); a reviewer's note → `403` (resolve it instead) |

Reviewers authorize with the review token (`?k=` on GET, `body.k` on POST) — no account
needed. Owners authorize the same way as everywhere else: bearer token or session.

curl sketches:

```sh
# mint (or reuse) a review link
curl -s -X POST -H "authorization: Bearer $CUE_TOKEN" -H "content-type: application/json" \
  -d '{}' $CUE_URL/api/decks/<id>/reviews
# → {"review": {...}, "reviewUrl": "https://.../review/<id>?k=<token>"}

# owner: list unresolved notes
curl -s -H "authorization: Bearer $CUE_TOKEN" \
  "$CUE_URL/api/decks/<id>/notes?resolved=false"

# owner: resolve a note once it's addressed
curl -s -X PATCH -H "authorization: Bearer $CUE_TOKEN" -H "content-type: application/json" \
  -d '{"resolved": true}' $CUE_URL/api/notes/<noteId>
```

**MCP/CLI tools:**

- `cue_feedback` — `{ deckId, all? }`. Lists notes of both kinds (unresolved only by
  default; `all: true` for the full history), each with `kind`, `elementKey`, `lang`,
  `versionId` and `stale`, plus the deck's `latestVersionId`. Feedback on wording, translation
  or overflow belongs to the note's `lang` only; on substance, structure or design, to every
  language. CLI:
  `node cue-mcp.mjs feedback <deckId> [--all]`.
- `cue_resolve_note` — `{ noteId }`. Marks a note resolved. CLI:
  `node cue-mcp.mjs resolve-note <noteId>`.

**The loop:**

1. `cue_feedback` — pull unresolved notes for the deck. Do this at the start of EVERY edit:
   the owner's notes are change requests even when the chat doesn't repeat them.
2. Revise the deck source locally to address them.
3. `cue_submit` the updated source, then `cue_publish`.
4. `cue_resolve_note` each note you fixed, so the owner's inbox and `cue_feedback`'s
   default list stay honest.

## 3. One file, two modes: MCP server and CLI

A zero-dependency file is served from the app itself (node >= 18, no install):

```sh
curl -O https://cue.humanmeetsai.com/cue-mcp.mjs
```

**MCP mode** (no args — Claude Code, Cursor, any MCP client):

```sh
claude mcp add cue --env CUE_TOKEN=cue_... -- node "$PWD/cue-mcp.mjs"
```

For clients configured by a JSON file (`mcpServers` → `command`/`args`/`env`) the `args`
path must be ABSOLUTE — `/Users/<you>/.cue/cue-mcp.mjs`, `C:\\Users\\<you>\\.cue\\cue-mcp.mjs` —
because the client spawns the command without a shell: `~` is never expanded, node exits
with `MODULE_NOT_FOUND`, and the client reports only `MCP error -32000: Connection closed`.
The same error means `node` is not on the client app's PATH (GUI apps do not see nvm/fnm
installs) — put the full path from `which node` / `where node` in `command`. `/connect`
generates the right shape per OS.

Tools: `cue_list_decks`, `cue_shelf` (decks shared WITH you — `{canEdit: true}` narrows to
the ones you may co-author; the discovery door for a co-editor, since `cue_list_decks` lists
only decks you own), `cue_pull` (writes source into a local dir), `cue_submit`
(reads the dir, creates or replaces a deck), `cue_job` (status; `wait: true` polls to
terminal), `cue_publish`, `cue_share` (access tier, invitees, `groups`/`revokeGroups` — standing
audiences by id or exact name, additive, gated/link decks only (D136) — named grants with optional
version pins or named-edition bindings, named editions via `promote`, tracked links, and
`addShareLink`/`revokeShareLink`/`rotateShareLink` for per-channel `?k=` links), and the
timeline four: `cue_history`, `cue_diff` (look before you overwrite), `cue_restore` (draft
back to a digest/version, or `discard: true` back to live) and `cue_set_live` — `cue_pull`
takes the same refs via `rev`.
The account font library: `cue_upload_font {path, attest: true}`, `cue_list_fonts`,
`cue_delete_font {fontId}` (see *Fonts* above). Room operators of a talk:
`cue_talk_operators {talkId, add?, remove?}` (see *Room operators* above). Your private notes on a
deck: `cue_my_notes {deckId, action, versionId?, slideIndex?, ref?, body?, all?}` (see *My notes* above).
Calls (D362): `cue_call_create`, `cue_call_entries`, `cue_call_enter`, `cue_call_withdraw`, and
(D370) `cue_call_decide` (see *Calls* above). Programmes (D370): `cue_programme_create`, `cue_programme_slots`,
`cue_programme_bind`, `cue_programme_approve_version`, `cue_programme_import` (see *Programmes* above).
`cue_pin {deckId, pinned}` floats a deck to the top of your library — the web home and the cue
phone app both show pinned decks first, so an agent can leave tomorrow's talk at the top of the
list it built it for. The pin is per PERSON (it never moves the deck for anyone it is shared
with) and changes nothing about the deck itself; `cue_list_decks` (ordered pinned first, then
most recently updated) and `cue_shelf` both report `pinned`.
On a brand-new account — one that owns no deck yet — `cue_list_decks` and `cue_shelf` also
carry an `onboarding` string telling the agent what to say and do first; the key is absent
once the account has a deck (§3c).
Point it at another instance with `--env CUE_URL=...`.

**It keeps itself current — from signed releases only (D334).** In MCP mode the shim checks
`<CUE_URL>/cue-mcp.mjs` at start, at most once a day (state in `~/.cue/cue-mcp-update.json`,
a 1.5 s budget, never a failed start). It installs a newer copy ONLY when
`<CUE_URL>/cue-mcp.mjs.sig` is a valid ed25519 signature by a key embedded in the copy you are
running — the server alone cannot push code to your machine — and only after `node --check` and
the candidate's own `--self-test` pass, and only when its version is strictly newer. The old file
is kept as `cue-mcp.mjs.bak`; a new version that exits with an error within 5 s of start is rolled
back and the server exits (your MCP client restarts it on the old version). The agent sees one line
with the first tool result ("cue MCP shim updated <old> → <new>", or why an update was refused). If
the file's directory is not writable you are told to fix the permissions and run
`node cue-mcp.mjs update`, which does the same verified update on demand; CLI commands only print a
stderr notice. A copy inside a git checkout never updates automatically. Opt out with
`--env CUE_MCP_AUTO_UPDATE=0`. API calls carry `X-Cue-Shim: <sha256 of the file>`; a shim too old
to update itself sees a `shimNotice` field in `cue_list_decks` / `cue_templates` naming the
command to re-download it once.

**CLI mode** (any args — humans, scripts, and shell-only agents; same behavior,
JSON on stdout, errors on stderr with exit 1):

```sh
export CUE_TOKEN=cue_...
node cue-mcp.mjs decks
node cue-mcp.mjs shelf --can-edit           # decks shared with you that you may co-edit
node cue-mcp.mjs pin <deckId>               # top of the library; --off unpins
node cue-mcp.mjs pull <deckId>              # dir defaults to the deck's slug
node cue-mcp.mjs diff <deckId>              # what is unpublished (live → draft), as text
node cue-mcp.mjs history <deckId>           # the timeline: publishes + revisions, newest first
node cue-mcp.mjs pull <deckId> old --rev <digest>   # a past point, into ./old
# ...edit locally...
node cue-mcp.mjs submit <dir> --deck <id> --message "reworked slide 2"
node cue-mcp.mjs job <jobId> --wait         # result.previewUrl on success
node cue-mcp.mjs publish <deckId>
node cue-mcp.mjs restore <deckId> --discard # drop unpublished changes (draft ← live), as a job
node cue-mcp.mjs set-live <deckId> <versionId>     # re-point what READERS see
node cue-mcp.mjs help
```

Typical agent flow either way: pull → edit files locally (your model, your tokens) →
submit with a one-line message (it becomes a turn in the deck's session transcript,
so the studio history stays honest) → wait on the job → `previewUrl` → publish when
happy.

## 3b. The cue skill (optional, recommended)

A skill teaches the agent the workflow — pull-before-submit, gate semantics, deck
source conventions, the craft — so you don't have to. A connector carries tools, never
a skill, so it is installed separately, in whichever shape the host takes. Both shapes
are the same bytes, versioned by the `version` frontmatter; the MCP server's
instructions tell the agent to compare its installed copy with the served one.

**claude.ai / Claude Desktop / WorkBuddy** — the skill goes in through the app's own
import, which takes a zip of the skill folder:

1. download https://cue.humanmeetsai.com/cue-skill.zip — one folder, `cue-decks/SKILL.md`,
   carrying the REMOTE-lane variant (the same bytes as `/cue-skill-remote.md`: the shim
   half is stripped, since a host that imports a zip talks to `POST /mcp`)
2. claude.ai / Claude Desktop: Customize → Skills → Add → Upload skill, choose the file.
   WorkBuddy: sidebar Experts · Skills · Connectors → Skills → Add Skill → Import Skill,
   drop the file in.

Both steps are on https://cue.humanmeetsai.com/connect under the claude.ai, Claude
Desktop and WorkBuddy tabs.

**Claude Code** (or any host with a skills directory) — the markdown, on disk:

```sh
mkdir -p ~/.claude/skills/cue-decks
curl -o ~/.claude/skills/cue-decks/SKILL.md https://cue.humanmeetsai.com/cue-skill.md
```

It prefers the cue MCP tools when configured and falls back to the CLI otherwise.

**Codex CLI / Codex app** — no zip import exists; Codex reads user skills from
`~/.agents/skills/<name>/SKILL.md` (not `~/.codex/skills`), and the folder name must equal
the skill's frontmatter `name`. Remote lane, since a Codex session talks to `POST /mcp`:

```sh
mkdir -p ~/.agents/skills/cue-decks
curl -fsSL https://cue.humanmeetsai.com/cue-skill-remote.md -o ~/.agents/skills/cue-decks/SKILL.md
```

Invoke it as `$cue-decks` (or `/skills`); the app lists it under Skills in the sidebar.

## 3c. Remote MCP (claude.ai / ChatGPT — no install)

`POST https://cue.humanmeetsai.com/mcp` is a stateless JSON-RPC 2.0 MCP endpoint,
bearer-only (no session-cookie fallback — a bearer header is never an ambient
credential, so this endpoint carries no cookie-CSRF surface). It serves current
2026-07-28 clients through self-contained per-request envelopes and `server/discover`,
and retains stateless `initialize` compatibility for 2025-era clients; neither lane
creates a session ID. Paste that URL into claude.ai
(Settings → Connectors → Add custom connector) or ChatGPT (Settings → Connectors →
Advanced → Developer mode → Add connector); the client discovers the authorization
server from the endpoint's protected-resource metadata and walks you through consent —
nothing to mint or paste by hand. Then add the skill (§3b — the zip upload lane for
claude.ai). Watch the setup: claude.ai —
https://cue.humanmeetsai.com/connect?agent=claude-ai&play=1 (1:10, silent); ChatGPT —
https://cue.humanmeetsai.com/connect?agent=chatgpt&play=1 (1:56, silent).

**OAuth 2.1**, with cue as both authorization server and resource server: PKCE S256
(public clients only — no client secret exists to leak), dynamic client registration
(RFC 7591) plus client-ID metadata documents for clients that use those instead, a
1-hour access token, and a 90-day refresh token that ROTATES on every use (presenting an
already-used refresh token revokes its whole family — the standard defense against a
stolen refresh token being replayed alongside the legitimate client). The access token
IS an ordinary `cue_` token under the hood — the same row a hand-minted API token is,
just carrying an expiry, scopes, and the OAuth client that owns it.

**Three scopes**, granted at consent:

| scope | allows |
|---|---|
| `read` | list/read decks, jobs, feedback notes, reader activity |
| `author` | create decks, edit draft content (draft workspace + asset uploads) |
| `publish` | publish, unpublish, delete, change sharing — can make decks public |

**Authoring needs an invite during the alpha.** If your account isn't an invited
author, consent still succeeds but silently downgrades to `read` only — you connect and
can browse, not create or edit. Ask for an author invite to unlock `author`/`publish`.

**Access tokens expire hourly and refresh themselves** — a connector holding the
refresh token renews automatically; you never see this happen.

**Revoke from `/connect`** kills the WHOLE connection: the refresh token family and
every access token it ever minted, not just whichever row happens to be listed. There
is no partial revoke.

The draft workspace this lane edits through (`cue_list_files` / `cue_grep` /
`cue_read_files` / `cue_edit_file` / `cue_write_files` / `cue_delete_files` /
`cue_submit`) is server-held, per DECK — it is
NOT the same working copy as a local `cue_pull`'d directory, but it IS the same working
copy shared by another remote session editing the same deck. `cue_write_files` and
`cue_delete_files` take a `baseRev` (optimistic concurrency: a stale rev is rejected
with the current rev and which files changed, so you re-read only what moved);
`stale: true` on a read means the deck's LIVE source moved on since this draft was
seeded — typically someone submitted from the local shim — and `cue_reseed_draft`
restarts the draft from live source, discarding any unsubmitted draft edits.

**The cheap edit loop.** A remote client has no shell, so `cue_grep` (regex → matching
`<file>:<line>: <text>` lines), `cue_read_files { lines: [start, end] }` (a ranged read,
returned as RAW TEXT rather than JSON-escaped) and `cue_edit_file { file, edits: [{old,
new}], baseRev }` (exact string replacement; each `old` must match exactly once, and a 0-
or 2-match call is rejected whole, naming the index, the count and the closest line) stand
in for grep, a ranged read and a string replace. Use them: a template's `slides.tsx` runs
32-39 KB, so a whole-file read plus a whole-file write costs ~12k tokens each way for a
three-line change. `cue_write_files` is for NEW files and genuine rewrites.
`cue_read_files` also takes `rev` (`live`, a version id or a 64-hex revision digest,
owner-only) to read a past point on the timeline instead of the workspace.

**Images and video without a shell.** `cue_request_upload` normally answers with a single-use
`uploadUrl` plus a ready-to-run `curl` line. If you have no shell, pass `sourceUrl`
instead and the server fetches that public http(s) image or video itself (private and
loopback hosts refused, 15 s budget plus one second per MB of cap above 8 MB, the same
per-plan cap, the same re-encode, ladder and content-addressed store), answering with
`{ assetId, ref, kind, ladder, width, height, bytes, fetchedFrom }` — reference `ref`
relatively in deck source, before the submit that uses it.
If the image is not on the public web but on the user's own device, hand them the
`uploadUrl` instead: the same URL opened in a browser is an upload page (file picker,
nine languages, single use), and `cue_list_assets` tells you when it landed.

**The first session.** On an account that owns no deck yet, `cue_list_decks` and `cue_shelf`
carry an extra `onboarding` string — what the agent should say and do first: that cue is
connected, and an offer of the first deck (the one-round intake, or a template). It is
present only while the account owns zero decks and disappears the moment it has one, so an
agent keys on the field's PRESENCE, never on a value. The server's `initialize` /
`server/discover` instructions and the skill (§3b) carry the same first-session guidance.

## 4. What stays server-side

The gate, preview build, promote, publish, quota, and ownership checks — identical to
studio authoring. Submitted code is treated exactly like agent output: gated, then
rendered only inside the sandboxed artifact origin (D29 CSP). Token management never
works over bearer auth (session-only) so a leaked token cannot mint successors.
