create-ailk 0.45.0 → 0.46.0
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.
- package/README.md +6 -3
- package/component-catalog.json +24 -1
- package/component-catalog.md +6 -5
- package/dist/lib/env-catalog.js +1 -1
- package/dist/lib/import-mdx.js +10 -2
- package/dist/seed-workspace.d.ts +1 -1
- package/dist/seed-workspace.js +10 -3
- package/dist/surfaces.js +1 -1
- package/package.json +3 -3
- package/templates/apps/api/.env.example +23 -0
- package/templates/apps/api/CLAUDE.md +13 -6
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +11 -0
- package/templates/apps/mcp/.env.example +8 -0
- package/templates/apps/mcp/CLAUDE.md +22 -6
- package/templates/apps/web/.env.example +1 -1
- package/templates/apps/web/CLAUDE.md +47 -16
- package/templates/apps/web/app/.well-known/mcp.json/route.ts +6 -7
- package/templates/apps/web/app/[locale]/layout.tsx +10 -7
- package/templates/apps/web/app/api/site-status/__tests__/route.test.ts +120 -0
- package/templates/apps/web/app/api/site-status/route.ts +62 -0
- package/templates/apps/web/app/llms.txt/route.ts +3 -3
- package/templates/apps/web/app/openapi.json/__tests__/route.test.ts +21 -4
- package/templates/apps/web/app/openapi.json/route.ts +10 -9
- package/templates/apps/web/app/sitemap.xml/route.ts +3 -3
- package/templates/apps/web/auth.ts +25 -1
- package/templates/apps/web/lib/__tests__/fixtures/mcp-stub-server.ts +10 -3
- package/templates/apps/web/lib/__tests__/mcp-served-tools.test.ts +61 -0
- package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +112 -0
- package/templates/apps/web/lib/__tests__/pricing-page.test.ts +280 -0
- package/templates/apps/web/lib/__tests__/site-brand.test.ts +5 -6
- package/templates/apps/web/lib/__tests__/site-visibility.test.ts +64 -0
- package/templates/apps/web/lib/mcp-oauth.ts +64 -0
- package/templates/apps/web/lib/mcp-served-tools.ts +51 -9
- package/templates/apps/web/lib/offerings-pricing.ts +30 -6
- package/templates/apps/web/lib/pricing-page.ts +142 -35
- package/templates/apps/web/lib/site-brand.tsx +1 -7
- package/templates/apps/web/lib/site-visibility.ts +45 -0
- package/templates/apps/web/messages/en.json +8 -0
- package/templates/apps/web/middleware.ts +16 -1
- package/templates/apps/web/src/lib/routes.ts +3 -3
- package/versions.json +51 -51
- package/templates/apps/web/app/.well-known/ai-plugin.json/route.ts +0 -93
package/README.md
CHANGED
|
@@ -797,9 +797,12 @@ AILK_AGENT_KEY=<agent key> create-ailk seed-workspace ./my-site --api-url <api o
|
|
|
797
797
|
and the origin's source, before any request.
|
|
798
798
|
- The agent key is read from `AILK_AGENT_KEY` only — never a flag or a file —
|
|
799
799
|
and never printed. An owner issues it in the Admin with the `content-edit`
|
|
800
|
-
and `content-publish` grants
|
|
801
|
-
the
|
|
802
|
-
|
|
800
|
+
and `content-publish` grants, and the agent's person sets its level to
|
|
801
|
+
Autonomous on the agent's page: below Autonomous an agent does not publish,
|
|
802
|
+
and every new agent starts at Training. After the first refused publish, the
|
|
803
|
+
rest of the pages are saved as drafts and fail `not published`, and the
|
|
804
|
+
report says when the agent's level held it back; a re-run publishes them only
|
|
805
|
+
once the agent is at Autonomous with both grants.
|
|
803
806
|
- Each page prints `created`, `updated`, `unchanged`, `skipped` or `failed`,
|
|
804
807
|
then a count line. A re-run creates nothing and reports every page
|
|
805
808
|
`unchanged`. An agent writes ten times a minute, so a first seed of about
|
package/component-catalog.json
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"importPath": "@working-theory/ui/chrome",
|
|
26
26
|
"rootBarrel": "@working-theory/ui",
|
|
27
27
|
"sourceRoot": "packages/ui/src/chrome",
|
|
28
|
-
"count":
|
|
28
|
+
"count": 20
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
"name": "primitives",
|
|
@@ -2157,6 +2157,17 @@
|
|
|
2157
2157
|
"descriptionGrade": "strong",
|
|
2158
2158
|
"sectionType": null
|
|
2159
2159
|
},
|
|
2160
|
+
{
|
|
2161
|
+
"name": "PricingRail",
|
|
2162
|
+
"tier": "chrome",
|
|
2163
|
+
"sourcePath": "packages/ui/src/chrome/PricingRail.tsx",
|
|
2164
|
+
"importPath": "@working-theory/ui/chrome",
|
|
2165
|
+
"exported": true,
|
|
2166
|
+
"description": "Wraps a pricing page's rendered content and owns its layout region. The current page carries `aria-current=\"page\"` in both. Every string is the caller's (`labels`, the items, the `cta`): no English defaults.",
|
|
2167
|
+
"descriptionSource": "doc-comment",
|
|
2168
|
+
"descriptionGrade": "strong",
|
|
2169
|
+
"sectionType": null
|
|
2170
|
+
},
|
|
2160
2171
|
{
|
|
2161
2172
|
"name": "SectionNav",
|
|
2162
2173
|
"tier": "chrome",
|
|
@@ -7327,6 +7338,15 @@
|
|
|
7327
7338
|
]
|
|
7328
7339
|
}
|
|
7329
7340
|
},
|
|
7341
|
+
"offeringPlans": {
|
|
7342
|
+
"minItems": 1,
|
|
7343
|
+
"maxItems": 12,
|
|
7344
|
+
"type": "array",
|
|
7345
|
+
"items": {
|
|
7346
|
+
"type": "string",
|
|
7347
|
+
"pattern": "^[a-z0-9][a-z0-9-]{0,39}$"
|
|
7348
|
+
}
|
|
7349
|
+
},
|
|
7330
7350
|
"billingToggle": {
|
|
7331
7351
|
"type": "boolean"
|
|
7332
7352
|
},
|
|
@@ -7599,6 +7619,9 @@
|
|
|
7599
7619
|
"qualifier": {
|
|
7600
7620
|
"type": "string"
|
|
7601
7621
|
},
|
|
7622
|
+
"note": {
|
|
7623
|
+
"type": "string"
|
|
7624
|
+
},
|
|
7602
7625
|
"features": {
|
|
7603
7626
|
"type": "array",
|
|
7604
7627
|
"items": {
|
package/component-catalog.md
CHANGED
|
@@ -15,13 +15,13 @@ The component inventory of `@working-theory/ui` and the shells of `@working-theo
|
|
|
15
15
|
3. Check the Primitives, Panels and Shells tables too — a low-level control, a collapsible layout container, or a route-level frame lives there, not under Sections or Blocks.
|
|
16
16
|
4. Only then build. If you do build, you are declaring the capability is genuinely absent.
|
|
17
17
|
|
|
18
|
-
Inventory: **
|
|
18
|
+
Inventory: **332 component files** across 16 tiers — 60 sections, 110 blocks, 20 chrome, 82 primitives, 6 panels, 8 shells, 5 docs-blog-blocks, 1 docs-blog-chrome, 2 docs-blog-shells, 2 scheduling-sections, 6 scheduling-blocks, 5 signal-collectors-sections, 9 signal-collectors-blocks, 2 commerce-sections, 13 commerce-blocks, 1 commerce-panels. 329 distinct names: `SchedulerEmbed`, `Separator`, `Tabs` exist in more than one tier as genuinely different components, listed once per tier with its own source path.
|
|
19
19
|
|
|
20
|
-
Description coverage: **
|
|
20
|
+
Description coverage: **328/332** components carry a capability description derived from source — 45 from the section registry's hand-authored when-to-use text, 248 from the component's own doc-comment header, 35 from its tier barrel's roster line. **4** have none; they are listed under [Undescribed components](#undescribed-components) rather than given a sentence invented from their name.
|
|
21
21
|
|
|
22
|
-
Of those, **
|
|
22
|
+
Of those, **295** are *strong* — a capability sentence you could match a requirement against — and **33** are *weak*: either one short clause, or a long one that spends itself on wiring (client boundaries, class names, which primitives it composes) instead of on what the thing is for. Weak rows are marked `(weak)` and listed in full under [Weak descriptions](#weak-descriptions). Coverage is 99%, but **findable-without-luck coverage is 89%**.
|
|
23
23
|
|
|
24
|
-
Per tier, strong out of total: **Sections** 59/60 · **Blocks** 102/110 · **Chrome**
|
|
24
|
+
Per tier, strong out of total: **Sections** 59/60 · **Blocks** 102/110 · **Chrome** 11/20 · **Primitives** 67/82 (4 undescribed) · **Panels** 6/6 · **Shells** 7/8 · **Docs + Blog Blocks** 5/5 · **Docs + Blog Chrome** 1/1 · **Docs + Blog Shells** 0/2 · **Scheduling Sections** 2/2 · **Scheduling Blocks** 6/6 · **Signal-Collectors Sections** 5/5 · **Signal-Collectors Blocks** 8/9 · **Commerce Sections** 2/2 · **Commerce Blocks** 13/13 · **Commerce Panels** 1/1. A tier low on this line is a tier where a capability search is most likely to come up empty on something that exists.
|
|
25
25
|
|
|
26
26
|
That grade is **mechanical**. It counts what it can measure — how much a description adds beyond the component's own name, how much of it is spent on wiring, whether the extraction came out damaged — and it cannot tell a fluent paragraph about the wrong subject from a useful one. A person reading these tables will find more rows unusable than the weak count admits. Treat it as a floor on the problem, not a measurement of it, and read the source before concluding a capability is absent.
|
|
27
27
|
|
|
@@ -245,7 +245,7 @@ Import: `import { X } from "@working-theory/ui/blocks";` (or from the `@working-
|
|
|
245
245
|
|
|
246
246
|
---
|
|
247
247
|
|
|
248
|
-
## Chrome (
|
|
248
|
+
## Chrome (20)
|
|
249
249
|
|
|
250
250
|
Persistent framing UI that wraps page content — navigation, footers, sidebars, banners. Not MDX-driven.
|
|
251
251
|
|
|
@@ -267,6 +267,7 @@ Import: `import { X } from "@working-theory/ui/chrome";` (or from the `@working-
|
|
|
267
267
|
| `NavMobileMenu` | Client subcomponent for mobile hamburger state. Isolates "use client" to this narrow component so Nav (Server Component) stays clean. Renders a hamburger button + collapsible link list. Closes the menu automatically when the pathname changes (route navigation). *(weak)* | internal — compose from `packages/ui/src/chrome/NavMobileMenu.tsx` |
|
|
268
268
|
| `NavOverflowMenu` | The Nav row's per-breakpoint link-overflow disclosure. The desktop link row never wraps: a fixed per-breakpoint inline-link budget (4 at md, 6 at lg+) is enforced by the caller (Nav), which splits `navItems` into an inline slice and an overflow slice. This component renders ONLY the overflow slice, behind a disclosure trigger, in source order — it never computes the budget itself. | internal — compose from `packages/ui/src/chrome/NavOverflowMenu.tsx` |
|
|
269
269
|
| `NotificationsMenu` | Bell trigger + notifications popover chrome (ploy-capture app-frame). Presentational, props-driven. The unread count and row list arrive entirely via props — this component carries NO fetch/polling logic of its own. Rows are pre-formatted at the call site (relative time, heading, empty copy) per the AILK i18n/formatting convention (design-system-rules Rule 10). | `import { NotificationsMenu } from "@working-theory/ui/chrome"` |
|
|
270
|
+
| `PricingRail` | Wraps a pricing page's rendered content and owns its layout region. The current page carries `aria-current="page"` in both. Every string is the caller's (`labels`, the items, the `cta`): no English defaults. | `import { PricingRail } from "@working-theory/ui/chrome"` |
|
|
270
271
|
| `SectionNav` | Chrome-tier route-aware section navigation. A horizontal, tab-styled section nav promoting Working Theory's bespoke `UnifiedTabs`/`TheoriesTabs` to a tokenized, tier-correct AILK component. | `import { SectionNav } from "@working-theory/ui/chrome"` |
|
|
271
272
|
| `SidebarNav` | Application sidebar rail (nav + teams + user) for dashboard shells. Server Component (RSC). Renders the vertical sidebar rail for application-shell layouts. Used as the `sidebar` prop of AdminShell. Wrap in a FixedPanel (panels tier) to get the expanded ↔ rail ↔ hidden state machinery. Independently reusable in future shells (settings, analytics, etc.). *(weak)* | `import { SidebarNav } from "@working-theory/ui/chrome"` |
|
|
272
273
|
| `SidebarNavRailItems` | Client boundary for the collapsed rail tooltip affordance. Isolated "use client" boundary so SidebarNav itself stays a Server Component. Renders icon-only nav links with Tooltip labels when the rail is collapsed. *(weak)* | internal — compose from `packages/ui/src/chrome/SidebarNavRailItems.tsx` |
|
package/dist/lib/env-catalog.js
CHANGED
|
@@ -256,7 +256,7 @@ export const ENV_CATALOG = {
|
|
|
256
256
|
secret: false,
|
|
257
257
|
},
|
|
258
258
|
STEALTH: {
|
|
259
|
-
description: 'Set to "true" to keep the site
|
|
259
|
+
description: 'Set to "true" to keep the site hidden until launch: on the website, crawlers are blocked and every page is noindexed; on the MCP server, the anonymous path refuses every caller.',
|
|
260
260
|
secret: false,
|
|
261
261
|
},
|
|
262
262
|
};
|
package/dist/lib/import-mdx.js
CHANGED
|
@@ -58,7 +58,9 @@
|
|
|
58
58
|
*
|
|
59
59
|
* The key travels only as `authorization: Bearer <key>`, never across a
|
|
60
60
|
* redirect (`redirect: "error"`), and is never printed. Of an API answer only
|
|
61
|
-
* a status and a `[a-z0-9_]` error code reach output (SEC-7876-S1).
|
|
61
|
+
* a status and a `[a-z0-9_]` error code reach output (SEC-7876-S1). A 401 or
|
|
62
|
+
* 403 stops the run, except a 403 `plugin_required`, which fails its page
|
|
63
|
+
* alone (#12013 D9).
|
|
62
64
|
*
|
|
63
65
|
* Spec: docs/specs/10203-import-mdx-one-mdx-artifact-spec.md; the editorial
|
|
64
66
|
* walk docs/specs/10701-import-mdx-walks-the-editorial-spec.md; its site
|
|
@@ -590,11 +592,17 @@ function failed(at, reason, halt) {
|
|
|
590
592
|
...(halt !== undefined && { halt }),
|
|
591
593
|
};
|
|
592
594
|
}
|
|
593
|
-
/**
|
|
595
|
+
/**
|
|
596
|
+
* A non-success answer: 401/403 stops the run, anything else fails the page.
|
|
597
|
+
* A 403 `plugin_required` refuses one address, not the key, so it fails the
|
|
598
|
+
* page alone (#12013 D9).
|
|
599
|
+
*/
|
|
594
600
|
function refusedAnswer(at, answer) {
|
|
595
601
|
if ("network" in answer)
|
|
596
602
|
return failed(at, answer.network);
|
|
597
603
|
const reason = `${answer.status} ${answer.code}`;
|
|
604
|
+
if (answer.status === 403 && answer.code === "plugin_required")
|
|
605
|
+
return failed(at, reason);
|
|
598
606
|
return answer.status === 401 || answer.status === 403
|
|
599
607
|
? failed(at, reason, `not sent: the API refused the key (${reason})`)
|
|
600
608
|
: failed(at, reason);
|
package/dist/seed-workspace.d.ts
CHANGED
|
@@ -69,5 +69,5 @@ export interface SeedWorkspaceArgs {
|
|
|
69
69
|
workspaceId: string | undefined;
|
|
70
70
|
help: boolean;
|
|
71
71
|
}
|
|
72
|
-
export declare const SEED_WORKSPACE_HELP = "create-ailk seed-workspace \u2014 import a starter's pages into its workspace.\n\nUsage:\n AILK_AGENT_KEY=<key> create-ailk seed-workspace [<dir>] [--api-url <origin>] [--workspace <wksp_id>]\n\nArguments:\n <dir> The site. Defaults to the current dir.\n\nOptions:\n --api-url <origin> The site's API origin. Else AILK_API_URL. https:\n only (http: on localhost or 127.0.0.1).\n --workspace <wksp_id> The workspace the pages are written to. Else\n AILK_WORKSPACE_ID.\n -h, --help Show this help.\n\nEach content/en/<Type>/<slug>.mdx page is written to the workspace, and set\nLive when it has no Live version, through the API's content routes, with the\nagent key, which is read from AILK_AGENT_KEY only and needs the content-edit\nand content-publish grants. Each page prints created, updated,
|
|
72
|
+
export declare const SEED_WORKSPACE_HELP = "create-ailk seed-workspace \u2014 import a starter's pages into its workspace.\n\nUsage:\n AILK_AGENT_KEY=<key> create-ailk seed-workspace [<dir>] [--api-url <origin>] [--workspace <wksp_id>]\n\nArguments:\n <dir> The site. Defaults to the current dir.\n\nOptions:\n --api-url <origin> The site's API origin. Else AILK_API_URL. https:\n only (http: on localhost or 127.0.0.1).\n --workspace <wksp_id> The workspace the pages are written to. Else\n AILK_WORKSPACE_ID.\n -h, --help Show this help.\n\nEach content/en/<Type>/<slug>.mdx page is written to the workspace, and set\nLive when it has no Live version, through the API's content routes, with the\nagent key, which is read from AILK_AGENT_KEY only and needs the content-edit\nand content-publish grants, at Autonomous. Each page prints created, updated,\nunchanged, skipped or failed, so a re-run is safe. When every page is Live, the site\nswitches apps/web and apps/api to CONTENT_ADAPTER=database, keeping a value\neither already sets. The site's dependencies must be installed. Exit 0 when\nevery page was seeded, 1 when any failed, 2 on a refusal (nothing is sent).\n";
|
|
73
73
|
export declare function parseSeedWorkspaceArgs(argv: string[]): SeedWorkspaceArgs;
|
package/dist/seed-workspace.js
CHANGED
|
@@ -43,6 +43,8 @@ export const AGENT_KEY_ENV_VAR = "AILK_AGENT_KEY";
|
|
|
43
43
|
export const WORKSPACE_ID_ENV_VAR = "AILK_WORKSPACE_ID";
|
|
44
44
|
/** The environment variable each app chooses its content source by (#10659). */
|
|
45
45
|
export const CONTENT_ADAPTER_ENV_VAR = "CONTENT_ADAPTER";
|
|
46
|
+
/** A page the importer saved but whose publish the API refused 403 (`import-mdx.ts`'s reason). */
|
|
47
|
+
const PUBLISH_REFUSED = /not published \(403 [a-z0-9_]+\)$/;
|
|
46
48
|
/** A refusal the CLI exits 2 on, thrown before any request is sent. */
|
|
47
49
|
export class SeedWorkspaceRefusedError extends Error {
|
|
48
50
|
exitCode = 2;
|
|
@@ -90,7 +92,7 @@ export async function seedWorkspace(opts) {
|
|
|
90
92
|
}
|
|
91
93
|
const apiKey = given(env[AGENT_KEY_ENV_VAR]);
|
|
92
94
|
if (apiKey === undefined) {
|
|
93
|
-
refuse(`set ${AGENT_KEY_ENV_VAR} to an agent key with the content-edit and content-publish grants. It is read from the environment only — never a flag or a file.`);
|
|
95
|
+
refuse(`set ${AGENT_KEY_ENV_VAR} to an agent key with the content-edit and content-publish grants, at Autonomous. It is read from the environment only — never a flag or a file.`);
|
|
94
96
|
}
|
|
95
97
|
const workspaceId = given(opts.workspaceId) ?? given(env[WORKSPACE_ID_ENV_VAR]);
|
|
96
98
|
if (workspaceId === undefined) {
|
|
@@ -145,6 +147,11 @@ export async function seedWorkspace(opts) {
|
|
|
145
147
|
if (failed > 0) {
|
|
146
148
|
onLine(`${failed} page(s) were not seeded. Fix them and re-run: create-ailk seed-workspace ${opts.targetDir}`);
|
|
147
149
|
}
|
|
150
|
+
// #12008 D12 — the key is an agent's, and below Autonomous an agent's
|
|
151
|
+
// publish is refused 403.
|
|
152
|
+
if (result.pages.some((page) => page.result === "failed" && PUBLISH_REFUSED.test(page.reason))) {
|
|
153
|
+
onLine("This agent's level holds back publishing. Its person sets it to Autonomous on the agent's page, then run this again.");
|
|
154
|
+
}
|
|
148
155
|
onLine("Content source: content/ (unchanged) until every page is seeded and Live.");
|
|
149
156
|
}
|
|
150
157
|
return { result, exitCode: failed > 0 ? 1 : 0 };
|
|
@@ -235,8 +242,8 @@ Options:
|
|
|
235
242
|
Each content/en/<Type>/<slug>.mdx page is written to the workspace, and set
|
|
236
243
|
Live when it has no Live version, through the API's content routes, with the
|
|
237
244
|
agent key, which is read from AILK_AGENT_KEY only and needs the content-edit
|
|
238
|
-
and content-publish grants. Each page prints created, updated,
|
|
239
|
-
skipped or failed, so a re-run is safe. When every page is Live, the site
|
|
245
|
+
and content-publish grants, at Autonomous. Each page prints created, updated,
|
|
246
|
+
unchanged, skipped or failed, so a re-run is safe. When every page is Live, the site
|
|
240
247
|
switches apps/web and apps/api to CONTENT_ADAPTER=database, keeping a value
|
|
241
248
|
either already sets. The site's dependencies must be installed. Exit 0 when
|
|
242
249
|
every page was seeded, 1 when any failed, 2 on a refusal (nothing is sent).
|
package/dist/surfaces.js
CHANGED
|
@@ -452,7 +452,7 @@ export const GATEABLE_SURFACES = [
|
|
|
452
452
|
// schedule/ directory by #5563), and the private index `/private`
|
|
453
453
|
// (#8843 D10), a second directory gated with it. API-backed like
|
|
454
454
|
// `flows`: every meeting fact comes from apps/api's
|
|
455
|
-
// `GET /v1/schedule/
|
|
455
|
+
// `GET /v1/schedule/meeting-pages`, so there is no MDX of its own. Since
|
|
456
456
|
// #11252 the pages ship in `@working-theory/ui-scheduling` and the
|
|
457
457
|
// snapshot carries neither directory; the surface still gates the nav
|
|
458
458
|
// label and the Free placeholders.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-ailk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0",
|
|
4
4
|
"description": "Scaffolder for AI Launch Kit — `pnpm create ailk@latest <dir>` produces a starter repo consuming @working-theory/* from npm (per ADR 0007).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"tar": "^7.5.21"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@working-theory/
|
|
32
|
-
"@working-theory/
|
|
31
|
+
"@working-theory/templates": "0.74.0",
|
|
32
|
+
"@working-theory/schema": "0.74.0"
|
|
33
33
|
},
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|
|
@@ -238,6 +238,29 @@ STRIPE_WEBHOOK_SECRET=whsec_xxx
|
|
|
238
238
|
# the connect PUT (#7533). On a hub whose spokes all have connections, unset
|
|
239
239
|
# this to retire the env receiver (it then answers 503).
|
|
240
240
|
# CAL_WEBHOOK_SECRET=
|
|
241
|
+
#
|
|
242
|
+
# The plugin entitlements read (#12001) — whether a workspace has a plugin
|
|
243
|
+
# (positionary, design-shop, promote, growth-ops, study), asked of the entitlements
|
|
244
|
+
# service by one function, workspaceHasPlugin. ENTITLEMENTS_URL is the
|
|
245
|
+
# service's origin only (no path) and must be https:, except a loopback host
|
|
246
|
+
# in local development. PLUGINS_RESOLVE_SECRET is the service's resolve
|
|
247
|
+
# secret ONLY, never billing's LICENSE_ISSUER_INTERNAL_SECRET. Set both ONLY
|
|
248
|
+
# on a deployment the entitlements service's own operator runs, never on a
|
|
249
|
+
# customer's deployment.
|
|
250
|
+
# Unset, or a URL that fails the rule, makes every read a logged failure:
|
|
251
|
+
# the sold plugins answer no and growth-ops answers yes.
|
|
252
|
+
# ENTITLEMENTS_URL=
|
|
253
|
+
# PLUGINS_RESOLVE_SECRET=
|
|
254
|
+
#
|
|
255
|
+
# The craft delivery service (#12015; claude-setup#12180) — where
|
|
256
|
+
# GET /v1/workspaces/:workspaceId/craft/:command asks for one command's craft,
|
|
257
|
+
# sending this deployment's licence key. CRAFT_DELIVERY_URL is a LOCAL override
|
|
258
|
+
# only: accepted only as a loopback origin with a port
|
|
259
|
+
# (http://127.0.0.1:<port> or http://[::1]:<port>), for development and tests;
|
|
260
|
+
# any other value refuses every craft read and sends nothing. Production uses
|
|
261
|
+
# the origin built into the kit (CRAFT_DELIVERY_ORIGIN, https://api.ailaunchkit.ai);
|
|
262
|
+
# nothing needs setting.
|
|
263
|
+
# CRAFT_DELIVERY_URL=
|
|
241
264
|
# GET /v1/schedule/appointments only returns rows where this deployment's
|
|
242
265
|
# AILK_SITE_ID (declared below, under "Project listings — site addressing")
|
|
243
266
|
# equals the caller's own workspace id: the receiver writes under
|
|
@@ -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
|
-
-
|
|
100
|
-
- `GET /v1/workspaces/:workspaceId/
|
|
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
|
|
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. **
|
|
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-
|
|
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
|