create-ailk 0.45.0 → 0.46.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +6 -3
  2. package/component-catalog.json +217 -4
  3. package/component-catalog.md +10 -7
  4. package/dist/lib/env-catalog.js +1 -1
  5. package/dist/lib/import-mdx.js +10 -2
  6. package/dist/seed-workspace.d.ts +1 -1
  7. package/dist/seed-workspace.js +10 -3
  8. package/dist/surfaces.js +1 -1
  9. package/package.json +3 -3
  10. package/templates/apps/api/.env.example +23 -0
  11. package/templates/apps/api/CLAUDE.md +13 -6
  12. package/templates/apps/api/src/lib/__mocks__/prisma.ts +11 -0
  13. package/templates/apps/mcp/.env.example +8 -0
  14. package/templates/apps/mcp/CLAUDE.md +22 -6
  15. package/templates/apps/web/.env.example +1 -1
  16. package/templates/apps/web/CLAUDE.md +80 -16
  17. package/templates/apps/web/app/.well-known/mcp.json/route.ts +6 -7
  18. package/templates/apps/web/app/[locale]/layout.tsx +10 -7
  19. package/templates/apps/web/app/api/site-status/__tests__/route.test.ts +120 -0
  20. package/templates/apps/web/app/api/site-status/route.ts +62 -0
  21. package/templates/apps/web/app/llms.txt/route.ts +3 -3
  22. package/templates/apps/web/app/openapi.json/__tests__/route.test.ts +21 -4
  23. package/templates/apps/web/app/openapi.json/route.ts +10 -9
  24. package/templates/apps/web/app/sitemap.xml/route.ts +3 -3
  25. package/templates/apps/web/auth.ts +25 -1
  26. package/templates/apps/web/lib/__tests__/fixtures/mcp-stub-server.ts +10 -3
  27. package/templates/apps/web/lib/__tests__/mcp-served-tools.test.ts +61 -0
  28. package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +384 -1
  29. package/templates/apps/web/lib/__tests__/pricing-page.test.ts +675 -0
  30. package/templates/apps/web/lib/__tests__/site-brand.test.ts +5 -6
  31. package/templates/apps/web/lib/__tests__/site-visibility.test.ts +64 -0
  32. package/templates/apps/web/lib/mcp-oauth.ts +64 -0
  33. package/templates/apps/web/lib/mcp-served-tools.ts +51 -9
  34. package/templates/apps/web/lib/offerings-pricing.ts +173 -20
  35. package/templates/apps/web/lib/pricing-page.ts +382 -43
  36. package/templates/apps/web/lib/site-brand.tsx +1 -7
  37. package/templates/apps/web/lib/site-visibility.ts +45 -0
  38. package/templates/apps/web/messages/en.json +9 -0
  39. package/templates/apps/web/middleware.ts +16 -1
  40. package/templates/apps/web/src/lib/routes.ts +3 -3
  41. package/versions.json +51 -51
  42. package/templates/apps/web/app/.well-known/ai-plugin.json/route.ts +0 -93
@@ -96,8 +96,9 @@ Routes are versioned under `/v1/*`:
96
96
  - `/v1/workspaces/:workspaceId/submissions/:leadId/trial` (POST), `/v1/workspaces/:workspaceId/people/:personId/trial` (GET), `/v1/workspaces/:workspaceId/people/:personId/trial/extend` (POST) — the operator's Start, Get and Extend trial (#9287 C3, `src/routes/workspaces/trial.ts` over `src/services/trial.ts`; spec `docs/specs/9287-operator-started-trials-spec.md` DD2–DD7; Start trial since #9342, spec `docs/specs/9342-start-trial-needs-customers-and-spec.md` DD1–DD7). Same registration, scope and tenant guard as the callbacks read (`workspace || multi-tenant`); the scope is always `request.tenant`. All three need `billing-manage` by role — the owner alone; an admin, a member and every agent key are `403` before any read or Stripe call — and the two POSTs charge a write budget of 30 an hour per person (`chargeWriteBudget` scope `trial`, `429 rate_limited` with `Retry-After`) before their strict body (`bodyLimit` 4 KiB, `400 validation_failed`). The Stripe client is the tenant's own Organization's, `stripeClientForOrganization` only, never the env key (`409 stripe_not_connected`; unusable, or any thrown Stripe error, a fixed `502 stripe_unavailable`, logged by class name only). **Start trial** is a hosted Checkout trial (#9342): it accepts a lead only when it is a `flow:trial` submission of this workspace whose `trial` magnet is a `diagnostic` and names a Person (else one `404 not_found`); the `{ lookupKey }` must be a `plan` `listPlanOfferings` lists (`400 plan_unknown`; a failed read `503 offerings_unavailable`); with no usable `FRONTEND_URL` it is `503 checkout_not_configured` before any Stripe call. It then makes exactly three Stripe calls, all within the Offerings key contract (#8879 §3.3, unchanged): `prices.list` for exactly one active recurring Price under the key (`409 plan_unavailable`); `checkout.sessions.list` of the Person's email's completed sessions, where one tagged `ailk_origin: ailk-trial` is `409 trial_exists` with nothing created; and one session through `lib/stripe.ts`'s `createTrialCheckoutSession` (`@working-theory/stripe-client`) — subscription mode, `trial_period_days: 14`, `payment_method_collection: "if_required"`, `trial_settings.end_behavior.missing_payment_method: "pause"`, the terms box required (`409 terms_not_configured` when the account has no Terms of service URL), `customer_email` the Person's, `subscription_data.metadata` `{ ailk_origin: "ailk-trial", ailk_workspace, ailk_person, site }` with `site` the workspace id (`TRIAL_ORIGIN_TAG`), returning to `<FRONTEND_URL origin>/trial`, keyed `trial-checkout:<leadId>:<lookupKey>`. It calls no Customers or Subscriptions endpoint and writes nothing to the Person: Stripe creates the customer and the trialing subscription when the person completes Checkout, and the hub's licensing module (`@working-theory/api-hub`'s `src/licensing/`, #9383 DD3) mints from `customer.subscription.created` only for a subscription traced to the session Start trial recorded. A session URL `isStripeCheckoutUrl` refuses is `502 stripe_unavailable` with nothing sent. Before anyone is sent the link the session is recorded (`recordCheckoutSession`, #9383) with the workspace, the Organization, the Price and key it read and the connection's mode; a failed record expires the session on the same client and is `502 stripe_unavailable` with nothing sent, and a `conflict` whose stored record is equal in every field is the idempotent replay and succeeds. The person is then emailed the link (`@working-theory/email`'s `sendTrialCheckoutEmail`, from `deliverableSenderAddress()` named "<workspace> via <organization>"); a failed send is one `warn` with its kind and still a success. The answer is `201 { checkout: { url, emailed } }` with `Cache-Control: private, no-store`, re-parsed against `startTrialResponseSchema`. **Get trial** reads the Person's newest RECORDED Start-trial session (#8047 DD5): of the Person's email's ten newest complete sessions, those tagged `ailk-trial`, this workspace and this Person, the newest whose session record names this Organization, workspace and mode — never a customer found by email or stored on the Person — and serves its subscription as `{ subscriptionId, status, trialEnd, lookupKey }`, or `null`. **Extend trial** moves that trial's `trial_end` with `proration_behavior: "none"` only while it is `trialing` (`409 trial_not_active`), to a `trialEnd` strictly later than the current one and no later than 90 days after the request (`400 trial_end_invalid`), nothing written on a refusal. **Get and Extend trial need Subscriptions access, which a key that keeps §3.3 lacks** (#9342 DD7): on such a key Stripe refuses, the route answers `502 stripe_unavailable` and the Person page hides its Trial box; they work on a key that grants that access. Each success writes one `recordAuditAction` row naming the actor and the Person — `people.trial.start` (summary `{ emailed }`, `"true"` or `"false"`) and `people.trial.extend`; a refusal writes none, and Start trial does not mark the lead handled. No log line or audit summary carries the Checkout URL, and no response, log line or audit summary carries an email, a key or a `cus_`/`price_` id (the one `cs_` id served is inside Start trial's URL); Get and Extend's bodies are re-parsed against `trialResponseSchema` (`@working-theory/validation`'s `trial.ts`). No MCP twin — owner-only, recorded in `tests/parity/README.md`. **The managed-service licence** (#9402, spec `docs/specs/9402-managed-service-trials-deliver-the-spec.md` DD5): `/v1/workspaces/:workspaceId/people/:personId/trial/licence` (GET) and `…/trial/licence/reveal` (POST) sit in the same plugin and, like the trial routes, need `billing-manage` by role (#9841, narrowing #9402 DD5's staff audience) — the owner alone; an admin, a member and every agent key are `403` before any read. They read a managed-service trial's licence through the fulfilment seam's optional `readManagedLicence` (`services/offerings/fulfilment-hooks.ts`, built with `fulfilmentContextFor` from the tenant's own client): the GET answers `{ licence }` — `null`, `{ live: false }` or `{ live: true, tier, expiresAt }`, never a key — and the POST charges its own write budget (scope `licencereveal`, 30 an hour per person), takes a strict empty body, and answers `{ key }` only after one `people.trial.licence_reveal` audit row is written (`503 audit_unavailable` and no key when it is not). A licence the issuer recorded for the customer at mint reads as `none` (#9402 AC 5, entitlements#19), whatever the Product is today. `none`/`not_live` on the reveal, and an Organization whose hook has no staff read, are `404 licence_not_found`; a read that cannot be made is `502 licence_unavailable`. Both answer `Cache-Control: private, no-store`; no log line or audit row carries the key. No MCP twin, recorded in `tests/parity/README.md`.
97
97
  - `/v1/workspaces/:workspaceId/members` (GET) — the org's member roster (`userId`, `name`, `email`, `role`), the Pro `workspace` module's Team tab (#5371). Read-only by design: granting a Membership is the invite flow, which is its own spec with a mandatory security review (§2.3), so no POST/PUT/DELETE is routed at this path. Scoped to `request.tenant.organizationId` — Membership is org-level — server-resolved from the validated session. Role floor: `members-read` (owner, admin — `@working-theory/validation`'s permission table (#7636 D2)): the roster carries every member's email, and who the other members are is not a member's job. No MCP twin — identity-bound tenant route (#3591 exception).
98
98
  - `GET /v1/workspaces/:workspaceId/knowledge` — the workspace knowledge read (#9683, spec `docs/specs/9683-agent-session-audit-knowledge-spec.md`; `packages-paid/api-workspace/src/routes/workspaces/knowledge.ts`, `// oss: false`): what the business offers, runs and serves, as `workspaceKnowledgeSchema` — `offerings` (the shown offering set, only while the commerce claim is held), `magnets` (the newest flows page's `live` rows), `meetingTypes` (the enabled slugs minus `privateSlugs`, titled by slug), `sitesServed` (the installed hub's live spokes for this workspace, read only when the hub's own gate answers `claimed`, through the optional `HubRegistry.listLiveSpokesForWorkspace`) and `strategyDocs` (`lib/strategy-docs.ts`, `[]` until a store exists) — every key always present, each entry an id, a title and a summary (`null` when it fails its check; an entry whose id or title fails is skipped and counted). Takes no query. Gate: `allows(people-read) || allows(people-memory-propose)` — a person member holds both; an agent only by grant. Every authenticated call writes one `workspace.knowledge.read` audit row (counts only; an agent's carries its session, thread `workspace:<workspaceId>`); `Cache-Control: private, no-store`. Same registration scope as the routes above (`workspace || multi-tenant`, `tenant:settings`). MCP twin: `get_workspace_knowledge` on `/mcp/workspace`.
99
- - `/v1/workspaces/:workspaceId/agents` (GET `?userId=`, POST), `/v1/workspaces/:workspaceId/agents/:agentId/key` (POST), `/v1/workspaces/:workspaceId/agents/:agentId` (PATCH `{ enabled }`), `PUT /v1/workspaces/:workspaceId/agents/:agentId/grants` (`{ grants }`, #7864), and `/v1/agent/context` (GET) — the agent seat (#3591, `src/routes/workspaces/agents.ts` over `src/lib/agent-store.ts`, `// oss: false`). An agent is a stored delegate of one person, bound to one workspace. The five management routes refuse an agent caller outright (403), check `agents-manage` (owner, admin) before any read, and scope every read and write to `tenant.organizationId`, never a body or query value; an agent of another organization is the same 404 as a missing one. Create returns 201 with the key shown once; re-key returns the new key once. Each successful create, re-key, switch and grant change writes an `agents.*` audit record. **Grants (#7864, `docs/specs/7864-agent-key-grants-spec.md`).** An agent acts at `member`, plus any of nine permissions an owner or admin granted it one by one — `content-edit`, `content-publish`, `assets-write`, `magnets-manage`, `meeting-types-manage`, `people-read` since #852, `member-pieces-manage` since #7878, and `people-memory-propose` and `inbox-act` since #9679 (`@working-theory/validation`'s `AGENT_GRANTABLE_PERMISSIONS`, held to that set by the `agents_grants_allowed` CHECK). The grant PUT replaces the whole set (an empty list removes every grant) and refuses a grant the agent's person's own role does not hold, `409 grant_exceeds_person`. The clamp is one function both tenant guards call (`services/default-tenant.ts`'s `agentTenant`): an agent holds a stored grant only while its person's role holds it, so a demoted person's agent keeps the row but not the permission. The routes for the nine check `allows(tenant, "<permission>")`, which reads the grants — except that the six existing inbox `inbox-act` checks still read `can(tenant.role, …)` until #9686 moves them, and `people-memory-propose` is read today only by the workspace knowledge read (#9683, beside `people-read`); every other check keeps `can(tenant.role, …)`, so no other owner or admin permission is reachable. Every agent write on content, assets and meeting types writes one `recordAgentWrite` row naming the agent and its person (magnets already did); a person's writes there stay unaudited. The member-area writes audit every caller through `recordAuditAction`, whose actor names an agent as the agent. No grant raises the ceiling. `/v1/agent/context` is the agent's own read, unchanged by grants, and needs no permission beyond the workspace guard. Same registration scope as the routes above (`workspace || multi-tenant`).
100
- - `GET /v1/workspaces/:workspaceId/clients` and `DELETE /v1/workspaces/:workspaceId/clients/:clientId[?userId=]` — the workspace's Connected clients (#10393, `src/routes/workspaces/clients.ts` over `src/lib/connected-clients-store.ts`, `// oss: false`). The GET lists, as one table, the workspace's live OAuth authorizations (one row per client and person, from the token rows bound to this workspace; `lastUsedAt` is the newest sign-in or refresh) and its enabled agent keys, each row `kind`, `id`, `client.name`, `person`, `scopes`, `lastUsedAt` and never a token or key. A person holding `agents-manage` (owner, admin) sees every row; anyone else, an agent principal included, sees only their own person's. The DELETE refuses every agent caller (403), ends an OAuth authorization by deleting its token rows for this workspace only (a caller without `agents-manage` may name only themselves — another person's row is the same 404 as a missing one) and an agent key by switching it off (`agents-manage`), touches no session, and writes one audit row and one `connected-client-revoked` log line. The GET's MCP twin is `list_connected_clients`; the DELETE has no tool, by decision. Same registration scope as the routes above (`workspace || multi-tenant`).
99
+ - `GET /v1/workspaces/:workspaceId/craft/:command` — one command's craft (#12015, spec `docs/specs/12015-the-admin-serves-a-plugin-spec.md`; `packages-paid/api-content-write/src/routes/workspaces/craft.ts`, `// oss: false`, in the content-write tenant scope after the overview): any tenant of the workspace (an agent or a cookie session; a personal API token is refused by both guards). `readCommandCraft` (`services/entitlements.ts`) reads the packs the tenant's own workspace has with one resolve call and asks the delivery service once, for this one command, with the site's licence key (`licenseToken()`). It answers 200 `{ command, pack, minShellVersion, craft }` (the craft byte for byte), 403 `pack_required` with `details: { pack, name, where }`, 404 `unknown_command`, or 503 `craft_unavailable` with `details.service` (`entitlements` or `delivery`) — an outage is never a `pack_required`. A command that is not `^[a-z][a-z0-9-]{0,39}$`, or any query key, is 400 `validation_failed`. Nothing is cached, stored or written; `Cache-Control: private, no-store`; one log line per call, `{ event: "craft", outcome, command, workspaceId, pack?, service? }`, never the craft or the key. MCP twin: `get_command_craft` on `/mcp/workspace`.
100
+ - `/v1/workspaces/:workspaceId/agents` (GET `?userId=`, POST), `/v1/workspaces/:workspaceId/agents/:agentId/key` (POST), `/v1/workspaces/:workspaceId/agents/:agentId` (PATCH `{ enabled }`), `PUT /v1/workspaces/:workspaceId/agents/:agentId/grants` (`{ grants }`, #7864), and `/v1/agent/context` (GET) — the agent seat (#3591, `src/routes/workspaces/agents.ts` over `src/lib/agent-store.ts`, `// oss: false`). An agent is a stored delegate of one person, bound to one workspace. The five management routes refuse an agent caller outright (403), check `agents-manage` (owner, admin) before any read, and scope every read and write to `tenant.organizationId`, never a body or query value; an agent of another organization is the same 404 as a missing one. Create returns 201 with the key shown once; re-key returns the new key once. Each successful create, re-key, switch and grant change writes an `agents.*` audit record. **Grants (#7864, `docs/specs/7864-agent-key-grants-spec.md`).** An agent acts at `member`, plus any of nine permissions an owner or admin granted it one by one — `content-edit`, `content-publish`, `assets-write`, `magnets-manage`, `meeting-types-manage`, `people-read` since #852, `member-pieces-manage` since #7878, and `people-memory-propose` and `inbox-act` since #9679 (`@working-theory/validation`'s `AGENT_GRANTABLE_PERMISSIONS`, held to that set by the `agents_grants_allowed` CHECK). The grant PUT replaces the whole set (an empty list removes every grant) and refuses a grant the agent's person's own role does not hold, `409 grant_exceeds_person`. The clamp is one function both tenant guards call (`services/default-tenant.ts`'s `agentTenant`): an agent holds a stored grant only while its person's role holds it, so a demoted person's agent keeps the row but not the permission. The routes for the nine check `allows(tenant, "<permission>")`, which reads the grants — except that the six existing inbox `inbox-act` checks still read `can(tenant.role, …)` until #9686 moves them, and `people-memory-propose` is read today only by the workspace knowledge read (#9683, beside `people-read`); every other check keeps `can(tenant.role, …)`, so no other owner or admin permission is reachable. Every agent write on content, assets and meeting types writes one `recordAgentWrite` row naming the agent and its person (magnets already did); a person's writes there stay unaudited. The member-area writes audit every caller through `recordAuditAction`, whose actor names an agent as the agent. No grant raises the ceiling. `/v1/agent/context` is the agent's own read, unchanged by grants, and needs no permission beyond the workspace guard. Its `packs` field (#12062, `docs/specs/12062-a-connected-claude-can-read-spec.md`) lists each pack of the tenant's workspace — id, name (`PACK_NAMES`) and `has`, in `PLUGIN_IDS` order, every pack even when the workspace has none — from one `readWorkspacePacks` call, or `{ status: "unavailable" }` when the entitlements service cannot be read, never a "no"; it reads no other workspace, and an all-workspaces call naming no workspace is refused `workspace_required` before any read. Same registration scope as the routes above (`workspace || multi-tenant`).
101
+ - `GET /v1/workspaces/:workspaceId/clients`, `DELETE /v1/workspaces/:workspaceId/clients/:clientId[?userId=]` and `PUT /v1/workspaces/:workspaceId/clients/:clientId/outside-send[?userId=]` — the workspace's Connected clients (#10393, `src/routes/workspaces/clients.ts` over `src/lib/connected-clients-store.ts`, `// oss: false`). The GET lists, as one table, the workspace's live OAuth authorizations (one row per client and person, from the token rows bound to this workspace; `lastUsedAt` is the newest sign-in or refresh) and its enabled agent keys, each row `kind`, `id`, `client.name`, `person`, `scopes`, `lastUsedAt`, `outsideSend` and never a token or key. A person holding `agents-manage` (owner, admin) sees every row; anyone else, an agent principal included, sees only their own person's. The DELETE refuses every agent caller (403), ends an OAuth authorization by deleting its token rows for this workspace only (a caller without `agents-manage` may name only themselves — another person's row is the same 404 as a missing one) and an agent key by switching it off (`agents-manage`), touches no session, and writes one audit row and one `connected-client-revoked` log line. A revoke of either kind also clears the connection's outside-send switch. The PUT (#12063, body `{ allowed }`, over `packages/api/src/lib/outside-send-store.ts`) is an owner's switch for one row: it refuses every agent caller and anyone not holding `outside-send` (403), answers 404 for a connection not listed in this workspace now, and refuses to turn on a connection whose person is not an owner now (409 `owner_only`), while turning one off is never refused there; each accepted PUT writes one audit row and one `connected-client-outside-send` log line. Each row's `outsideSend` is `allowed`, `not-allowed` or `unavailable` (its person is not an owner), and a connected Claude reads its own as `outsideSend` in `GET /v1/agent/context`; the Admin cannot stop an outside send, which never passes through it. The GET's MCP twin is `list_connected_clients`; the DELETE and the PUT have no tool, by decision. Same registration scope as the routes above (`workspace || multi-tenant`).
101
102
  - `GET /v1/workspaces/:workspaceId/discovery` and `PUT /v1/workspaces/:workspaceId/discovery` — the owner's discovery switch, whether AI and search tools can find the workspace's site (#10510, `src/routes/workspaces/discovery.ts`, `// oss: false`, over `packages/api/src/services/site-discovery.ts`). Both parse `:workspaceId` with `inboxWorkspaceParamsSchema` (`400 validation_failed`) and act on `request.tenant.workspaceId` only. The GET needs any tenant, an agent included, and answers `{ ok: true, data: { discoverable } }`; the PUT needs `workspace-settings` (owner, admin — an agent is refused, `403`), checked before the strict `{ discoverable: boolean }` body (`400 validation_failed` on anything else), and answers the stored value. The GET's MCP twin is `get_site_discovery`; the PUT has no tool, by decision. Same registration scope as the routes above (`workspace || multi-tenant`, one `tenant:settings` row).
102
103
  - `GET /v1/workspaces/:workspaceId/agent-tools` and `PUT /v1/workspaces/:workspaceId/agent-tools` — what agents can do on the workspace's site, and the owner's per-capability switch for it (#11953, `src/routes/workspaces/agent-tools.ts`, `// oss: false`). Both parse `:workspaceId` with `inboxWorkspaceParamsSchema` (`400 validation_failed`) and act on `request.tenant.workspaceId` only. The GET needs any tenant, an agent included, and answers `{ ok: true, data: { capabilities, deploymentMcp } }` — the three flags `GET /v1/content/agent-tools` answers, from the same `readAgentToolState` (`packages/api/src/services/agent-tool-state.ts`, reached through `buildServer()`'s root decoration), plus whether a keyless MCP server at this deployment is served this workspace. The PUT needs `workspace-settings` (owner, admin — an agent is refused, `403`), checked before the strict `{ off: AgentToolCapability[] }` body (`400 validation_failed` on anything else), writes the `site.agent-tools` row through `writeAgentToolSwitches`, and answers the GET's `data`, recomputed. Neither has a tool, by decision. Same registration scope as the routes above (`workspace || multi-tenant`, one `tenant:settings` row).
103
104
  - `/v1/workspaces/:workspaceId/content` (GET, POST), `/v1/workspaces/:workspaceId/content/:type/:slug` (GET, PATCH), `/v1/workspaces/:workspaceId/content/:type/:slug/{publish,unpublish}` (POST) — the tenant-guarded content editor's write surface (#5853, `src/routes/workspaces/content.ts`): list, create, read/save the draft tip (under `X-Draft-Version`; `If-Match` still accepted for one release, #10264), and publish/unpublish, all over `Artifact`/`ArtifactVersion`. `:type` is validated against the page-type registry (`z.enum(SCHEMA_ORG_TYPES)`) rather than accepted as a free string on every addressed operation — an unregistered type is a 400 before any lookup, since it is echoed back and passed to `notifyRevalidate` as the site's cache tag. Role floors from `@working-theory/validation`'s permission table (#7636 D2): publish and unpublish need `content-publish`, and create, read and save need `content-edit` (both owner, admin — an admin builds, a member operates). The list serves `content-edit` the editor's full view and a caller holding only `docs-read` (a member) a published-only projection (D4): draft rows dropped, every row `status: "published"`, `version: null`, `valid: true`, and a `published_with_draft` page's `type`/`tags` read from its PUBLISHED version — applied before every filter, so a member's `?status=draft` or a draft tip's `?tag=` matches nothing. **The GET list is a UNION of page artifacts and DOCUMENT assets** (#6093, D1/D9 — "one store, two views"): every row carries `tags: string[]` (never null, read from the draft tip's stored content for a page, from `Asset.tags` for a file) and a DERIVED `kind: "page" | "post" | "file"` (`BlogPosting` alone maps to `"post"`; an asset row is always `"file"`) — an optional `?tag=<slug>` filters the union AFTER it is built, so a file is returned under either its own tag or a shared one. The asset half of the union (`DOCUMENT_CONTENT_TYPES`, i.e. `application/pdf`) is skipped entirely when `locale`/`type` is supplied or `status` names anything but `"published"`, since a file row can never satisfy those. A foreign `:workspaceId` costs zero artifact **and** zero asset queries. MCP parity: on `/mcp/workspace`, the create's twin is `create_page` (#10956), the draft read and save are `read_report` and `save_draft` (#10336), and the publish is `publish_draft` (#10661); the list and unpublish have none, as `tests/parity/README.md` and the registry record. `POST /v1/workspaces/:workspaceId/documents/save` (#11811) saves a `Document` — agent context or a plugin-owned document — in the common shape, its address in the body as `POST …/assets/save`'s is: `content-edit` is checked before the body (an agent without it `403 agent_refused`, audited), `version: null` creates and a version edits under a compare-and-swap on the tip, a moved tip or a `null` on an existing document is `409 stale` with `currentVersion`, and a wrong field or word — a plugin contract's misfit included — is `422 invalid` with each issue's path; it never publishes. Its twin is `save_document`; the page save (`PUT …/content/:type/:slug`, `save_page`) also takes an editorial page, whose words are `{ body }`, carrying its stored layout forward. While both ways live, `create_page`, `save_draft` and `save_structure` say they are deprecated. `GET /v1/workspaces/:workspaceId/content/:type/:slug/open?locale=&as=` (#11808, #11882) opens a page laid out in sections as the page envelope: `content-edit` is checked before the query or any read, `as` is `record` (the default: its `fields` and its `words`, the stored layout with the body's words applied) or `working-copy` (a `workingCopy`, `{ document, settings }`, in their place) — `form` is its old name, answered until the release after #11882, and the two sent with different values are `422 invalid` at `as` — a type not laid out in sections is `422 invalid` at `address.type` (a `Document` naming `open_document`), a missing page — or one the caller may not read — a blank built in memory and never stored (#11809): `version` and `structureToken` `null`, `state: "draft"`, `report: null`, `fields: {}` and its template's starting sections headed by the slug, in the shape asked for, a page not in the section form, or whose body's words do not apply cleanly to its layout, `409 not_outlined`, and a page whose working copy would lose a value or exceed the working copy's bounds `409 not_representable` with each issue's path; it never writes or audits, and is limited to 60 calls a minute per workspace. Its twin is `open_page`.
@@ -110,13 +111,13 @@ Routes are versioned under `/v1/*`:
110
111
  - `/v1/workspaces/:workspaceId/kinds` (GET) — the kinds read (#11805; the same file and scope), any tenant of the workspace, no query, no row read. It answers `listKinds(request.tenant, isModuleEnabled)` from `@working-theory/metadata`: `{ kinds: [{ kind, address, fields, moreFields, sectionTypes, states, moves }] }`, one entry per kind of `ADMIN_KIND_REGISTRY` (`@working-theory/validation`) — page, document, language_item, magnet, asset — whose address, fields and states are read off that kind's own schemas, and whose `moves` are the catalog rows tagged with the kind, kept only when the row's gate holds for the CLAMPED tenant the guard built (never an agent's stored grants or a token's raw scopes) and one of its modules runs on this hub; a page's `sectionTypes` names `list_section_types` rather than repeating it. Beside `kinds` (#11878) it answers `forms` (`[{ kind, field, values }]` — each kind's form field and its values, read off that field's own schema through `KIND_FORMS`, then an offering's `ailkGroup` and an appointment with no form), `offSiteForms` (`[{ form, formats }]`), `formats` and `origins`, all from `adminKinds()` and the same for every caller and hub. Advice, never an entitlement: no write path may gate on it. MCP parity: `list_kinds` on `/mcp/workspace`.
111
112
  - `/v1/workspaces/:workspaceId/assets` (GET, POST), `/v1/workspaces/:workspaceId/assets/:assetId` (PATCH, DELETE), `/v1/assets/:assetId` (GET, public/anonymous) — the workspace asset store (#5854 upload/read; #6093 list/PATCH/DELETE, `src/routes/assets/{index,upload,read,manage}.ts`). Upload accepts an allowlisted union of three named classes (`src/routes/assets/index.ts`): five RASTER images (`image/png`, `image/jpeg`, `image/gif`, `image/webp`, `image/avif`), one VECTOR image (`image/svg+xml`, admitted under the operator's 2026-09-18 `allow-svg-assets` ruling — issue #6093 comment `5731573595` — superseding #5854's original SVG exclusion) and one DOCUMENT type (`application/pdf`), all under the existing 20 MB cap; `?tags=<slug>[,<slug>…]` stores tags on the row. The public read serves a RASTER type `inline` exactly as before; every OTHER admitted type (SVG, PDF) is served `attachment`, with the filename's extension pinned to the stored content type (closing extension spoofing) and a five-directive `Content-Security-Policy` (`default-src 'none'; sandbox; frame-ancestors 'none'; form-action 'none'; base-uri 'none'`) that makes the bytes never a document on this origin — this is what makes admitting SVG safe with NO server-side sanitizer. `GET …/assets` (`assets-read` — every role, a member included) lists a workspace's assets, metadata only, never `bytes`, with an optional `?tag=<slug>` filter; this is what narrows the store's prior "nothing lists assets" premise to its precise form — no ANONYMOUS and no CROSS-TENANT enumeration, both still true. `PATCH …/assets/:assetId` updates `title`/`description`/`tags` (`assets-write`, owner and admin, the upload's permission too; `null` clears a text field to SQL `NULL`, `""` stores empty; the asset's `id` and public URL are untouched). `DELETE …/assets/:assetId` (`assets-write`) removes the row and the bytes at the ORIGIN only — already-cached copies elsewhere are not recallable under the year-long `immutable` promise, and no reference check protects a page that still embeds the URL; absent and foreign ids both take the same 404. Every tenant route here is identity-bound; no MCP twin (#3591 exception). The public read has no MCP twin either — it serves bytes to an `<img>`/download, the same boundary `upload.ts` records for its own sibling. **A client's file is never in the library's public life (#7877 D18):** the default `GET …/assets` listing leaves out every asset tagged `private` — only `?tag=private` lists them (the Admin's Compose) — and the public read answers its uniform 404 for an asset tagged `private`, attached to any member-area message, or (#8171 D3) named by a delivered piece version (one `pieceVersion.count`, since the tag can be removed after delivery), so such a file's bytes are served only by its owner's member reads.
112
113
  - `/v1/subscription/me` (GET) — `?include=billing` (#8171 D7), from a cookie session only, adds the optional `planName` and `paymentMethod` (brand, last four, expiry) read from Stripe through `lib/stripe.ts`'s `readCustomerBillingSummary` for the caller's own resolved customer: cached per customer for 60 s (a failure too), one read in flight per customer, bounded at 3 s; a failure leaves both keys absent, a value outside the schema's bounds is `null`, and no id is served or logged. A bearer token, another value or none answers exactly as before.
113
- - `/v1/billing` (GET), `/v1/billing/portal-session` (POST) — org-scoped billing read + Stripe customer-portal session creation. The read stays open to every member (the Admin's plan gate reads it); the portal needs `billing-manage` — the owner alone (`@working-theory/validation`'s permission table (#7636 D2); an admin is refused before any Stripe call). `/v1/billing/usage` (GET) needs `billing-read` (owner, admin). **The read's `commerce` field (#8907 D14)** is the deployment's commerce claim, `claimed | unclaimed | undetermined` (`resolveCommerceClaim()`; a rejected read is `undetermined` and the answer stays `200`) — what the Admin's Billing card reads (#8908 D10). **`?include=billing` (#9067 D1)** — exactly that string, never an array — adds `details` only for a caller holding `billing-manage` (the owner; an agent never qualifies): `licenseExpiresAt` (`checkLicense().expiresAt`, `null` on a failed read) always, and for an Organization with a Stripe customer `renewsAt` (the current subscription's first item's `current_period_end`, only while it will renew), `sites` (its quantity) and `paymentMethod` (brand, last four, expiry), read through `lib/stripe.ts`'s `readCustomerBillingSummary` by `services/entitlements.ts`'s `readOrgBillingSummary` — cached per customer for 60 s (a failure too), one read in flight per customer, bounded at 3 s; a failure answers `details: { licenseExpiresAt }` and still `200`, a value outside `orgBillingDetailsSchema`'s bounds is `null`, no id is served or logged, and the reply carries `Cache-Control: private, no-store`. Every other request is answered exactly as before, with no Stripe or licence read. **`POST /v1/billing/plan-checkout` (#9067 D3, `routes/billing/plan-checkout.ts`)** is the Billing tab's Purchase plan: a subscription Checkout for the caller's own Organization's plan (`planPurchaseLookupKey` — `ailk-pro_monthly` / `ailk-pro-plus_monthly`, `PLAN_PURCHASE_LOOKUP_KEYS` built by the Offerings lookup-key grammar, #9338 DD1), on the admitted key like the portal (#8463). **It sells only an Offerings plan (#9338 DD4):** `createCheckoutSession` gets a `refuseProduct` that refuses every Product whose `metadata.ailk_group` is not exactly `plan` (`isOfferingsPlanProduct`, `services/offerings/catalog.ts`), checked on the same expanded Price it sells; a refused or unexpanded Product answers `500 plan_price_missing`. Check order: tenant → `billing-manage` (403 before any lookup) → write budget (`chargeWriteBudget` scope `plancheckout`, 10 an hour per Organization and per person, `429` with `Retry-After`) → the commerce claim (`409 purchase_unavailable`, `503 license_undetermined`) → a strict `{ returnUrl }` (`bodyLimit` 4 KiB, `400 validation_failed`) → the return URL (canonical, no userinfo, query, fragment or `//` path, `https:` or a local `http:`, on `config.TRUSTED_ORIGINS`; `400 return_url_refused`, `500 config-error` when none is trusted) → no customer yet (`409 billing_customer_exists`) and a purchasable tier (`409 plan_not_purchasable`) → `STRIPE_SECRET_KEY` and `assertAdmittedStripeKey` → one payable session (an open earlier one is expired first, a completed one is `409 purchase_pending`) → `createCheckoutSession` with `mode: "subscription"`, 1–50 sites, `metadata` and `subscriptionMetadata` `{ organizationId, ...siteStamp() }` and `PLATFORM_TERMS_OF_SERVICE`, never a `buyer` → a Checkout URL only → the session id recorded on `Organization.planCheckoutSessionId` by compare-and-set (a lost race or a failed write expires the new session). It answers `{ url }` with `Cache-Control: private, no-store`; no body or log line carries the return URL, an id or a Stripe message. **The webhook's Organization arm binds only that recorded session (#9067 D13):** a `checkout.session.completed` with `metadata.organizationId` links `session.customer` through one guarded `updateMany` on `{ id, planCheckoutSessionId: session.id, billingCustomerId: null }` (clearing the session); anything else — an unrecorded session, a bound customer, every `customer.created` — writes nothing and logs `org_bind_unproven`. No MCP twin for the purchase — owner-only, recorded in `tests/parity/README.md`.
114
+ - `/v1/billing` (GET), `/v1/billing/portal-session` (POST) — org-scoped billing read + Stripe customer-portal session creation. The read stays open to every member (the Admin's plan gate reads it); the portal needs `billing-manage` — the owner alone (`@working-theory/validation`'s permission table (#7636 D2); an admin is refused before any Stripe call). `/v1/billing/usage` (GET) needs `billing-read` (owner, admin). **The read's `commerce` field (#8907 D14)** is the deployment's commerce claim, `claimed | unclaimed | undetermined` (`resolveCommerceClaim()`; a rejected read is `undetermined` and the answer stays `200`) — what the Admin's Billing card reads (#8908 D10). **`?include=billing` (#9067 D1)** — exactly that string, never an array — adds `details` only for a caller holding `billing-manage` (the owner; an agent never qualifies): `licenseExpiresAt` (`checkLicense().expiresAt`, `null` on a failed read) always, and for an Organization with a Stripe customer `renewsAt` (the current subscription's first item's `current_period_end`, only while it will renew), `sites` (its quantity) and `paymentMethod` (brand, last four, expiry), read through `lib/stripe.ts`'s `readCustomerBillingSummary` by `services/entitlements.ts`'s `readOrgBillingSummary` — cached per customer for 60 s (a failure too), one read in flight per customer, bounded at 3 s; a failure answers `details: { licenseExpiresAt }` and still `200`, a value outside `orgBillingDetailsSchema`'s bounds is `null`, no id is served or logged, and the reply carries `Cache-Control: private, no-store`. **The same gate adds `plugins` (#12009 D2, `routes/billing/plugin-billing.ts`):** the Organization's workspaces (`{ id, name }`, `readOrgWorkspaces`) and one row per plugin in `PLUGIN_IDS` order — `has` (the workspaces `workspaceHasPlugin` answers yes for), `billingReasons` (the union of their reasons, in `PLUGIN_REASONS` order; Billing is the reason's one reader, guarded by `plugin-entitlement-confinement.test.ts`), `bought` (the workspaces on the Organization's active `PluginPurchase` rows, by interval — what their subscriptions bill), `prices` (integer US cents from `services/entitlements.ts`'s `readPluginCatalogue`, the entitlements service's catalogue read on #12001's call, cached 60 s; `null` for growth-ops, an unsold plugin, a placeholder or non-`usd` price, or an unread catalogue — never a fallback) and `forSale` (a shown price, a Stripe customer, the commerce claim `claimed` and a registered grant writer — `services/plugin-purchases.ts`'s `pluginGrantWriter()`, which only the hub's licensing module registers, so a hub without it sells nothing). A failed plugin read leaves the key out and logs `plugins_unavailable`; the rest of the answer stands. Every other request is answered exactly as before, with no Stripe or licence read. **`POST /v1/billing/plan-checkout` (#9067 D3, `routes/billing/plan-checkout.ts`)** is the Billing tab's Purchase plan: a subscription Checkout for the caller's own Organization's plan (`planPurchaseLookupKey` — `ailk-pro_monthly` / `ailk-pro-plus_monthly`, `PLAN_PURCHASE_LOOKUP_KEYS` built by the Offerings lookup-key grammar, #9338 DD1), on the admitted key like the portal (#8463). **It sells only an Offerings plan (#9338 DD4):** `createCheckoutSession` gets a `refuseProduct` that refuses every Product whose `metadata.ailk_group` is not exactly `plan` (`isOfferingsPlanProduct`, `services/offerings/catalog.ts`), checked on the same expanded Price it sells; a refused or unexpanded Product answers `500 plan_price_missing`. Check order: tenant → `billing-manage` (403 before any lookup) → write budget (`chargeWriteBudget` scope `plancheckout`, 10 an hour per Organization and per person, `429` with `Retry-After`) → the commerce claim (`409 purchase_unavailable`, `503 license_undetermined`) → a strict `{ returnUrl }` (`bodyLimit` 4 KiB, `400 validation_failed`) → the return URL (canonical, no userinfo, query, fragment or `//` path, `https:` or a local `http:`, on `config.TRUSTED_ORIGINS`; `400 return_url_refused`, `500 config-error` when none is trusted) → no customer yet (`409 billing_customer_exists`) and a purchasable tier (`409 plan_not_purchasable`) → `STRIPE_SECRET_KEY` and `assertAdmittedStripeKey` → one payable session (an open earlier one is expired first, a completed one is `409 purchase_pending`) → `createCheckoutSession` with `mode: "subscription"`, 1–50 sites, `metadata` and `subscriptionMetadata` `{ organizationId, ...siteStamp() }` and `PLATFORM_TERMS_OF_SERVICE`, never a `buyer` → a Checkout URL only → the session id recorded on `Organization.planCheckoutSessionId` by compare-and-set (a lost race or a failed write expires the new session). It answers `{ url }` with `Cache-Control: private, no-store`; no body or log line carries the return URL, an id or a Stripe message. **The webhook's Organization arm binds only that recorded session (#9067 D13):** a `checkout.session.completed` with `metadata.organizationId` links `session.customer` through one guarded `updateMany` on `{ id, planCheckoutSessionId: session.id, billingCustomerId: null }` (clearing the session); anything else — an unrecorded session, a bound customer, every `customer.created` — writes nothing and logs `org_bind_unproven`. No MCP twin for the purchase — owner-only, recorded in `tests/parity/README.md`. **`POST /v1/billing/plugin-checkout` (#12009 D5, `routes/billing/plugin-checkout.ts`)** is the Billing tab's "+ Add" on a plugin row: a subscription Checkout for one plugin at one interval (`year` or `month`), one unit per chosen workspace, on the Organization's own bound customer. Check order: tenant → `billing-manage` (403 before any read) → write budget (scope `plugincheckout`, 10 an hour per Organization and per person) → the commerce claim → a strict `{ plugin, interval, workspaceIds (1–50, distinct), returnUrl }` → plan-checkout's own return-URL rule (`isAcceptableReturnUrl`) → a registered grant writer (`409 purchase_unavailable`) → a bound customer (`409 billing_customer_missing` — no plugin before the plan) → the catalogue (`503 catalogue_unavailable` on an unread one; `409 plugin_not_for_sale` for growth-ops, an unsold plugin or a placeholder price) → the workspaces (each a `wksp_` id of the caller's own Organization, else `400 workspace_refused`; a failed entitlement read for any of them, `503 entitlement_unavailable` — `workspaceHasPluginForSale`, which fails closed where `workspaceHasPlugin` answers no; one it answers yes for, or an active purchase of the plugin names, `409 plugin_already_added`) → the admitted Stripe key → one open Checkout per workspace, from one read of the plugin's `created` and `active` purchases (one confirmed since the step before, `active`, naming a chosen workspace answers `409 plugin_already_added`; an earlier `created` one is expired and ended; a completed one answers `409 purchase_pending`) → `createCheckoutSession` at the catalogue's lookup key with `quantity` equal to the workspace count, no `adjustableQuantity`, `metadata` and `subscriptionMetadata` `{ organizationId, ailk_plugin, ...siteStamp() }`, and a `refusePrice` that refuses any Price whose `unit_amount`, currency or interval is not the catalogue's, or that is not billed per unit, once per interval, with no quantity transform (`500 plugin_price_mismatch`) → a Checkout URL only → the session recorded as a `PluginPurchase` with the Price id `refusePrice` accepted (`state: created`; no accepted Price, or a failed write, expires the session and answers 502) → no rival recorded or confirmed meanwhile for a chosen workspace (else the new session is expired and ended: `409 purchase_pending` for a `created` rival, `409 plugin_already_added` for an `active` one; a recheck that cannot be read does the same and answers 502). **The webhook's plugin path (#12009 D9, `services/plugin-purchases.ts` `fulfilPluginEvent`)** runs once after the site filter and before the `switch`, and only on a hub with billing's grant writer: for a `checkout.session.completed`, `customer.subscription.*`, `invoice.paid` or `invoice.payment_failed` whose object carries the `ailk_plugin` stamp (`PLUGIN_SUBSCRIPTION_METADATA_KEY` — a filter only, never a grant) it traces the event's subscription to a recorded purchase (bound, or by `checkout.sessions.list` and a once-only bind), re-reads the subscription from Stripe, stores `state` and `exp` (the item's `current_period_end` while `active` or `trialing` and still paying for the record — quantity at least the recorded workspaces, the recorded Price and interval, collection not paused — else now; `ended_at` or now, `state: ended`, when `canceled` or `incomplete_expired`; nothing while `incomplete`; now otherwise — no grace), and writes one `add_on` grant per workspace with the latest `exp` among the purchases covering it and that purchase's subscription. It never throws, an untraced subscription grants nothing, and no grant is written without an `exp`. When a read or a grant write fails (Stripe, the database or entitlements down) it answers `"retry"`: the webhook un-marks the event (`unmarkSeen`) and answers `503`, before any arm of the `switch` runs, so Stripe redelivers it and the idempotent path re-derives every grant.
114
115
  - `/v1/billing/stripe-connection` (GET, PUT, DELETE), `/v1/billing/stripe-connection/live` (POST), `/v1/billing/stripe-connection/webhook-secret` (PUT), `/v1/billing/stripe-connection/webhook-reset` (POST) — the Organization's own Stripe connection (#8907, `src/routes/billing/stripe-connection.ts`; spec `docs/specs/8907-the-organization-stripe-connection-custody-spec.md`; contract `docs/specs/8879-the-offerings-security-contract-key-spec.md`). Registered from `routes/billing/index.ts`, so the same multi-tenant tenant scope and module gate; the target is always `request.tenant.organizationId`. **Data access and the cipher** are `src/services/offerings/connection.ts`, the only file that touches the StripeConnection model (exactly ten delegate calls, `architecture.yaml` `paths_scoped`): the key and the webhook secret are AES-256-GCM ciphertext under `STRIPE_CONNECTION_KEY`, bound to the Organization, the column and (for the secret) the mode; decryption also tries `STRIPE_CONNECTION_KEY_PREVIOUS`. The GET needs `billing-read` and answers `null` or exactly `{ mode, last4, webhookPath, webhookSecretSet, connectedAt, liveAt, updatedAt }` (a corrupt row `500 connection_unreadable`); with no stored row it answers `{ source: "environment", mode }` to the Organization that owns `STRIPE_SECRET_KEY` and `null` to every other (#9285 — without the `multi-tenant` module selected the single Organization owns it; with it selected in `AILK_ENABLED_MODULES`, whether or not the licence claims it (#9968), only the one `STRIPE_ENV_ORGANIZATION_ID` names, so unset is nobody: a deployment that selects `multi-tenant` must set `STRIPE_ENV_ORGANIZATION_ID` for any Organization to own the environment key, a downgraded one whose licence no longer claims the module included), and that Organization's Offerings reads and shown set go through the same key (`services/offerings/connection.ts`'s `getOfferingsConnectionState` and the `stripeClientForOrganization` fallback), but its checkout stays on the env path — `resolveOfferingsCheckoutPath` returns the Offerings path only for a stored connection, because a session stamped `ailk_offering` on the environment key is acked `offerings_path` by the legacy webhook and never recorded (#9296; the bridge until a stored connection exists, #8936); every write needs `billing-manage` (the owner alone), checked before the body is read, and answers `{ mode, webhookSecretSet, liveAt, updatedAt }` — never `last4` or the path. PUT `{ key }` admits a restricted test key only (`400 stripe_key_refused` with a `reason` from the class table: `key_unrestricted`, `key_publishable`, `live_key_needs_go_live`, `key_unrecognized`); a replace keeps the webhook token and returns the connection to test mode, clearing a live secret. POST `…/live` `{ key, webhookSecret, confirm: "go-live" }` admits a restricted live key only when a cookie session (`403 session_required`), the commerce claim (`409 commerce_required`, `503 license_undetermined`), a production build (`409 live_mode_unavailable` — `lib/stripe.ts`'s `isProductionBuild`), the confirmation (`400 confirmation_required`) and a `whsec_` secret (`400 webhook_secret_invalid`) all hold. Connect and go-live run three read probes — `products.list`, `prices.list`, `checkout.sessions.list`, together, 10 s — through `lib/stripe.ts`'s `stripeClientForConnection` (the per-key factory's one caller, confined in `architecture.yaml`) before anything is stored: `400 stripe_key_refused` `key_not_usable` or `502 stripe_unavailable`, nothing written. The secret PUT binds it to the row's mode; the reset mints a new token and clears the secret; DELETE removes the row, so the token's lookup (`findStripeConnectionByWebhookToken`, #8861's receiver) answers `not-found` at once; it is a compare-and-swap on the row it read, so it answers `{ revoked: false }` when that read found none, and `409 connection_changed` when the row keeps changing between the read and the delete. On a build that is not production, every write to a live row is `409 live_mode_unavailable` and nothing decrypts one. With `STRIPE_CONNECTION_KEY` unset, connect, go-live and the secret answer `503 credential_key_not_configured`; the GET, reset and DELETE need no key and no claim. **The write budget (K10):** every write but DELETE that passes the permission is counted, refused keys included — 10 an hour per Organization, 20 per person (`middleware/rate-limit.ts`'s `chargeWriteBudget`, always its own database store) — `429 rate_limited` with `Retry-After`. Every success writes one `billing.stripe_connection.<connect|replace|go_live|webhook_secret|webhook_reset|remove>` audit row whose summary is `{ mode, last4 }` and emails every owner, the actor included (`@working-theory/email`'s `sendStripeConnectionChangedEmail`); neither can change the answer. Every response is `Cache-Control: private, no-store`; no response, log line, audit row or email carries the key, the secret, the token or a ciphertext. The rekey bin is `stripe-connections:rekey` (`node dist/bin/stripe-connections-rekey.js`), run with the production environment; anywhere else it answers `not_production` and touches nothing. No MCP twin — owner-only key custody that no agent can hold, recorded in `tests/parity/README.md`.
115
116
  - `/v1/billing/stripe-products` (GET, PUT) — the may-sell product list and the org-enabled write (#8922, `src/routes/billing/stripe-products.ts`; spec `docs/specs/8922-the-may-sell-product-list-spec.md`; contract A12, G3, G4, T6). Registered from `routes/billing/index.ts`, so the same multi-tenant tenant scope and module gate; the target is always `request.tenant.organizationId`. Check order: tenant → permission (GET `billing-read`, owner and admin; PUT `billing-manage`, the owner alone — checked before the body, so an admin, a member and an agent key get `403` whatever they send) → the commerce claim (`409 commerce_required`, `503 license_undetermined` with `Retry-After: 300`) → the body → the connection → the catalog read. The GET answers `{ ok: true, data: { connected, products } }`: every active Product `normalizeCatalog` keeps, offerings first in its order then the held ones, each exactly `{ productId, name, description, enabled, heldReason }` — `heldReason` an `OFFERINGS_HELD_REASONS` value or `null`, a held entry always `enabled: false` with `description: null`, and no price, lookup key, image or URL. No connection is `connected: false, products: []`; a corrupt one is `409 connection_unreadable` on both routes, never the empty list. The PUT takes a strict `{ productIds }` (`bodyLimit` 32 KiB; `400 validation_failed` for a malformed body, a duplicate or a malformed id) and replaces the whole set: more than 100 ids, an id in neither list, and a held id are `400 offerings_enabled_refused` with `reason` `too_many_products`, `product_not_in_catalog` or `product_held` (the lookup-key gate — `needs_lookup_key` covers a missing `{plan}_{period}` key and a period that disagrees with the Price, `plan_conflict` a plan two Products share), nothing written; no connection is `409 stripe_not_connected`. It answers the GET body for the new set, parsed before the write. The set's one writer is `services/offerings/store.ts`'s `writeEnabledProductIds` (an `upsert`, `architecture.yaml` `paths_scoped`), through `services/offerings/index.ts`'s `listOrgProducts` and `setOrgEnabledProducts`; both share the per-Organization catalog read (one a minute per process, T7), so `getOrgEnabledProducts` afterwards reads the row with no Stripe call. The catalog comes from `services/offerings/source.ts`'s `stripeCatalogSourceFor` — the Organization's own client (`stripeClientForOrganization`), paged at most 10 product and 30 price calls, 20 s for the whole read, confined in `architecture.yaml`; a disconnected or unusable connection rejects rather than reading as empty, and any source failure is `502 offerings_source_unavailable` with a fixed message. Every successful write records one `offerings.enabled.set` audit row naming the actor, whose summary is `{ enabled, added, removed }` counts only; a failed audit write is one `error` line and the answer stays `200`. Every response is `Cache-Control: private, no-store`, every error message is fixed, and no log line carries a product or price id, a name or the body. The wire names are #8923's, the Admin card that reads it. No MCP twin — owner and admin settings that no agent can hold, recorded in `tests/parity/README.md`.
116
117
  - `/v1/workspaces/:workspaceId/offerings` (GET, PUT) — the Library → Offerings tab's read and the workspace's selection write (#8926, `src/routes/workspaces/offerings.ts`; spec `docs/specs/8926-the-workspace-offerings-route-get-spec.md`; contract A12, T6, T7; the wire shape is #8928 D10's, made per Stripe Price by #9070, spec `docs/specs/9070-the-workspace-offerings-page-becomes-spec.md`). Registered in the multi-tenant tenant scope beside the billing routes; every read and write keys on `request.tenant`, never the path or the body. The GET is open to every member, an agent key included: with the `commerce` claim `unclaimed` it answers `{ status: "unavailable", reason: "no_commerce" }`, with no StripeConnection `reason: "no_connection"` (both `200`, no catalog read); `undetermined` is `503 license_undetermined` with `Retry-After: 300`, and an unreadable connection is `502 offerings_source_unavailable`, never unconnected or an empty list. Available, it answers `{ status: "available", products, shown, recommended: { plan, addon } }`: `products` are `getOrgEnabledProducts`' offerings (enabled and sellable, the normalizer's order, plans before add-ons, each `recommended: false`, never a held product), `shown` one `{ productId, periods }` per Product with an effective shown Price, in products order with each Product's periods in its Price order, and each Recommended only while it is such a Product of its group, read from the selection row (`readWorkspaceSelection`), never the snapshot; a read never rewrites the row. **The shown set is per Stripe Price (#9070):** the row stores `shown_price_ids` beside `shown_product_ids` (the Products with at least one of them), and `services/offerings/index.ts`'s `shownPriceIdsFor` is the one rule every reader applies — the stored Price ids the catalog still carries, or, for a row saved before #9070 (none stored), every Price of each shown Product; a Price the seller replaced in Stripe is off until switched on. The PUT needs `workspace-settings` (owner, admin; never agent-grantable) checked by role before the body, then the claim (`409 offerings_unavailable`, `503 license_undetermined`), then a write budget charged before the body — 30 saves an hour per person, then 60 per Organization only while the person is within theirs (`chargeWriteBudget`, scope `offeringsshown`; `429 rate_limited` with `Retry-After`) — then a strict `{ productId, period, shown }` — ONE Price's switch, named by its Product and period, never a price id (`bodyLimit` 32 KiB, `400 validation_failed`, so no body can name a Recommended or a whole set) — the connection (`409 offerings_unavailable` for none, `502` for unreadable) and the catalog read (`502 offerings_source_unavailable`). A Product that is not enabled and sellable is `400 offerings_shown_refused` `reason: "product_not_enabled"`, a period it has no Price for `reason: "price_not_offered"`, nothing written; it never writes the Organization's enabled set. The save adds or removes that Price from the previous row's effective set (a legacy row expanded once, here), and keeps each stored Recommended while its Product keeps a shown Price, clearing it otherwise — it never sets one (a Recommended is written only by code or a recommender). A save goes through `services/offerings/store.ts`'s `updateWorkspaceSelection`, which reads the stored selection and `upsert`s the next one in one transaction under the advisory lock `ailk:workspace-offerings:<workspaceId>` (#9970 D7), creating the row on a first save and never naming the snapshot (`architecture.yaml` `paths_scoped`), records one `offerings.shown.set` audit row whose summary is `{ shown, added, removed, recommended }` counts only — `shown`, `added` and `removed` count Prices against the previous effective set since #9070 (a failed audit is one `error` line and the answer stays `200`), and awaits `refreshWorkspaceSnapshot` with `force` — logged once as `snapshot_refreshed` or `snapshot_pending`; a failed refresh never fails the save — then answers `{ shown, recommended }`. Every response is `Cache-Control: private, no-store`, every error message is fixed, and no log line carries a product or price id, a name or the body. MCP parity: the GET's twin is `get_workspace_offerings` on `/mcp/workspace` (#10949); the PUT has no tool — it needs `workspace-settings`, which is never agent-grantable — recorded in `tests/parity/README.md`.
117
118
  - `/v1/schedule/availability` (GET), `/v1/schedule/event-meta` (GET), `/v1/schedule/book` (POST) — anonymous scheduling proxy behind the provider seam (`src/services/scheduling/`); Cal.com v2 today, a self-hosted engine later, same three calls. `event-meta` is the meta-only read (title · duration · description · price) so rendering an event's facts never fetches an availability window (#4633). `CAL_API_KEY` is read server-side only. Which account answers is `resolvePublicSchedulingProvider` (#7533 D4), from `resolvePublicWorkspace()` and never the request: off the database adapter, the env credential as before; a resolved workspace, its own connection (or the env credential on a one-workspace deployment); an unresolved one, `503 not_configured` — fail closed. MCP twins: `list_availability` / `get_event_meta` / `create_booking` (#4416, #4633), unchanged — same arguments, same result shape. **A hub's spokes (#7944):** a call carrying a spoke key passes one gate before any event, slot or booking call — every calLink's slug must be one its workspace has enabled (no provider call at all), and every calLink's owner must equal the handle of the account the workspace's credential belongs to (`SchedulingProvider.getAccountHandle()`, Cal `GET /v2/me`, remembered 60 s per key, an empty answer never remembered); a refusal is `404 event_not_found`, an unreadable handle the read's own kind (`502 provider_error`), and each refusal logs one `warn` of `{ route, spokeId, reason }` and nothing else. A refused key keeps the answer each route gave it before; keyless callers skip the gate and never read the handle. The MCP twins forward no visitor identity, so every MCP caller shares the MCP host's one per-IP `schedule` bucket on the hub (`availability`, `event-meta` and `book` counted together): one caller's reads can make `create_booking` answer 429 for every other MCP caller of that host. This is accepted (#7944 D6) — the site's own booker carries the visitor's identity through the relay and is unaffected; the reopen trigger is recorded in `apps/mcp/src/tools/create_booking.ts`'s header
118
- - `/v1/schedule/meeting-types` (GET) — the enabled-meeting-slugs public read (#6183 S9b, `src/routes/schedule/meeting-types.ts`): the session-less read the public `/meet` surface needs to honour the operator's enabled-slug gate (`/v1/workspaces/:workspaceId/meetings`, above), since a public page holds no session. Resolves its workspace via `resolvePublicWorkspace()` (the same fail-closed predicate the public content read uses — no client-suppliable workspace, ever) and reads through a new named public-read boundary, `src/lib/public-meetings-config.ts` (modelled on `lib/asset-store.ts`): one `findUnique` by the resolved `workspaceId`, no write, no list. `{ slugs: string[] | null }` — `null` means "no stored list" (an unconfigured deployment, or the non-database adapter). Since #8843 no in-tree page calls it: the booking pages read `/v1/schedule/meetings` below, whose no-row rule replaced the web app's env-derived singleton; it stays for a spoke on an older `apps/web`. Reads no client input. No MCP twin — deferred to a named follow-up rather than silently skipped (the route's own header, §10 Q3 of the spec).
119
- - `/v1/schedule/meetings` (GET) — the meetings read (#8843 D1–D3, `src/routes/schedule/index.ts`; spec `docs/specs/8843-the-meet-index-and-meeting-spec.md`): the caller's workspace's Live meetings with every fact a booking page shows, so no title, length, description or price is copied into content. Anonymous, in the same `scheduling`-gated schedule scope and strict per-IP limit as its siblings. It takes no argument (a query parameter is `400 invalid_input`, as its twin refuses one): the workspace comes from `resolvePublicWorkspace()`, the provider from `resolvePublicSchedulingProvider`, a refused spoke key, no provider or an unresolved workspace answering `503 not_configured`. The Live set is the stored row's `enabledSlugs` that pass `MeetingSlugSchema`, less its `customerSlugs` (#11122 D6: an Authenticated type is booked from the member area only, so it is never on `/meet`, `/private` or the public booker — `public-meetings-config.ts` answers that difference to every public route); with no row a spoke's is empty (and no provider call is made), and a keyless caller's is every event type the account lists. Rows: each listed event type whose slug is Live, in the provider's order, `bookable: true` with `calLink` (`<account handle>/<slug>`), `title`, `durationMinutes` and the optional `description` and `price`; then each Live slug the provider does not list, `bookable: false` (a `null` handle makes every row non-bookable); each with `visibility` (`private` when the row's `privateSlugs` holds it, else `public`) and `position`, at most 20 rows. These rules live in `src/services/scheduling/meetings.ts`'s `listWorkspaceMeetings` (#9129), which the route calls with the account handle read; `GET /v1/member/meeting-types` calls the same function's `customers` list without it, so the member read makes no `/v2/me` call. **`privateSlugs` (#8843 D2)** is a fourth optional list on the meetings blob — what a site lists on `/private` rather than `/meet`; the meetings PUT keeps a stored list a body leaves out, as it keeps `customerSlugs`, and `meeting-types` ignores it. `enabledSlugs` keeps its whole-list meaning (a body without it parses to `[]`), so a writer of `privateSlugs` sends the `enabledSlugs` it read. **Private means unlisted, not access-controlled:** the read and its twin serve private rows to any caller, and `availability`, `event-meta` and `book` accept a private Live slug like a public one. The body is re-parsed against `MeetingListSchema` before it is sent (a failure is `502 provider_error`); a provider failure logs `{ route: "meetings", kind, detail }`, and nothing is logged on success. MCP twin: `list_meetings` (D5).
119
+ - `/v1/schedule/meeting-types` (GET) — the enabled-meeting-slugs public read (#6183 S9b, `src/routes/schedule/meeting-types.ts`): the session-less read the public `/meet` surface needs to honour the operator's enabled-slug gate (`/v1/workspaces/:workspaceId/meetings`, above), since a public page holds no session. Resolves its workspace via `resolvePublicWorkspace()` (the same fail-closed predicate the public content read uses — no client-suppliable workspace, ever) and reads through a new named public-read boundary, `src/lib/public-meetings-config.ts` (modelled on `lib/asset-store.ts`): one `findUnique` by the resolved `workspaceId`, no write, no list. `{ slugs: string[] | null }` — `null` means "no stored list" (an unconfigured deployment, or the non-database adapter). Since #8843 no in-tree page calls it: the booking pages read `/v1/schedule/meetings` below — since #11977 its unlisted twin `/v1/schedule/meeting-pages` — whose no-row rule replaced the web app's env-derived singleton; it stays for a spoke on an older `apps/web`. Reads no client input. No MCP twin — deferred to a named follow-up rather than silently skipped (the route's own header, §10 Q3 of the spec).
120
+ - `/v1/schedule/meetings` (GET) — the meetings read (#8843 D1–D3, `src/routes/schedule/index.ts`; spec `docs/specs/8843-the-meet-index-and-meeting-spec.md`): the caller's workspace's Live meetings with every fact a booking page shows, so no title, length, description or price is copied into content. Anonymous, in the same `scheduling`-gated schedule scope and strict per-IP limit as its siblings. It takes no argument (a query parameter is `400 invalid_input`, as its twin refuses one): the workspace comes from `resolvePublicWorkspace()`, the provider from `resolvePublicSchedulingProvider`, a refused spoke key, no provider or an unresolved workspace answering `503 not_configured`. The Live set is the stored row's `enabledSlugs` that pass `MeetingSlugSchema`, less its `customerSlugs` (#11122 D6: an Authenticated type is booked from the member area only, so it is never on `/meet`, `/private` or the public booker — `public-meetings-config.ts` answers that difference to every public route); with no row a spoke's is empty (and no provider call is made), and a keyless caller's is every event type the account lists. Rows: each listed event type whose slug is Live, in the provider's order, `bookable: true` with `calLink` (`<account handle>/<slug>`), `title`, `durationMinutes` and the optional `description` and `price`; then each Live slug the provider does not list, `bookable: false` (a `null` handle makes every row non-bookable); each with `visibility` (`private` when the row's `privateSlugs` holds it, else `public`) and `position`, at most 20 rows. These rules live in `src/services/scheduling/meetings.ts`'s `listWorkspaceMeetings` (#9129), which the route calls with the account handle read; `GET /v1/member/meeting-types` calls the same function's `customers` list without it, so the member read makes no `/v2/me` call. **`privateSlugs` (#8843 D2)** is a fourth optional list on the meetings blob — what a site lists on `/private` rather than `/meet`; the meetings PUT keeps a stored list a body leaves out, as it keeps `customerSlugs`, and `meeting-types` ignores it. `enabledSlugs` keeps its whole-list meaning (a body without it parses to `[]`), so a writer of `privateSlugs` sends the `enabledSlugs` it read. **The read is the site's public meetings, for every caller (#11977, amending #8843 D2 for the list):** `listWorkspaceMeetings` drops every slug the row's `privateSlugs` holds from the Live set before the order and the cap, so `position` counts the returned rows, and a spoke's key changes nothing; its twin `list_meetings` answers the same rows. **`/v1/schedule/meeting-pages` (GET, #11977 D3)** is the same read with the private rows kept, marked `private` — what the site's own booking pages render (`/meet`, `/private`, `/meet/<slug>`, a flow's results link, through `schedule.meetingPages()`); one handler in `listMeetingsRoute` serves both paths, so the caller, provider, workspace, refusals, re-parse and logging are one. It has no MCP tool, by decision (`tests/parity/README.md`). **Private still means unlisted, not access-controlled:** `meeting-pages` is anonymous, and `availability`, `event-meta` and `book` accept a private Live slug like a public one. The body is re-parsed against `MeetingListSchema` before it is sent (a failure is `502 provider_error`); a provider failure logs `{ route: "meetings", kind, detail }`, and nothing is logged on success. MCP twin: `list_meetings` (D5).
120
121
  - `POST /v1/webhooks/calcom` — the scheduling booking-event receiver (#6085, brief H7): verifies the provider's HMAC-SHA256 signature (`x-cal-signature-256`) over the raw body, then normalizes one of six `BOOKING_*` trigger events into an `Appointment` row (`src/services/scheduling/appointments.ts`). `CAL_WEBHOOK_SECRET` is read server-side only (`config/index.ts`); an unset secret answers `503`, never a silent accept. Registered on the same `webhooksScope` as `/v1/webhooks/stripe` (its raw-body content-type parser is what a signed receiver needs), module-conditional (`scheduling`, `src/routes/webhooks/index.ts`). No commerce-claim read: a booking event is not a money event (D-67 puts the payment on the provider's own side). No MCP twin — an inbound receiver for one named provider, not an endpoint an agent could reasonably call, the same footing `POST /v1/webhooks/stripe` already takes.
121
122
  - `POST /v1/webhooks/calcom/:connectionToken` — the same receiver for ONE workspace's own connection (#7533 D6, `calcomConnectionWebhookHandler`). The 43-character token in the path names one `SchedulingConnection` row, whose own decrypted secret verifies `x-cal-signature-256` and whose `workspaceId` the Appointment is written to — nothing in the body, query or headers reaches the workspace. A malformed or unknown token, or another provider's connection, is `404 not-found` (logged nothing); a secret that will not decrypt is `503 webhook-not-configured`; the rest of the ladder is the legacy route's, by the same code. Same module gate and `loadSlice` call as the legacy route, its own rate-limit bucket. The legacy `POST /v1/webhooks/calcom` is unchanged: the env account's receiver, writing into the `AILK_SITE_ID` workspace (SEC-7533-2, accepted). No MCP twin — the same inbound-receiver footing as the legacy route.
122
123
  - `POST /v1/slack/events` — the prospect channel's Slack Events API receiver (#9854, `packages-paid/api-scheduling/src/routes/webhooks/slack-events.ts`). Every Organization's Slack app points its Request URL here; the path carries no parameter and no token (#9339). The event's `team_id` finds the one `SlackConnection` (`findSlackConnectionByTeam`, which answers the Organization, the team and the decrypted signing secret — never the bot token — and logs nothing), and THAT connection's own signing secret verifies Slack's `v0` signature over the raw body with a 300 s timestamp tolerance; the Organization is always the connection's, never a payload value (#7522). `url_verification` (no `team_id`) is answered `200 { challenge }` from a shape check alone, reading and writing nothing; a malformed challenge or body is `400 invalid-payload`. A missing or repeated header, a stale timestamp, a malformed or unknown team and a bad signature all answer one identical empty `401`; a connection-store failure is `503`, so Slack retries. A verified `member_joined_channel` from outside the connection's team stamps `prospectJoinedAt`, and a later `message` from the connection's own team by a person or another app stamps `firstAgentMessageAt`, on the record found by (team, channel) inside that Organization (`stampProspectChannelActivity`); no message content is read or stored. One `SCHEDULING` row in the `webhooks` scope (`slackEventsRoutes`, `loadSlice`), so it loads on every build that carries the scheduling module and on no other, with its own 6,000 req/min/IP bucket. Logs a `reason` kind only. No MCP twin — a signed inbound receiver for one provider, the same footing as `POST /v1/webhooks/calcom` and `/v1/slack/actions`. The booking side is `src/services/scheduling/prospect-channel.ts`: both Cal.com receivers await its step, bounded at 8 s, after a lifecycle create committed, and its outcome never changes their reply.
@@ -246,7 +247,13 @@ sweep's own DB constraint (never a caller-side lock).
246
247
  - Don't bundle `apps/api` (esbuild, rollup, webpack). Slice specifiers cannot survive it — see `## Deploy path`.
247
248
  - Don't construct Fastify with `logger: true` or any `logger:` option. Pass `loggerInstance` built from `createLogger` in `@working-theory/observability` (see `packages/api/src/server.ts`). Fastify's own pino carries none of the redaction.
248
249
 
249
- Last updated: 2026-11-19 — #11953: a bullet for `GET`/`PUT /v1/workspaces/:workspaceId/agent-tools` — verified against `packages-paid/api-workspace/src/routes/workspaces/agent-tools.ts`, `packages/api/src/services/agent-tool-state.ts` and `packages/api/src/services/agent-tool-switches.ts`.
250
+ Last updated: 2026-11-20 — #12009 U2: plugin-checkout's workspace check fails closed (`503 entitlement_unavailable`); the `/v1/billing` bullet names `bought` from the purchase record and the registered grant writer behind `forSale`, `POST /v1/billing/plugin-checkout` with its check order, and the webhook's plugin path — verified against `packages-paid/api-multi-tenant/src/routes/billing/{read,plugin-billing,plugin-checkout}.ts`, `packages/api/src/services/plugin-purchases.ts` and `packages/api/src/routes/webhooks/stripe.ts`.
251
+
252
+ Prior: 2026-11-20 — #12009: the `/v1/billing` bullet names the owner's `plugins` rows under `?include=billing`, their fields and the catalogue read behind `prices` — verified against `packages-paid/api-multi-tenant/src/routes/billing/{read,plugin-billing}.ts` and `packages/api/src/services/entitlements.ts`.
253
+
254
+ Prior: 2026-11-19 — #11977: the meetings bullet — `GET /v1/schedule/meetings` and `list_meetings` answer the public meetings only, for every caller, and `GET /v1/schedule/meeting-pages` is the booking pages' read with the private rows kept, no MCP tool by decision; the meeting-types bullet names the pages' new read — verified against `packages-paid/api-scheduling/src/routes/schedule/index.ts`, `packages-paid/api-scheduling/src/services/scheduling/meetings.ts` and `tests/parity/README.md`.
255
+
256
+ Prior: 2026-11-19 — #11953: a bullet for `GET`/`PUT /v1/workspaces/:workspaceId/agent-tools` — verified against `packages-paid/api-workspace/src/routes/workspaces/agent-tools.ts`, `packages/api/src/services/agent-tool-state.ts` and `packages/api/src/services/agent-tool-switches.ts`.
250
257
 
251
258
  Prior: 2026-11-17 — #11882: both open routes take the query key `as` in place of `form`, which stays their old name for one release; `as` and `form` sent with different values are `422 invalid` at `as` — verified against `packages/validation/src/schemas/content-draft.ts` and `packages-paid/api-content-write/src/routes/workspaces/content.ts`.
252
259
 
@@ -127,6 +127,17 @@ export const prisma = {
127
127
  // atomicity test load-bearing rather than an API-shape check.
128
128
  updateMany: jest.fn(),
129
129
  },
130
+ // #12009 D7 — the hub's plugin purchase record, written and read only by
131
+ // services/plugin-purchases.ts. Bare `jest.fn()`s: an unprogrammed
132
+ // `findUnique` answers `undefined`, which that file reads as no row, so a
133
+ // webhook suite that never records a purchase reaches no grant.
134
+ pluginPurchase: {
135
+ create: jest.fn(),
136
+ findUnique: jest.fn(),
137
+ findMany: jest.fn(),
138
+ update: jest.fn(),
139
+ updateMany: jest.fn(),
140
+ },
130
141
  workspace: {
131
142
  // #6335 — NO default implementation, deliberately. Until this issue the
132
143
  // delegate carried a PERMISSIVE one (#6203): it resolved ANY requested
@@ -105,6 +105,14 @@ MCP_ABUSE_BLOCKED_USER_AGENTS=
105
105
  # Required ONLY on a hub's CONTENT_ADAPTER=database — never on a spoke.
106
106
  # DATABASE_URL=
107
107
 
108
+ # ── STEALTH ──────────────────────────────────────────────────────────────────
109
+
110
+ # Optional. Set to "true" on this server's own hosting project to keep its
111
+ # anonymous path refusing every caller (404), whatever the owner's Site
112
+ # visibility switch says (#11978). Same values as the website's STEALTH: true,
113
+ # 1, yes or on; false, 0, no, off or empty. Any other value fails the boot.
114
+ # STEALTH=
115
+
108
116
  # ── Spoke key ─────────────────────────────────────────────────────────────────
109
117
 
110
118
  # SPOKE (server-only). The key the hub's `spokes register` printed. Sent as
@@ -65,6 +65,15 @@ now mean `packages/mcp-server/src/<file>`.
65
65
  reader's 15-second shared answer; a failed read keeps the last answer, then on.
66
66
  `/mcp/workspace`, its protected-resource metadata and stdio are untouched. A hub's own tool
67
67
  server needs the hub site's `AILK_SPOKE_KEY`, or its hub refuses the read and the server stays on.
68
+ The switch is the Admin's **Site visibility** (Live or Hidden, #11978). `STEALTH` on this
69
+ server's own hosting project (read once through `parseStealth`, `@working-theory/web-i18n/stealth`;
70
+ an unknown value fails the boot) makes `discoverable` answer false with no hub read — the website's
71
+ STEALTH cannot reach this hosting project, so a hidden site sets it on both.
72
+ - **The installed capability (#11978 D4).** `createMcpServer()` names the loaded packs' tool names —
73
+ gated ones included — under `capabilities.experimental["ailk/installed"].tools` in every
74
+ `initialize` answer (`mcpInstalledTools()`, `lib/public-agent-tools.ts`). The website's
75
+ `GET /api/site-status` reads it so the Admin's Installed column can tell an absent pack from one
76
+ the hub gates off. It names the build's module set, never a workspace's data.
68
77
  - **Content root.** Every content tool and `audit` take their root from `mcpContentRoot()`
69
78
  (`lib/content-adapter.ts`): `AILK_CONTENT_ROOT`, else `<cwd>/content`, else
70
79
  `<cwd>/../../content`. Never build a content path from `process.cwd()` in a tool — the one
@@ -131,7 +140,7 @@ Every tool maps 1:1 to an `apps/api` endpoint. When you change a tool, change th
131
140
  **Conversion-write (3):** `capture_lead`, `subscribe_newsletter`, `request_callback` — each takes the body its `POST /v1/leads/{submit,subscribe,callback}` route parses (`leadSubmitBodySchema`: `source`, `email`, `consent`, `payload`; `leadSubscribeBodySchema`: `email`, `source`; `leadCallbackBodySchema`: `name`, `phone`, `preferredTime`, `payload`) and returns the route's 201 body `{ id, persisted, email }` unchanged (#7171, #7172, #7173 — the operator's decision of 2026-10-19), so the parity guard holds the three as `twin`s. `source` is the agent's to choose — `mcp` unless the operator says otherwise — and a consent-bearing source needs `consent: true`, exactly as a form does; `capture_lead` still spreads the spoke marker `payload.site` from `AILK_LEAD_SITE` last. The AbuseGuard reads the first two's `email` at the top level, else inside `payload` (the route lifts it from there), so a malformed address is refused wherever it sits
132
141
  **Maintenance (2):** `audit`, `create_project` (stdio only, #9965 D13)
133
142
  **Flow (3):** `list_flows`, `get_flow`, `submit_flow_step` — `list_flows` (#11954) twins `GET /v1/flows`: it takes no argument and returns each live visitor magnet's slug, kind, title and purpose line, so an agent learns a slug before `get_flow`. All three are module-gated (`module: "signal-collectors"`, D-48, #5366) and licence-feature-tagged (`feature: "flows-deliverables"`, #7136): identity-blind like every tool in this list, registered only when its pack is installed and the hub's `GET /v1/content/agent-tools` answers `signal-collectors` licensed, ready (a live visitor magnet) and on (#11950), and gated on the deployment's `flows-deliverables` licence feature under `MCP_FEATURE_GATE_MODE`, the same shape Booking below has. `submit_flow_step` takes the HTTP write branch (its own daily cap, `MCP_ABUSE_SUBMIT_FLOW_STEP_DAILY_CAP`, default 50 — #8071)
134
- **Booking (4):** `list_availability`, `get_event_meta`, `list_meetings`, `create_booking` — module-gated (`module: "scheduling"`: registered only when its pack is installed and the hub answers `scheduling` licensed, ready — a connected calendar — and on, #11950) and licence-feature-tagged (`feature: "scheduling"`, #7136), gated on the deployment's `scheduling` licence feature under `MCP_FEATURE_GATE_MODE`. `create_booking` takes the HTTP write branch (its own daily cap, `MCP_ABUSE_CREATE_BOOKING_DAILY_CAP`, default 20, and an `attendee.email` format check — #8071). `list_meetings` (#8843 D5) twins `GET /v1/schedule/meetings`: it takes no argument and returns the site's Live meetings — slug, visibility, position and whether each can be booked, plus a bookable one's calLink, title, length, description and price; `private` means unlisted, not secret
143
+ **Booking (4):** `list_availability`, `get_event_meta`, `list_meetings`, `create_booking` — module-gated (`module: "scheduling"`: registered only when its pack is installed and the hub answers `scheduling` licensed, ready — a connected calendar — and on, #11950) and licence-feature-tagged (`feature: "scheduling"`, #7136), gated on the deployment's `scheduling` licence feature under `MCP_FEATURE_GATE_MODE`. `create_booking` takes the HTTP write branch (its own daily cap, `MCP_ABUSE_CREATE_BOOKING_DAILY_CAP`, default 20, and an `attendee.email` format check — #8071). `list_meetings` (#8843 D5) twins `GET /v1/schedule/meetings`: it takes no argument and returns the site's public Live meetings — the ones its `/meet` page lists — slug, visibility, position and whether each can be booked, plus a bookable one's calLink, title, length, description and price; since #11977 (amending #8843 D2 for the list) a meeting the owner keeps unlisted is left out for every caller, and its calLink still works with `get_event_meta`, `list_availability` and `create_booking`; `private` means unlisted, not secret
135
144
  **Redirect (1):** `get_redirect` (#10202 D8) — module-gated (`module: "content-write"`: registered only when its pack is installed and the hub answers `content-write` licensed — its redirect route served — and on, #11950) and licence-feature-tagged (`feature: "workspace"`, the content-write claim), gated on the deployment's `workspace` licence feature under `MCP_FEATURE_GATE_MODE`. It twins `GET /v1/redirects`: given an old site path (and an optional locale) it returns where the site permanently redirects it — `{ from, to, permanent: true }` — or the route's not-found body. Its handler rides `@working-theory/mcp-workspace`'s anonymous `tools` (`redirect.ts`), the pack the `workspace` and `multi-tenant` modules carry, and calls the module-level `apiClient` with no agent key
136
145
 
137
146
  ### Why the parity test counts 23 and a keyless server registers 21 (22 over stdio once Free is released)
@@ -153,8 +162,11 @@ Every tool maps 1:1 to an `apps/api` endpoint. When you change a tool, change th
153
162
  stdio (the transport filter, #9965 D13), minus `OSS_DISABLED_TOOLS`
154
163
  (now empty), minus module-gated tools not served from state (#11950: the
155
164
  tool's pack is installed and the hub's `GET /v1/content/agent-tools` answers
156
- its capability licensed, ready and on — read at boot and every
157
- `MCP_CLAIM_REFRESH_MS` by `lib/public-agent-tools.ts`, failing closed;
165
+ its capability licensed, ready and on — read at boot, every
166
+ `MCP_CLAIM_REFRESH_MS` and on a `POST /mcp` that finds the memo stale, by
167
+ `lib/public-agent-tools.ts`; a failed read keeps the last good answer for
168
+ up to `MCP_CLAIM_REFRESH_MS` plus one minute, and with none no module tool
169
+ is listed;
158
170
  `AILK_ENABLED_MODULES` gates `/mcp/workspace` only), minus any
159
171
  `addon`-tagged tool whose claim this deployment does not hold.
160
172
  `start_purchase` carries `addon: "commerce"`, so it is the one entry whose
@@ -192,7 +204,7 @@ here. Spec: `docs/specs/3591-tenant-scoped-agent-auth-secure-spec.md` D13–D16.
192
204
  - **apps/mcp checks only the key's shape.** The key is attached as the SDK's `req.auth` for that
193
205
  request alone and reaches a tool as `extra.authInfo.token`. apps/api is the one place it is
194
206
  checked, and its tenant guard and the caller's clamped role decide every answer.
195
- - **Eighty-seven tools (eighty-four plus three deprecated aliases), each a `twin`.** The catalog rows carry `surface: "workspace"`, `tier: "pro"`
207
+ - **Ninety tools (eighty-seven plus three deprecated aliases), each a `twin`.** The catalog rows carry `surface: "workspace"`, `tier: "pro"`
196
208
  and `modulesAnyOf` (the modules any one of which registers the tool — its twin route's gate):
197
209
  `get_agent_context`, (#9683) `get_workspace_knowledge` — twin of `GET
198
210
  /v1/workspaces/:workspaceId/knowledge`: the business's shown offerings, live magnets, listed
@@ -214,7 +226,7 @@ here. Spec: `docs/specs/3591-tenant-scoped-agent-auth-secure-spec.md` D13–D16.
214
226
  tools, `list_proposals` and `create_proposal`, twinning `GET`/`POST
215
227
  /v1/workspaces/:workspaceId/people/:personId/proposals` with the same grant: a proposal is
216
228
  private to one client, `payments` says whether approval leads to a Stripe page, and an agent's
217
- price is refused `proposal_needs_person` (a person prices) — and (#10957) `send_person_message`, twinning `POST …/people/:personId/messages`: one message on a client's member feed, saved then emailed (an agent's only to a proved address), needing `inbox-act` with `people-read` or `member-pieces-manage`, and `assets-write` for a file; the operator's message list has no tool, by decision — and (#9681) the four person-thread tools, `get_person_thread`, `set_person_thread_state`, `list_external_threads` and `add_external_thread`, twinning `GET`/`PATCH …/people/:personId/thread` and `GET`/`POST …/people/:personId/external-threads`: a client's whole thread page by page with its read/archived/resolved state, and pointers to email and Slack threads (never message text); reading needs the `people-read` grant, writing also `inbox-act`, and the client erasure route has no tool, by decision — and (#9682) the three person-memory tools, `list_person_memories`, `get_person_memory` and `propose_person_memory`, twinning `GET …/people/:personId/memories`, `GET …/memories/:path` and `POST …/memories`: an agent reads only live, unexpired memories (confirmed by a person, read within 180 days) and its proposal is never live — a new path is a draft, a confirmed one gets a pending version — needing the `people-read` or `people-memory-propose` grant to read and `people-memory-propose` to propose; the six person-only memory routes (edit, delete, confirm, redact, the versions list, restore) have no tool, by decision — and (#9749) `get_slack_connection_status`, twin of `GET /v1/workspaces/:workspaceId/slack-connection` (registered with `workspace`/`multi-tenant`, its route's `TENANCY` row: whether the Organization's Slack is connected, its team name and the date, never a credential; connect and disconnect are a person's act and have no tool, by decision), and `get_prospect_channel_settings` / `set_prospect_channel_settings`, twins of `GET`/`PUT …/prospect-channel` (registered with `scheduling`, their routes' module): the update replaces every field, needs the `meeting-types-manage` grant, is refused `slack_not_connected` while the Organization has no Slack connection, and an agent may change only `enabled`, `channelPrefix` and `archiveDays` — a change to `memberIds` or `welcomeTemplate` is refused `prospect_channel_needs_person` — and (#10950) the three meeting tools, `list_meeting_types`, `save_meeting_types` and `list_appointments`, twinning `GET`/`PUT …/meetings` and `GET /v1/schedule/appointments` (registered with `scheduling`): the meeting types from the connected calendar, each with whether it is Live (`enabled`) and who can book it (`visibility`: `public`, `private` or `authenticated`), the provider's `providerEventTypeId` and `createdAt` when it serves them, and, with the `meeting-types-manage` grant, `providerEditUrl` — the read takes no `include` (#11122 D4); the save needs that grant and its required `enabledSlugs` replaces the Live list, while `customerSlugs` (Authenticated) and `privateSlugs` (Private) are exclusive — a slug in both is refused — and an omitted one keeps the stored list less the sent list's slugs, and no price is set there; the appointments read is every role's, and an agent's only with the `people-read` grant (#10986), takes `eventTypeId` for one type's bookings (#11122 D12) and `workspaceId` when the connection reaches several workspaces (#11753), and its attendee names and emails are public-written text; the three scheduling-connection routes have no tool, by decision — and (#10218) the content-suggestion pair, `draft_page_suggestions` and `decide_page_suggestion` — and (#10336) the draft pair, `save_draft` and `read_report`, twinning `PATCH`/`GET …/content/:type/:slug` with the `content-edit` grant: `save_draft` takes the page's `content` whole as the PATCH body and its `version` as `X-Draft-Version`, writes a draft version that never goes live, and answers 409 `conflict` with `currentVersion` when the draft moved; `read_report` returns the draft tip, the version a save must send, the page's stored layout (`structure`, #10962) and the token `save_structure` must send, its open suggestions and the route's check report (`ready`, `needs repair` or `needs your words`), computed by the route and never by the tool — and (#10956) `create_page`, twinning `POST …/content` with the `content-edit` grant: it creates a page and its first draft from `content` sent whole (its `type` and `slug` are the address) — a page type laid out in sections sent no words (no body, an empty one, or only its template's headings) starts from its template (#11793): the hub lays out the template's sections, each headed by its default headline with an empty field to write under, and stores the words and the layout together, refusing a title or description the words rules refuse, or a `sections` key, 422 `invalid` — never publishes, and answers 409 `conflict` when the page exists and 409 `slug_taken` when another page holds the link — and (#11791) `save_page`, twinning `PUT …/content/:type/:slug` with the `content-edit` grant, under the common names of `docs/internal/decisions/one-way-common-names.md`: it saves a page laid out in sections — its `fields` and its `words` (its sections in order, each `{ id, type, data }`) — in one draft version that holds the body the hub builds from the words and the layout together; `address` (type, slug, locale) rides the URL, and `version` with `structureToken` is what the save was based on, both `null` for a new page; a save whose basis is no longer the tip, or `null` for a page that exists, answers 409 `stale` with `currentVersion` and `currentStructureToken`, and a wrong field or word 422 `invalid` with `issues` (`path`, `message`), the one refusal pair whose details reach the tool; it never publishes; since #11811 it also saves an editorial page, whose `words` are `{ body }`, its Markdown, carrying the stored layout forward; since #11808 (#11852) a page laid out in sections may send `workingCopy`, `{ document, settings }` — the two tabs of a working copy as exported — in place of `fields` and `words`: the hub converts it against the tip it was based on (409 `stale` before converting), keeps the stored fields a Settings table cannot carry, refuses a wrong copy 422 `invalid` at `workingCopy.settings`, `workingCopy.document` or the envelope path, and answers the page as a working copy — and (#11811) `save_document`, twinning `POST …/documents/save` with the `content-edit` grant: it saves a `Document` (Instructions, Knowledge or a plugin-owned document) in the same common shape — `address` (`type` always `Document`, slug, locale) rides the body, as `save_asset`'s does, `version` is `null` for a new document, `fields` are the page save's, and `words` is `{ body }`; a moved tip or a `null` on an existing document answers 409 `stale` with `currentVersion` alone, and a wrong field or word — a plugin contract's misfit included, each issue at its path (`fields.contract_version`, `words.body`) — 422 `invalid`, both details rebuilt in `workspace-server.ts`; a document never goes live; since #11808 it takes, at a plugin-owned contract address only, `workingCopy` (`{ document, settings }`, the two tabs of a working copy as exported) in place of `fields` and `words`, which the hub converts against the tip it was based on and answers in the same form (the record form when the copy would outgrow its bounds) — and (#11808) `open_document`, twinning `GET …/documents/open` with the `content-edit` grant: the read twin of `save_document`, its `address` in the query, answering the envelope as the record or, with `as: "working-copy"` and only at a plugin-owned address (else 422 `invalid` at the key sent), the working copy (409 `not_representable` when it would outgrow its bounds); since #11882 `open_page` and `open_document` take `as` where they took `form`, which stays the old name for one release (the catalog keeps it, so the SDK never strips it), and the route refuses the two sent with different values 422 `invalid` at `as`; it never writes, and its `invalid` keeps `issues` (`path`, `message`, each cut to 200 characters). — and (#11809) `open_language_item` and `open_asset` (`mcp-workspace`'s `language.ts` and `library.ts`), twinning `GET …/language/:kind/:slug/open` and `GET …/assets/open` under the gate of the read each parallels (`docs-read`, `assets-read`): each takes `{ workspaceId, address }` (plus `locale` for an item) and answers the thing in the common envelope with the `version` its save takes, or — nothing at the address, or nothing the caller may read there — an item's blank, `version: null` and its kind's empty words, which the save with `version: null` starts; a file is never blank (`404 not_found`); and `open_page` and `open_document` answer the same kind of blank where they answered 404 — a page its template's starting sections, headed by the slug, and a document at a plugin-owned contract address its contract's constant fields and required headings, else nothing; no open writes, and the section map lists `open_` tools as reads. While both ways live, `create_page`, `save_draft` and `save_structure` open their descriptions with a deprecation naming `save_page` or `save_document`; nothing else about them changes until the removal (#11811 D2, D6) — and (#10661) `publish_draft`, twinning `POST …/content/:type/:slug/publish` with the `content-publish` grant: it publishes the draft tip (or a named version) exactly as a person holding that permission does, an agent without the grant is refused 403 `agent_refused` before anything is read, and it never widens Audience or re-enables a doc — and (#10345) the knowledge-base pair, `read_knowledge` and `read_knowledge_doc`, twinning `GET …/knowledge-base` and `GET …/knowledge-base/:type/:slug` with no grant (`docs-read` is every role's): the docs a named member may read (`userId`, by default the agent's own person), at the lower of the agent's person's role and that member's, so naming someone only narrows; Live does not gate them and a disabled doc never appears; `filter: "workspace-memory"` answers the always-loaded set with its `totalTokens` and an 8000-token `warning` — and (#10951) `get_workspace_settings`, twin of `GET /v1/workspaces/:workspaceId/general` (`mcp-workspace`'s `workspace_settings.ts`, no grant): the workspace's name, its own logo (`null` when the organization's applies) and the deployment's deliverable sender (`null` when none is configured, so a magnet's results and completion emails do not go out); the PUT, which renames the workspace and sets its logo, has no tool, by decision — it needs `workspace-settings`, which is never agent-grantable — and (#11806) `get_workspace_overview`, twin of `GET /v1/workspaces/:workspaceId/overview` (`mcp-workspace`'s `workspace_overview.ts`, registered with `workspace` or `multi-tenant`, `gate: "tenant"`, no query): a command's starting picture in one call — the site identity's name and SEO description, the default locale, the Knowledge docs `read_knowledge` lists for the caller with each one's draft `version` where `read_report` would answer it (`content-edit`, and the caller's own role reads the doc), and the Language items by kind and the magnets by state (`draft` only with `magnets-manage`); a part the caller's grants or the site's modules do not allow is `null` or left out and named in `withheld` (`grant` or `module`), never a refusal of the read — and the six site-profile tools, `get_site_identity`, `set_site_identity`, `get_site_seo`, `set_site_seo`, `get_welcome_email` and `set_welcome_email` (`mcp-workspace`'s `site_profile.ts`), twinning `GET`/`PUT …/identity`, `…/seo` and `…/welcome-email`: any member reads; each write needs the `site-profile` grant (`ailk:site-profile`), under which every logo and every SEO field but the description — robots and indexing above all — must be sent as read, else `site_profile_field_locked`; the theme pair has no tool, by decision — and (#10733, issue 10905, #10952) the six Language tools, `list_language_items`, `get_language_item`, `save_language_item`, `set_language_item_live`, `list_language_item_pages` and `get_topic_brief`, twinning `GET …/language`, `GET`/`PUT …/language/:kind/:slug`, `POST …/language/:kind/:slug/live`, `GET …/language/:kind/:slug/appears-on` and `GET …/language/topic/:slug/brief` (`mcp-workspace`'s `language.ts`): a workspace's glossary terms, FAQs and topics; reading needs no grant, saving the `content-edit` grant (`version: null` creates, a tip id updates, 409 `slug_taken` / `stale` otherwise), the Live switch `content-publish` with the `version` the person reviewed — `live: false` is how an agent takes an item off the site; the `DELETE` has no tool, by decision (#11802): it is permanent (nothing restores the item and its slug stays taken), so a person deletes in the Admin and the route refuses every agent `agent_refused`; tags are the hub's and never written by a tool; a topic is a keyword cluster for agents and is never shown to visitors, and `get_topic_brief` reads it as a writing brief — its kept rows scored best bets first, from the Live version when Live; the Topic's Keyword Planner import and the value-thresholds pair are a person's and have no tool, by decision — and (#10948) the three magnet tools, `list_magnets`, `get_magnet` and `save_magnet`, twinning `GET …/magnets`, `GET …/magnets/:id` and (#11810) `POST …/magnets/save` (`mcp-workspace`'s `magnets.ts`, registered with `multi-tenant` or `signal-collectors`): with the `magnets-manage` grant every magnet in full, without it only live ones as `{ id, slug, kind, title, landingPage, tags }`; `save_magnet` takes the save body whole, the magnet's `id` in it, so going live is `status: "live"` and the route alone refuses it (`402 plan_required`, `409 conversion_needs_email`), and an agent cannot set or change what a magnet charges (`403 magnet_pricing_needs_person`); with no `id` and `version: null` it creates a draft magnet — a slug another magnet holds is `409 stale` with its `currentVersion`, a slug the site reads by name `409 slug_reserved`, and the plan check is the Admin create's; the Admin's PATCH and create (which refuses every agent `403 agent_refused`) and the four captured-people lists have no tool, by decision — and (#10949) `get_workspace_offerings`, twin of `GET /v1/workspaces/:workspaceId/offerings` (registered with `multi-tenant` alone, its route's module; `mcp-workspace`'s `offerings.ts`): the Offerings tab's view — unavailable with `no_commerce` or `no_connection`, or the Organization's enabled products with this workspace's shown Prices and Recommended — read with no grant; its PUT, which switches a Price on or off, needs `workspace-settings`, which is never agent-grantable, and has no tool, by decision — and the two library reads, `list_workspace_pages` and `list_assets` (`mcp-workspace`'s `library.ts`, registered with `workspace` or `multi-tenant`), twinning `GET …/library/pages` and `GET …/library/assets`: every page with drafts included and its status (`live`, `draft`, or `disabled` — a person editor's alone), needing the `content-edit` grant, and the asset library read-only with each file's whole record (#11801) — its public path, title, description and record version, its size, an image's pixel size as the Admin's Details panel shows it, and its audience — for every role; both filter, page and name the workspace `{ id, name }` they read, and uploading has no tool — and (#11803) `save_asset` (`library.ts`, `gate: { allows: "assets-write" }`), twinning `POST …/assets/save`: it saves a file's title and description — and (#11879) its type, `fields.type`, one of the ten asset types — by its key, based on the record version `list_assets` returned; a stale save is `409 stale` and its tool error carries `details.currentVersion`, a wrong argument `422 invalid` with `details.issues` (`{ path, message }`, at most twenty, each cut to 200 characters, rebuilt in `workspace-server.ts`); it never replaces, renames, re-privacies or deletes a file, and never reaches a private, Knowledge or disabled one — and (#11680) the two site-vocabulary reads, `list_page_types` and `get_tag_vocabulary` (`mcp-workspace`'s `site_vocabulary.ts`, registered with `workspace` or `multi-tenant`, `gate: "tenant"` — any tenant of the workspace, no grant), twinning `GET …/page-types` and `GET …/tag-vocabulary`: the page types this hub's site can serve (the registry filtered by the modules the hub runs), each with its address, whether a site has only one, its template and that template's headings, and the context classes, Knowledge topic tags and status tags, each with what it means and who may set it; both are platform data and read no row; and (#11790) the third, `list_section_types` (same file, registration and gate), twinning `GET …/section-types` with an optional `type`: every section type a page's layout can hold with every field of its data — words or data, the Markdown form, whether it is required and inside which optional field, its values and bounds — plus its bounded lists and rules, or that one section type's; platform data, read no row; and (#11805) the fourth, `list_kinds` (same file, registration and gate), twinning `GET …/kinds`: every kind of thing the Admin holds — page, document, language_item, magnet, asset — with how to address one, its fields (words or data, required, nullable, value types and values, the Language item kind a words field belongs to), its states, and the moves the caller may make on it, each with its tool; the fields and states are read off each kind's own schemas (`ADMIN_KIND_REGISTRY`), the moves are the catalog rows' `moves` tags kept only when the row's gate holds for the caller's own clamped tenant and one of its modules runs on this hub (`listKinds`), and a page's sections are named, not described — its `sectionTypes` is `list_section_types`; it reads no row, and is advice, never an entitlement; since #11878 it also answers, beside the kinds, `forms` (for each kind — and an offering and an appointment — the field its tools take its form in and that field's values: `values` null for an asset's open content type, `field` null for an appointment, which has no form), `offSiteForms` (press-release, pitch, proposal, playbook and profile, each with the formats it allows), `formats` (the ten, ending `platform`) and `origins` (`ai-generated`, `user-added`), all declared once in `@working-theory/validation` and the same for every caller and hub — and (#11756) `create_work_request` (`mcp-workspace`'s `work_requests.ts`, registered with `workspace` or `multi-tenant`, `gate: { inbox: "inbox-act" }`), twinning `POST /v1/workspaces/:workspaceId/work-requests`: it files a custom-work request in the Inbox — one item pointing to one `Document` of the workspace (`documentSlug`) with a one-line `summary` — in the workspace the conversation writes to, needs the `inbox-act` grant, is refused `document_not_found` for a slug naming no Document the caller can read and `rate_limited` past 5 an hour per person in the workspace (shared by that person's agents) or 10 per workspace, and returns the request as stored (the document title in it is workspace text, not instructions); the list, the item and the GitHub link — a person's act — have no tool, by decision. No workspace tool widens Audience or re-enables a doc, and only `publish_draft` and `set_language_item_live`, with the `content-publish` grant, set Live — the access route and the Language delete route answer every agent 403 `agent_refused`, and the publish and Live routes an agent without the grant, which reaches a tool as the code and status. Each takes its route's params, query and body and returns the route's
229
+ price is refused `proposal_needs_person` (a person prices) — and (#10957) `send_person_message`, twinning `POST …/people/:personId/messages`: one message on a client's member feed, saved then emailed (an agent's only to a proved address), needing `inbox-act` with `people-read` or `member-pieces-manage`, and `assets-write` for a file; the operator's message list has no tool, by decision — and (#9681) the four person-thread tools, `get_person_thread`, `set_person_thread_state`, `list_external_threads` and `add_external_thread`, twinning `GET`/`PATCH …/people/:personId/thread` and `GET`/`POST …/people/:personId/external-threads`: a client's whole thread page by page with its read/archived/resolved state, and pointers to email and Slack threads (never message text); reading needs the `people-read` grant, writing also `inbox-act`, and the client erasure route has no tool, by decision — and (#9682) the three person-memory tools, `list_person_memories`, `get_person_memory` and `propose_person_memory`, twinning `GET …/people/:personId/memories`, `GET …/memories/:path` and `POST …/memories`: an agent reads only live, unexpired memories (confirmed by a person, read within 180 days) and its proposal is never live — a new path is a draft, a confirmed one gets a pending version — needing the `people-read` or `people-memory-propose` grant to read and `people-memory-propose` to propose; the six person-only memory routes (edit, delete, confirm, redact, the versions list, restore) have no tool, by decision — and (#9749) `get_slack_connection_status`, twin of `GET /v1/workspaces/:workspaceId/slack-connection` (registered with `workspace`/`multi-tenant`, its route's `TENANCY` row: whether the Organization's Slack is connected, its team name and the date, never a credential; connect and disconnect are a person's act and have no tool, by decision), and `get_prospect_channel_settings` / `set_prospect_channel_settings`, twins of `GET`/`PUT …/prospect-channel` (registered with `scheduling`, their routes' module): the update replaces every field, needs the `meeting-types-manage` grant, is refused `slack_not_connected` while the Organization has no Slack connection, and an agent may change only `enabled`, `channelPrefix` and `archiveDays` — a change to `memberIds` or `welcomeTemplate` is refused `prospect_channel_needs_person` — and (#10950) the three meeting tools, `list_meeting_types`, `save_meeting_types` and `list_appointments`, twinning `GET`/`PUT …/meetings` and `GET /v1/schedule/appointments` (registered with `scheduling`): the meeting types from the connected calendar, each with whether it is Live (`enabled`) and who can book it (`visibility`: `public`, `private` or `authenticated`), the provider's `providerEventTypeId` and `createdAt` when it serves them, and, with the `meeting-types-manage` grant, `providerEditUrl` — the read takes no `include` (#11122 D4); the save needs that grant and its required `enabledSlugs` replaces the Live list, while `customerSlugs` (Authenticated) and `privateSlugs` (Private) are exclusive — a slug in both is refused — and an omitted one keeps the stored list less the sent list's slugs, and no price is set there; the appointments read is every role's, and an agent's only with the `people-read` grant (#10986), takes `eventTypeId` for one type's bookings (#11122 D12) and `workspaceId` when the connection reaches several workspaces (#11753), and its attendee names and emails are public-written text; the three scheduling-connection routes have no tool, by decision — and (#10218) the content-suggestion pair, `draft_page_suggestions` and `decide_page_suggestion` — and (#10336) the draft pair, `save_draft` and `read_report`, twinning `PATCH`/`GET …/content/:type/:slug` with the `content-edit` grant: `save_draft` takes the page's `content` whole as the PATCH body and its `version` as `X-Draft-Version`, writes a draft version that never goes live, and answers 409 `conflict` with `currentVersion` when the draft moved; `read_report` returns the draft tip, the version a save must send, the page's stored layout (`structure`, #10962) and the token `save_structure` must send, its open suggestions and the route's check report (`ready`, `needs repair` or `needs your words`), computed by the route and never by the tool — and (#10956) `create_page`, twinning `POST …/content` with the `content-edit` grant: it creates a page and its first draft from `content` sent whole (its `type` and `slug` are the address) — a page type laid out in sections sent no words (no body, an empty one, or only its template's headings) starts from its template (#11793): the hub lays out the template's sections, each headed by its default headline with an empty field to write under, and stores the words and the layout together, refusing a title or description the words rules refuse, or a `sections` key, 422 `invalid` — never publishes, and answers 409 `conflict` when the page exists and 409 `slug_taken` when another page holds the link — and (#11791) `save_page`, twinning `PUT …/content/:type/:slug` with the `content-edit` grant, under the common names of `docs/internal/decisions/one-way-common-names.md`: it saves a page laid out in sections — its `fields` and its `words` (its sections in order, each `{ id, type, data }`) — in one draft version that holds the body the hub builds from the words and the layout together; `address` (type, slug, locale) rides the URL, and `version` with `structureToken` is what the save was based on, both `null` for a new page; a save whose basis is no longer the tip, or `null` for a page that exists, answers 409 `stale` with `currentVersion` and `currentStructureToken`, and a wrong field or word 422 `invalid` with `issues` (`path`, `message`), the one refusal pair whose details reach the tool; it never publishes; since #11811 it also saves an editorial page, whose `words` are `{ body }`, its Markdown, carrying the stored layout forward; since #11808 (#11852) a page laid out in sections may send `workingCopy`, `{ document, settings }` — the two tabs of a working copy as exported — in place of `fields` and `words`: the hub converts it against the tip it was based on (409 `stale` before converting), keeps the stored fields a Settings table cannot carry, refuses a wrong copy 422 `invalid` at `workingCopy.settings`, `workingCopy.document` or the envelope path, and answers the page as a working copy — and (#11811) `save_document`, twinning `POST …/documents/save` with the `content-edit` grant: it saves a `Document` (Instructions, Knowledge or a plugin-owned document) in the same common shape — `address` (`type` always `Document`, slug, locale) rides the body, as `save_asset`'s does, `version` is `null` for a new document, `fields` are the page save's, and `words` is `{ body }`; a moved tip or a `null` on an existing document answers 409 `stale` with `currentVersion` alone, and a wrong field or word — a plugin contract's misfit included, each issue at its path (`fields.contract_version`, `words.body`) — 422 `invalid`, both details rebuilt in `workspace-server.ts`; a document never goes live; since #11808 it takes, at a plugin-owned contract address only, `workingCopy` (`{ document, settings }`, the two tabs of a working copy as exported) in place of `fields` and `words`, which the hub converts against the tip it was based on and answers in the same form (the record form when the copy would outgrow its bounds) — and (#11808) `open_document`, twinning `GET …/documents/open` with the `content-edit` grant: the read twin of `save_document`, its `address` in the query, answering the envelope as the record or, with `as: "working-copy"` and only at a plugin-owned address (else 422 `invalid` at the key sent), the working copy (409 `not_representable` when it would outgrow its bounds); since #11882 `open_page` and `open_document` take `as` where they took `form`, which stays the old name for one release (the catalog keeps it, so the SDK never strips it), and the route refuses the two sent with different values 422 `invalid` at `as`; it never writes, and its `invalid` keeps `issues` (`path`, `message`, each cut to 200 characters). — and (#11809) `open_language_item` and `open_asset` (`mcp-workspace`'s `language.ts` and `library.ts`), twinning `GET …/language/:kind/:slug/open` and `GET …/assets/open` under the gate of the read each parallels (`docs-read`, `assets-read`): each takes `{ workspaceId, address }` (plus `locale` for an item) and answers the thing in the common envelope with the `version` its save takes, or — nothing at the address, or nothing the caller may read there — an item's blank, `version: null` and its kind's empty words, which the save with `version: null` starts; a file is never blank (`404 not_found`); and `open_page` and `open_document` answer the same kind of blank where they answered 404 — a page its template's starting sections, headed by the slug, and a document at a plugin-owned contract address its contract's constant fields and required headings, else nothing; no open writes, and the section map lists `open_` tools as reads. While both ways live, `create_page`, `save_draft` and `save_structure` open their descriptions with a deprecation naming `save_page` or `save_document`; nothing else about them changes until the removal (#11811 D2, D6) — and (#10661) `publish_draft`, twinning `POST …/content/:type/:slug/publish` with the `content-publish` grant: it publishes the draft tip (or a named version) exactly as a person holding that permission does, an agent without the grant is refused 403 `agent_refused` before anything is read, and it never widens Audience or re-enables a doc — and (#10345) the knowledge-base pair, `read_knowledge` and `read_knowledge_doc`, twinning `GET …/knowledge-base` and `GET …/knowledge-base/:type/:slug` with no grant (`docs-read` is every role's): the docs a named member may read (`userId`, by default the agent's own person), at the lower of the agent's person's role and that member's, so naming someone only narrows; Live does not gate them and a disabled doc never appears; `filter: "workspace-memory"` answers the always-loaded set with its `totalTokens` and an 8000-token `warning` — and (#10951) `get_workspace_settings`, twin of `GET /v1/workspaces/:workspaceId/general` (`mcp-workspace`'s `workspace_settings.ts`, no grant): the workspace's name, its own logo (`null` when the organization's applies) and the deployment's deliverable sender (`null` when none is configured, so a magnet's results and completion emails do not go out); the PUT, which renames the workspace and sets its logo, has no tool, by decision — it needs `workspace-settings`, which is never agent-grantable — and (#11806) `get_workspace_overview`, twin of `GET /v1/workspaces/:workspaceId/overview` (`mcp-workspace`'s `workspace_overview.ts`, registered with `workspace` or `multi-tenant`, `gate: "tenant"`, no query): a command's starting picture in one call — the site identity's name and SEO description, the default locale, the Knowledge docs `read_knowledge` lists for the caller with each one's draft `version` where `read_report` would answer it (`content-edit`, and the caller's own role reads the doc), and the Language items by kind and the magnets by state (`draft` only with `magnets-manage`); a part the caller's grants or the site's modules do not allow is `null` or left out and named in `withheld` (`grant` or `module`), never a refusal of the read — and (#12015) `get_command_craft`, twin of `GET /v1/workspaces/:workspaceId/craft/:command` (`mcp-workspace`'s `command_craft.ts`, registered with `workspace` or `multi-tenant`, `gate: "tenant"`): one command's craft for the session, `{ command, pack, minShellVersion, craft }`, served only to a workspace that has the command's pack; a `pack_required` refusal carries `details` rebuilt from `pack`, `name` and `where` alone, and a `craft_unavailable` carries `service` alone (`entitlements`, `delivery` or `null`) — and the six site-profile tools, `get_site_identity`, `set_site_identity`, `get_site_seo`, `set_site_seo`, `get_welcome_email` and `set_welcome_email` (`mcp-workspace`'s `site_profile.ts`), twinning `GET`/`PUT …/identity`, `…/seo` and `…/welcome-email`: any member reads; each write needs the `site-profile` grant (`ailk:site-profile`), under which every logo and every SEO field but the description — robots and indexing above all — must be sent as read, else `site_profile_field_locked`; the theme pair has no tool, by decision — and (#10733, issue 10905, #10952) the six Language tools, `list_language_items`, `get_language_item`, `save_language_item`, `set_language_item_live`, `list_language_item_pages` and `get_topic_brief`, twinning `GET …/language`, `GET`/`PUT …/language/:kind/:slug`, `POST …/language/:kind/:slug/live`, `GET …/language/:kind/:slug/appears-on` and `GET …/language/topic/:slug/brief` (`mcp-workspace`'s `language.ts`): a workspace's glossary terms, FAQs and topics; reading needs no grant, saving the `content-edit` grant (`version: null` creates, a tip id updates, 409 `slug_taken` / `stale` otherwise), the Live switch `content-publish` with the `version` the person reviewed — `live: false` is how an agent takes an item off the site; the `DELETE` has no tool, by decision (#11802): it is permanent (nothing restores the item and its slug stays taken), so a person deletes in the Admin and the route refuses every agent `agent_refused`; tags are the hub's and never written by a tool; a topic is a keyword cluster for agents and is never shown to visitors, and `get_topic_brief` reads it as a writing brief — its kept rows scored best bets first, from the Live version when Live; the Topic's Keyword Planner import and the value-thresholds pair are a person's and have no tool, by decision — and (#10948) the three magnet tools, `list_magnets`, `get_magnet` and `save_magnet`, twinning `GET …/magnets`, `GET …/magnets/:id` and (#11810) `POST …/magnets/save` (`mcp-workspace`'s `magnets.ts`, registered with `multi-tenant` or `signal-collectors`): with the `magnets-manage` grant every magnet in full, without it only live ones as `{ id, slug, kind, title, landingPage, tags }`; `save_magnet` takes the save body whole, the magnet's `id` in it, so going live is `status: "live"` and the route alone refuses it (`402 plan_required`, `409 conversion_needs_email`), and an agent cannot set or change what a magnet charges (`403 magnet_pricing_needs_person`); with no `id` and `version: null` it creates a draft magnet — a slug another magnet holds is `409 stale` with its `currentVersion`, a slug the site reads by name `409 slug_reserved`, and the plan check is the Admin create's; the Admin's PATCH and create (which refuses every agent `403 agent_refused`) and the four captured-people lists have no tool, by decision — and (#10949) `get_workspace_offerings`, twin of `GET /v1/workspaces/:workspaceId/offerings` (registered with `multi-tenant` alone, its route's module; `mcp-workspace`'s `offerings.ts`): the Offerings tab's view — unavailable with `no_commerce` or `no_connection`, or the Organization's enabled products with this workspace's shown Prices and Recommended — read with no grant; its PUT, which switches a Price on or off, needs `workspace-settings`, which is never agent-grantable, and has no tool, by decision — and the two library reads, `list_workspace_pages` and `list_assets` (`mcp-workspace`'s `library.ts`, registered with `workspace` or `multi-tenant`), twinning `GET …/library/pages` and `GET …/library/assets`: every page with drafts included and its status (`live`, `draft`, or `disabled` — a person editor's alone), needing the `content-edit` grant, and the asset library read-only with each file's whole record (#11801) — its public path, title, description and record version, its size, an image's pixel size as the Admin's Details panel shows it, and its audience — for every role; both filter, page and name the workspace `{ id, name }` they read, and uploading has no tool — and (#11803) `save_asset` (`library.ts`, `gate: { allows: "assets-write" }`), twinning `POST …/assets/save`: it saves a file's title and description — and (#11879) its type, `fields.type`, one of the ten asset types — by its key, based on the record version `list_assets` returned; a stale save is `409 stale` and its tool error carries `details.currentVersion`, a wrong argument `422 invalid` with `details.issues` (`{ path, message }`, at most twenty, each cut to 200 characters, rebuilt in `workspace-server.ts`); it never replaces, renames, re-privacies or deletes a file, and never reaches a private, Knowledge or disabled one — and (#11680) the two site-vocabulary reads, `list_page_types` and `get_tag_vocabulary` (`mcp-workspace`'s `site_vocabulary.ts`, registered with `workspace` or `multi-tenant`, `gate: "tenant"` — any tenant of the workspace, no grant), twinning `GET …/page-types` and `GET …/tag-vocabulary`: the page types this hub's site can serve (the registry filtered by the modules the hub runs), each with its address, whether a site has only one, its template and that template's headings, and the context classes, Knowledge topic tags and status tags, each with what it means and who may set it; both are platform data and read no row; and (#11790) the third, `list_section_types` (same file, registration and gate), twinning `GET …/section-types` with an optional `type`: every section type a page's layout can hold with every field of its data — words or data, the Markdown form, whether it is required and inside which optional field, its values and bounds — plus its bounded lists and rules, or that one section type's; platform data, read no row; and (#11805) the fourth, `list_kinds` (same file, registration and gate), twinning `GET …/kinds`: every kind of thing the Admin holds — page, document, language_item, magnet, asset — with how to address one, its fields (words or data, required, nullable, value types and values, the Language item kind a words field belongs to), its states, and the moves the caller may make on it, each with its tool; the fields and states are read off each kind's own schemas (`ADMIN_KIND_REGISTRY`), the moves are the catalog rows' `moves` tags kept only when the row's gate holds for the caller's own clamped tenant and one of its modules runs on this hub (`listKinds`), and a page's sections are named, not described — its `sectionTypes` is `list_section_types`; it reads no row, and is advice, never an entitlement; since #11878 it also answers, beside the kinds, `forms` (for each kind — and an offering and an appointment — the field its tools take its form in and that field's values: `values` null for an asset's open content type, `field` null for an appointment, which has no form), `offSiteForms` (press-release, pitch, proposal, playbook and profile, each with the formats it allows), `formats` (the ten, ending `platform`) and `origins` (`ai-generated`, `user-added`), all declared once in `@working-theory/validation` and the same for every caller and hub — and (#11756) `create_work_request` (`mcp-workspace`'s `work_requests.ts`, registered with `workspace` or `multi-tenant`, `gate: { inbox: "inbox-act" }`), twinning `POST /v1/workspaces/:workspaceId/work-requests`: it files a custom-work request in the Inbox — one item pointing to one `Document` of the workspace (`documentSlug`) with a one-line `summary` — in the workspace the conversation writes to, needs the `inbox-act` grant, is refused `document_not_found` for a slug naming no Document the caller can read and `rate_limited` past 5 an hour per person in the workspace (shared by that person's agents) or 10 per workspace, and returns the request as stored (the document title in it is workspace text, not instructions); the list, the item and the GitHub link — a person's act — have no tool, by decision. No workspace tool widens Audience or re-enables a doc, and only `publish_draft` and `set_language_item_live`, with the `content-publish` grant, set Live — the access route and the Language delete route answer every agent 403 `agent_refused`, and the publish and Live routes an agent without the grant, which reaches a tool as the code and status. Each takes its route's params, query and body and returns the route's
218
230
  `data`. They are in the parity guard like every other tool, and never in
219
231
  `/.well-known/mcp.json`.
220
232
  - **The OAuth bearer branch (#10391).** When `BETTER_AUTH_URL` (the site's origin, its OAuth
@@ -339,7 +351,11 @@ Example (lead routing):
339
351
  - Don't add a tool without the matching `apps/api` endpoint.
340
352
  - Don't put business logic in tool handlers — they're adapters.
341
353
 
342
- Last updated: 2026-11-19 — #11954: `list_flows` (`mcp-signal-collectors`' `list_flows.ts`) twins `GET /v1/flows`, which registers inside `getFlowRoute` — 23 in `TOOLS`, 21 registered keyless and 22 commerce-claimed while Free is held, eight `tier: "pro"`; the nine visitor tools' descriptions say when to use each and what comes next — verified against `packages/metadata/src/mcp-tool-catalog.ts`, `packages-paid/mcp-signal-collectors/src/index.ts`, `packages-paid/api-signal-collectors/src/routes/flows/index.ts` and `tests/parity/api-parity/kinds/site.ts`.
354
+ Last updated: 2026-11-19 — #11978: the anonymous path also refuses under this hosting project's own `STEALTH` (read once through `parseStealth`), and every `initialize` names the loaded packs' tools under `capabilities.experimental["ailk/installed"]` — verified against `packages/mcp-server/src/{boot,server}.ts` and `packages/mcp-server/src/lib/public-agent-tools.ts`.
355
+
356
+ Prior: 2026-11-19 — #11977: `list_meetings` returns the site's public meetings only, for every caller; a private meeting stays bookable by its calLink — verified against `packages/metadata/src/mcp-tool-catalog.ts`, `packages-paid/mcp-scheduling/src/list_meetings.ts` and `packages-paid/api-scheduling/src/services/scheduling/meetings.ts`.
357
+
358
+ Prior: 2026-11-19 — #11954: `list_flows` (`mcp-signal-collectors`' `list_flows.ts`) twins `GET /v1/flows`, which registers inside `getFlowRoute` — 23 in `TOOLS`, 21 registered keyless and 22 commerce-claimed while Free is held, eight `tier: "pro"`; the nine visitor tools' descriptions say when to use each and what comes next — verified against `packages/metadata/src/mcp-tool-catalog.ts`, `packages-paid/mcp-signal-collectors/src/index.ts`, `packages-paid/api-signal-collectors/src/routes/flows/index.ts` and `tests/parity/api-parity/kinds/site.ts`.
343
359
 
344
360
  Prior: 2026-11-18 — #11909: `list_kinds` and `GET /v1/workspaces/:workspaceId/kinds` answer ten formats, the tenth `platform`, and five off-site forms, the fifth `profile` (`platform` only), with `proposal` also allowing `platform`; only the two constants change, and the pair stays a twin — verified against `packages/validation/src/contract/admin-kinds.ts`, `packages/metadata/src/mcp-tool-catalog.ts` and `tests/parity/api-parity/fixtures/site-wire.ts`.
345
361
 
@@ -315,7 +315,7 @@ CONTENT_ADAPTER=mdx
315
315
  # =============================================================================
316
316
  # No variable here. /meet, /private and /meet/<slug> read every meeting fact
317
317
  # — which meetings are Live, public or private, their titles, lengths and
318
- # Cal.com links — from apps/api's GET /v1/schedule/meetings, which resolves
318
+ # Cal.com links — from apps/api's GET /v1/schedule/meeting-pages, which resolves
319
319
  # the workspace from this site (the site alias keyless, a spoke by its key)
320
320
  # and composes each Cal.com link from that workspace's own account. The
321
321
  # one-meeting "<owner>/<event-slug>" variable this block used to set is