create-ailk 0.44.0 → 0.45.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/dist/add-module.d.ts +7 -0
- package/dist/add-module.js +17 -2
- package/dist/apply-design.js +1 -12
- package/dist/lib/env-catalog.js +1 -1
- package/dist/lib/license-key-files.d.ts +2 -0
- package/dist/lib/license-key-files.js +11 -0
- package/dist/paid-sections.d.ts +19 -0
- package/dist/paid-sections.js +41 -0
- package/dist/programmatic.js +56 -6
- package/dist/update.d.ts +21 -2
- package/dist/update.js +188 -10
- package/package.json +3 -3
- package/templates/apps/api/CLAUDE.md +5 -2
- package/templates/apps/mcp/.env.example +6 -3
- package/templates/apps/mcp/CLAUDE.md +29 -22
- package/templates/apps/mcp/src/index.ts +1 -1
- package/templates/apps/web/app/.well-known/mcp.json/build-manifest.ts +44 -41
- package/templates/apps/web/app/.well-known/mcp.json/route.ts +20 -28
- package/templates/apps/web/lib/__tests__/fixtures/mcp-stub-server.ts +238 -0
- package/templates/apps/web/lib/__tests__/mcp-served-tools.test.ts +334 -0
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +108 -11
- package/templates/apps/web/lib/license-key-store.ts +1 -1
- package/templates/apps/web/lib/mcp-served-tools.ts +189 -0
- package/versions.json +50 -50
- package/templates/apps/web/lib/release-scope.ts +0 -47
package/dist/update.js
CHANGED
|
@@ -87,6 +87,15 @@
|
|
|
87
87
|
* additively. A written web file that uses, through `t(…)`, a template key a
|
|
88
88
|
* catalog still lacks after that is held with the catalog.
|
|
89
89
|
*
|
|
90
|
+
* The web build script comes with the template (#11940). `package.json` is
|
|
91
|
+
* never recorded, so `apps/web/package.json`'s `scripts.build` is read
|
|
92
|
+
* against the published history, as a stale copy is (#11147): a value equal
|
|
93
|
+
* to a published template's in the run's range is set to the running
|
|
94
|
+
* template's and listed under "Build scripts carried"; one matching none is
|
|
95
|
+
* the site's own, left as it is and listed under "Needs review". The carry
|
|
96
|
+
* waits, under review, while the site would lack a `tsx` file the new value
|
|
97
|
+
* runs.
|
|
98
|
+
*
|
|
90
99
|
* A route the site declined in `customizations.yaml` `declined_routes`
|
|
91
100
|
* (#11260) is the site's decision: no file under its directory is written —
|
|
92
101
|
* not updated, not added, not supplied as another file's dependency — and
|
|
@@ -97,7 +106,7 @@
|
|
|
97
106
|
*/
|
|
98
107
|
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, rmdirSync, statSync, writeFileSync, } from "node:fs";
|
|
99
108
|
import { createRequire } from "node:module";
|
|
100
|
-
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
109
|
+
import { dirname, join, posix, relative, resolve, sep } from "node:path";
|
|
101
110
|
import { pathToFileURL } from "node:url";
|
|
102
111
|
import { parseArgs } from "node:util";
|
|
103
112
|
import { AddModuleRefusedError, readArchitectureHeader } from "./add-module-core.js";
|
|
@@ -111,16 +120,20 @@ import { ENV_CATALOG } from "./lib/env-catalog.js";
|
|
|
111
120
|
import { assertContentLengthWithinLimit, assertHttpsRegistryUrl, fetchTimeoutSignal, } from "./lib/fetch-guard.js";
|
|
112
121
|
import { DEFAULT_AILK_NPM_REGISTRY_URL, fetchTemplateSnapshot } from "./lib/fetch-template-snapshot.js";
|
|
113
122
|
import { exportsName, listFilesUnder, namedImportsOf } from "./lib/import-graph.js";
|
|
123
|
+
import { readSiteKey } from "./lib/license-key-files.js";
|
|
114
124
|
import { mergeThreeWay } from "./lib/merge-three-way.js";
|
|
125
|
+
import { deriveLevel } from "./lib/module-license-gate.js";
|
|
126
|
+
import { LEVEL_LABEL } from "./lib/module-tier.js";
|
|
115
127
|
import { publicTreeRemoved } from "./lib/site-modules.js";
|
|
116
128
|
import { escapeBareBraces, findBareBraces } from "./mdx-braces.js";
|
|
117
129
|
import { MODULE_SLICES } from "./module-architecture.js";
|
|
118
|
-
import { MODULE_FLAGS_PATH, PAID_MCP_TOOLS_PATH, PAID_SECTIONS_PATH, renderSitePaidSections, writeModuleFlags, writePaidMcpTools, writePaidSectionsRegistry, } from "./paid-sections.js";
|
|
130
|
+
import { MODULE_FLAGS_PATH, PAID_MCP_TOOLS_PATH, PAID_SECTIONS_PATH, levelMcpPackages, renderSitePaidSections, withLevelMcpPackages, writeModuleFlags, writePaidMcpTools, writePaidSectionsRegistry, } from "./paid-sections.js";
|
|
119
131
|
import { ParseError } from "./parse-args.js";
|
|
120
132
|
import { PAGE_DECISION_GUIDANCE, RoutesRefusedError, checkRoutes, customizationsRecord, isGenerated, writeRoutes } from "./routes.js";
|
|
121
133
|
import { planSeamRefresh, seamRow, siteSeamRenders } from "./seam-refresh.js";
|
|
122
134
|
import { SITE_LISTING_PATH } from "./site-listing-path.js";
|
|
123
135
|
import { SITE_ROSTER_PATH, planServedRoster, readRosterPageRoutes } from "./site-roster.js";
|
|
136
|
+
import { substituteMarkers } from "./substitute.js";
|
|
124
137
|
import { GATEABLE_SURFACES, excludedRoutePaths, isRemovedPublicRoutePath, resolveSurfaces, surfacesNamedByRoutes, } from "./surfaces.js";
|
|
125
138
|
import { DATABASE_BOOT_FILES, ROOT_TOOL_FILES, TEMPLATE_RECORD_PATH, isRecordable, parseTemplateRecord, serializeTemplateRecord, sha256Hex, } from "./template-record.js";
|
|
126
139
|
import { MCP_SEAM_PATH, MCP_SERVER_HUB, SPOKE_SEAM_FILES, TopologyError, isSpokeExcluded, readSpokeShape, spokeExclusions, } from "./topology.js";
|
|
@@ -1306,6 +1319,25 @@ const WEB_PACKAGE_JSON = "apps/web/package.json";
|
|
|
1306
1319
|
* Frozen; a name joins only with a spec.
|
|
1307
1320
|
*/
|
|
1308
1321
|
const WEB_CARRIED_DEPENDENCIES = Object.freeze(["botid"]);
|
|
1322
|
+
/**
|
|
1323
|
+
* The `apps/web/package.json` scripts `update` carries (#11940): a value that
|
|
1324
|
+
* is a published template's in the run's range moves to the running
|
|
1325
|
+
* template's; one matching none is the site's own and is reviewed. Frozen; a
|
|
1326
|
+
* name joins only with a spec.
|
|
1327
|
+
*/
|
|
1328
|
+
const WEB_CARRIED_SCRIPTS = Object.freeze(["build"]);
|
|
1329
|
+
/** Each `tsx <file>.ts` a script runs (#11940 D4), resolved under `apps/web/`. */
|
|
1330
|
+
const TSX_STEP = /\btsx\s+(\S+\.ts)\b/g;
|
|
1331
|
+
/** The `scripts` of a template's `apps/web/package.json` text — `undefined` when not JSON or not an object (#11940 D3). */
|
|
1332
|
+
function webScriptsOf(text) {
|
|
1333
|
+
try {
|
|
1334
|
+
const scripts = JSON.parse(text).scripts;
|
|
1335
|
+
return isPlainObject(scripts) ? scripts : undefined;
|
|
1336
|
+
}
|
|
1337
|
+
catch {
|
|
1338
|
+
return undefined;
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1309
1341
|
/** Whether the site's `pkg` declares `name`, in `dependencies` or `devDependencies`, at any range. */
|
|
1310
1342
|
function declares(pkg, name) {
|
|
1311
1343
|
return Object.hasOwn(pkg.dependencies ?? {}, name) || Object.hasOwn(pkg.devDependencies ?? {}, name);
|
|
@@ -1456,8 +1488,20 @@ export async function updateSite(opts) {
|
|
|
1456
1488
|
// ── The running version's rendered copies ─────────────────────────────
|
|
1457
1489
|
const runningRaw = walkLocalTemplates(opts.templatesDir);
|
|
1458
1490
|
const newMap = renderSnapshot(runningRaw, record.projectName, version);
|
|
1491
|
+
// #11940 D3 — a version's `apps/web/package.json` scripts, read before
|
|
1492
|
+
// `renderSnapshot` drops the unrecorded path. Markers only: the workspace
|
|
1493
|
+
// version pass rewrites `dependencies`, never `scripts`, and would refuse
|
|
1494
|
+
// here for want of a versions map.
|
|
1495
|
+
const webScriptsIn = (raw, v) => {
|
|
1496
|
+
const bytes = raw.get(WEB_PACKAGE_JSON);
|
|
1497
|
+
return bytes === undefined
|
|
1498
|
+
? undefined
|
|
1499
|
+
: webScriptsOf(substituteMarkers(Buffer.from(bytes).toString("utf8"), markersForVersion(record.projectName, v)));
|
|
1500
|
+
};
|
|
1501
|
+
const runningWebScripts = webScriptsIn(runningRaw, version);
|
|
1459
1502
|
// ── A cache of rendered copies by version, fetched at most once each ──
|
|
1460
1503
|
const versionCache = new Map();
|
|
1504
|
+
const webScriptsByVersion = new Map();
|
|
1461
1505
|
async function loadVersionMap(v) {
|
|
1462
1506
|
const cached = versionCache.get(v);
|
|
1463
1507
|
if (cached !== undefined)
|
|
@@ -1474,6 +1518,7 @@ export async function updateSite(opts) {
|
|
|
1474
1518
|
...(opts.fetchImpl !== undefined ? { fetchImpl: opts.fetchImpl } : {}),
|
|
1475
1519
|
});
|
|
1476
1520
|
result = renderSnapshot(raw, record.projectName, v);
|
|
1521
|
+
webScriptsByVersion.set(v, webScriptsIn(raw, v));
|
|
1477
1522
|
}
|
|
1478
1523
|
catch (err) {
|
|
1479
1524
|
result = { error: err.message };
|
|
@@ -1570,6 +1615,55 @@ export async function updateSite(opts) {
|
|
|
1570
1615
|
const mcpMove = existsSync(mcpPkgPath)
|
|
1571
1616
|
? planMcpMove(targetDir, header.modules, spoke === undefined, new Set(Object.keys(record.files)), opts.versions ?? {})
|
|
1572
1617
|
: undefined;
|
|
1618
|
+
// ── The level's MCP packs (#11952 D4), planned before the first write ──
|
|
1619
|
+
// A site missing a paid MCP pack its licence level ships gets it. The
|
|
1620
|
+
// level comes only from the site's own key (NFR1); a site already holding
|
|
1621
|
+
// every pack either paid level ships reads no key and sends no request.
|
|
1622
|
+
let mcpLevelPlan;
|
|
1623
|
+
let mcpLevelUnchecked;
|
|
1624
|
+
if (existsSync(mcpPkgPath)) {
|
|
1625
|
+
const haveText = mcpMove?.packageJson ?? readFileSync(mcpPkgPath, "utf8");
|
|
1626
|
+
let have;
|
|
1627
|
+
try {
|
|
1628
|
+
have = JSON.parse(haveText).dependencies ?? {};
|
|
1629
|
+
}
|
|
1630
|
+
catch (err) {
|
|
1631
|
+
throw new UpdateRefusedError(`${MCP_PACKAGE_JSON} is not valid JSON: ${err.message}`);
|
|
1632
|
+
}
|
|
1633
|
+
const paidPacks = [...new Set([...levelMcpPackages("pro"), ...levelMcpPackages("pro-plus")])];
|
|
1634
|
+
if (!paidPacks.every((name) => Object.hasOwn(have, name))) {
|
|
1635
|
+
const key = readSiteKey(targetDir, opts.env ?? process.env);
|
|
1636
|
+
let level = "free";
|
|
1637
|
+
if (key === undefined) {
|
|
1638
|
+
if (paidPacks.some((name) => Object.hasOwn(have, name))) {
|
|
1639
|
+
mcpLevelUnchecked = "no licence key (ailk.key or AILK_LICENSE_KEY)";
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
else {
|
|
1643
|
+
try {
|
|
1644
|
+
({ level } = await deriveLevel({
|
|
1645
|
+
licenseKey: key,
|
|
1646
|
+
...(opts.moduleRegistryUrl !== undefined ? { registryUrl: opts.moduleRegistryUrl } : {}),
|
|
1647
|
+
...(opts.fetchImpl !== undefined ? { fetchImpl: opts.fetchImpl } : {}),
|
|
1648
|
+
}));
|
|
1649
|
+
}
|
|
1650
|
+
catch (err) {
|
|
1651
|
+
mcpLevelUnchecked = `could not determine this site's licence level: ${err.message}`;
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
if (level !== "free") {
|
|
1655
|
+
let next;
|
|
1656
|
+
try {
|
|
1657
|
+
next = withLevelMcpPackages(haveText, level, opts.versions ?? {});
|
|
1658
|
+
}
|
|
1659
|
+
catch (err) {
|
|
1660
|
+
throw new UpdateRefusedError(err.message);
|
|
1661
|
+
}
|
|
1662
|
+
if (next.added.length > 0)
|
|
1663
|
+
mcpLevelPlan = { level, packages: next.added, text: next.text };
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1573
1667
|
// ── The API move (#9566), planned before the first write ──────────────
|
|
1574
1668
|
// A site scaffolded before #9564 carries the server under apps/api/src, an
|
|
1575
1669
|
// apps/api still named @working-theory/api and no @working-theory/api
|
|
@@ -2401,9 +2495,58 @@ export async function updateSite(opts) {
|
|
|
2401
2495
|
}
|
|
2402
2496
|
}
|
|
2403
2497
|
}
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2498
|
+
// #11940 — each carried script is the running template's when the site's
|
|
2499
|
+
// value is a published template's in the run's range, oldest first (the
|
|
2500
|
+
// scaffold's version is the floor, so the common case reads one tarball);
|
|
2501
|
+
// one matching none is the site's own, reviewed and left as it is. The
|
|
2502
|
+
// carry waits while a `tsx` file the running value runs would be absent
|
|
2503
|
+
// once the run lands. The hold cascade is final here and no write has run.
|
|
2504
|
+
const scriptsCarried = [];
|
|
2505
|
+
if (webDependencies !== undefined) {
|
|
2506
|
+
const siteScripts = webDependencies.pkg.scripts ?? {};
|
|
2507
|
+
for (const name of WEB_CARRIED_SCRIPTS) {
|
|
2508
|
+
const running = runningWebScripts?.[name];
|
|
2509
|
+
const site = siteScripts[name];
|
|
2510
|
+
if (typeof running !== "string" || site === running)
|
|
2511
|
+
continue;
|
|
2512
|
+
let matched;
|
|
2513
|
+
for (const v of [...(await (versionsInRange ??= listVersionsInRange()))].reverse()) {
|
|
2514
|
+
await loadVersionMap(v);
|
|
2515
|
+
const scripts = webScriptsByVersion.get(v);
|
|
2516
|
+
if (scripts !== undefined && scripts[name] === site) {
|
|
2517
|
+
matched = v;
|
|
2518
|
+
break;
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
if (matched === undefined) {
|
|
2522
|
+
review.push({
|
|
2523
|
+
path: WEB_PACKAGE_JSON,
|
|
2524
|
+
reason: `scripts.${name} is ${site === undefined ? "absent" : JSON.stringify(site)}, which matches no create-ailk template this run read; this template's is ${JSON.stringify(running)} — left as it is`,
|
|
2525
|
+
});
|
|
2526
|
+
continue;
|
|
2527
|
+
}
|
|
2528
|
+
const missing = [...running.matchAll(TSX_STEP)]
|
|
2529
|
+
.map((m) => posix.join(WEB_ROOT, m[1]))
|
|
2530
|
+
.find((path) => !presentAfter(path));
|
|
2531
|
+
if (missing !== undefined) {
|
|
2532
|
+
review.push({
|
|
2533
|
+
path: WEB_PACKAGE_JSON,
|
|
2534
|
+
reason: `scripts.${name} not carried: this template's ${JSON.stringify(running)} runs ${missing}, which this site will not have`,
|
|
2535
|
+
});
|
|
2536
|
+
continue;
|
|
2537
|
+
}
|
|
2538
|
+
(webDependencies.pkg.scripts ??= {})[name] = running;
|
|
2539
|
+
scriptsCarried.push({ script: name, version: matched });
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
const webDependenciesAdded = Object.keys(webDependencies?.entries ?? {}).sort();
|
|
2543
|
+
const webPackageJson = webDependencies === undefined
|
|
2544
|
+
? undefined
|
|
2545
|
+
: webDependenciesAdded.length > 0
|
|
2546
|
+
? withDependencies(webDependencies.pkg, webDependencies.entries)
|
|
2547
|
+
: scriptsCarried.length > 0
|
|
2548
|
+
? `${JSON.stringify(webDependencies.pkg, null, 2)}\n`
|
|
2549
|
+
: undefined;
|
|
2407
2550
|
// #11216 — a dependency written this run is in the site after all.
|
|
2408
2551
|
for (let i = skipped.length - 1; i >= 0; i--) {
|
|
2409
2552
|
const path = skipped[i].path;
|
|
@@ -2538,6 +2681,12 @@ export async function updateSite(opts) {
|
|
|
2538
2681
|
}
|
|
2539
2682
|
pruneEmptyDirs(join(targetDir, ...MCP_SRC.split("/")));
|
|
2540
2683
|
}
|
|
2684
|
+
// #11952 D4 — the level's packs, planned over the move's text so its packs are kept.
|
|
2685
|
+
if (mcpLevelPlan !== undefined) {
|
|
2686
|
+
writeFileSync(mcpPkgPath, mcpLevelPlan.text);
|
|
2687
|
+
if (!moved.updated.includes(MCP_PACKAGE_JSON))
|
|
2688
|
+
moved.updated.push(MCP_PACKAGE_JSON);
|
|
2689
|
+
}
|
|
2541
2690
|
const registry = writePaidMcpTools(targetDir);
|
|
2542
2691
|
if (registry === "added")
|
|
2543
2692
|
moved.added.push(PAID_MCP_TOOLS_PATH);
|
|
@@ -2693,6 +2842,12 @@ export async function updateSite(opts) {
|
|
|
2693
2842
|
...(adopted.some((row) => notHeld(row.path))
|
|
2694
2843
|
? { adopted: adopted.filter((row) => notHeld(row.path)) }
|
|
2695
2844
|
: {}),
|
|
2845
|
+
...(scriptsCarried.length > 0 ? { scriptsCarried } : {}),
|
|
2846
|
+
...(webDependenciesAdded.length > 0 ? { webDependenciesAdded } : {}),
|
|
2847
|
+
...(mcpLevelPlan !== undefined
|
|
2848
|
+
? { mcpPackagesAdded: { level: mcpLevelPlan.level, packages: mcpLevelPlan.packages } }
|
|
2849
|
+
: {}),
|
|
2850
|
+
...(mcpLevelUnchecked !== undefined ? { mcpLevelUnchecked } : {}),
|
|
2696
2851
|
headingsAdded: headings.written.map(sitePath),
|
|
2697
2852
|
bracesEscaped,
|
|
2698
2853
|
...(regenerated.length > 0 ? { regenerated: regenerated.sort() } : {}),
|
|
@@ -2808,6 +2963,15 @@ export function formatUpdateReport(result) {
|
|
|
2808
2963
|
lines.push(`Adopted (${result.adopted.length}):`);
|
|
2809
2964
|
lines.push(...result.adopted.map(({ path, version }) => ` ${path} — matched the ${version} template`));
|
|
2810
2965
|
}
|
|
2966
|
+
if (result.scriptsCarried !== undefined) {
|
|
2967
|
+
lines.push(`Build scripts carried (${result.scriptsCarried.length}):`);
|
|
2968
|
+
lines.push(...result.scriptsCarried.map(({ script, version }) => ` ${WEB_PACKAGE_JSON} scripts.${script} — was the ${version} template's`));
|
|
2969
|
+
}
|
|
2970
|
+
if (result.mcpPackagesAdded !== undefined) {
|
|
2971
|
+
const { level, packages } = result.mcpPackagesAdded;
|
|
2972
|
+
lines.push(`MCP packages added for the ${LEVEL_LABEL[level]} level (${packages.length}):`);
|
|
2973
|
+
lines.push(...packages.map((pkg) => ` ${pkg}`));
|
|
2974
|
+
}
|
|
2811
2975
|
if (result.review.length > 0) {
|
|
2812
2976
|
lines.push(`Needs review (${result.review.length}):`);
|
|
2813
2977
|
lines.push(...result.review.map((row) => ` ${row.path} — ${row.reason}`));
|
|
@@ -2864,6 +3028,8 @@ export function formatUpdateReport(result) {
|
|
|
2864
3028
|
result.regenerated === undefined &&
|
|
2865
3029
|
result.routesWritten === undefined &&
|
|
2866
3030
|
result.cliPin === undefined &&
|
|
3031
|
+
result.scriptsCarried === undefined &&
|
|
3032
|
+
result.mcpPackagesAdded === undefined &&
|
|
2867
3033
|
result.review.length === 0 &&
|
|
2868
3034
|
result.skipped.length === 0 &&
|
|
2869
3035
|
result.heldBack.length === 0 &&
|
|
@@ -2871,18 +3037,24 @@ export function formatUpdateReport(result) {
|
|
|
2871
3037
|
result.droppedRows === undefined &&
|
|
2872
3038
|
result.surfacesDeclared === undefined &&
|
|
2873
3039
|
result.rosterRowsDropped === undefined;
|
|
3040
|
+
// #11952 D4 — why the level's packs were not checked: the report's last line.
|
|
3041
|
+
const unchecked = result.mcpLevelUnchecked !== undefined
|
|
3042
|
+
? `MCP packages for this site's level not checked — ${result.mcpLevelUnchecked}\n`
|
|
3043
|
+
: "";
|
|
2874
3044
|
if (nothingHappened) {
|
|
2875
|
-
return `[create-ailk] Already up to date (create-ailk ${result.version}).\n`;
|
|
3045
|
+
return `[create-ailk] Already up to date (create-ailk ${result.version}).\n${unchecked}`;
|
|
2876
3046
|
}
|
|
2877
3047
|
// #9567 / #9566 — the MCP and API moves add dependencies (the mcp README
|
|
2878
3048
|
// § Move, step 7, names the install; the API half says the same), and so
|
|
2879
|
-
// does the web app's carried-dependency step (#9889 D9)
|
|
3049
|
+
// does the web app's carried-dependency step (#9889 D9) — never a write
|
|
3050
|
+
// that only carried a build script (#11940).
|
|
2880
3051
|
for (const pkgJson of [MCP_PACKAGE_JSON, API_PACKAGE_JSON, WEB_PACKAGE_JSON]) {
|
|
2881
|
-
|
|
3052
|
+
const gained = pkgJson === WEB_PACKAGE_JSON ? result.webDependenciesAdded !== undefined : result.updated.includes(pkgJson);
|
|
3053
|
+
if (gained) {
|
|
2882
3054
|
lines.push(`${pkgJson} gained dependencies: run \`pnpm install\`.`);
|
|
2883
3055
|
}
|
|
2884
3056
|
}
|
|
2885
|
-
return lines.join("\n") + "\n";
|
|
3057
|
+
return lines.join("\n") + "\n" + unchecked;
|
|
2886
3058
|
}
|
|
2887
3059
|
export const UPDATE_HELP = `create-ailk update — bring template fixes into a site's copied app code.
|
|
2888
3060
|
|
|
@@ -2908,7 +3080,13 @@ on one side and a value on the other; a written apps/web file that uses
|
|
|
2908
3080
|
through t(...) a key the catalog then lacks is held with it, listed under
|
|
2909
3081
|
"Held back with <catalog>". Each @working-theory/* package a written apps/web
|
|
2910
3082
|
file imports that apps/web/package.json does not declare is added to its
|
|
2911
|
-
dependencies at this release's version.
|
|
3083
|
+
dependencies at this release's version. A site missing a paid MCP package
|
|
3084
|
+
its licence level ships gets it in apps/mcp/package.json; the level is read
|
|
3085
|
+
from the site's key (ailk.key, else AILK_LICENSE_KEY) through the module
|
|
3086
|
+
registry, and a run with no key adds none. apps/web/package.json's
|
|
3087
|
+
scripts.build is set to this template's when it is a published create-ailk
|
|
3088
|
+
template's, listed under "Build scripts carried"; a build script matching no
|
|
3089
|
+
template's is left as it is and listed under "Needs review". An edited file whose
|
|
2912
3090
|
bytes are another published create-ailk version's copy is a stale copy, not
|
|
2913
3091
|
an edit: it is overwritten or removed as an untouched file is, listed with
|
|
2914
3092
|
the version it matched. An edit that touches only comment lines is listed as
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-ailk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.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/schema": "0.
|
|
32
|
-
"@working-theory/templates": "0.
|
|
31
|
+
"@working-theory/schema": "0.73.0",
|
|
32
|
+
"@working-theory/templates": "0.73.0"
|
|
33
33
|
},
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|
|
@@ -66,7 +66,7 @@ Routes are versioned under `/v1/*`:
|
|
|
66
66
|
- `/v1/flows/:slug/save` (POST), `/v1/flows/:slug/checkout` (POST) — the recommender's email moment (#4841): `save` creates the FlowSession + Lead (+ the T+0 DeliverableGrant) for the permalink's answers; `checkout` does the same, records the `FlowCheckout` buyer row at a SERVER-recomputed `price()` (the body carries no amount — `flowCheckoutInputSchema` is strict), and opens a Stripe Checkout Session whose metadata carries the permalink + offer key (`src/routes/flows/recommender.ts`, `src/services/recommender-capture.ts`, `packages/stripe-client`'s `createQuotedCheckoutSession`). Anonymous, rate-limited; a key `assertAdmittedStripeKey` refuses is refused before any side effect. **An Offerings offer is never quoted here (#9071 D2):** a `checkout` whose register offer or flow config offer carries `lookupKey` is `409 checkout_not_configured` before any write (the flow config's is checked inside the capture, before the email moment's session and lead — #9970 D9) — logged `{ slug, outcome: "offerings_offer_refused" }`; such an offer is sold on `/pricing` at Stripe's own Price. No MCP twin — recorded exception: an agent walking a flow has no email to give and no card to pay with; the anonymous MCP surface is identity-blind.
|
|
67
67
|
- `/v1/workspaces/:workspaceId/magnets` (GET, POST), `/v1/workspaces/:workspaceId/magnets/:id` (GET, PATCH), `/v1/workspaces/:workspaceId/magnets/save` (POST, #11810), `/v1/workspaces/:workspaceId/magnets/:id/signups` (GET), `/v1/workspaces/:workspaceId/magnets/:id/subscribers` (GET), `/v1/workspaces/:workspaceId/magnets/:id/messages` (GET) — the tenant-scoped magnet Admin authoring surface over the flow engine's `FlowDefinition` rows (#6157 S5c, `src/routes/magnets/index.ts`): list (cursor-paginated, fixed 50-row page), create, get, update, and the three per-magnet captured-lead reads (#6246 S6h). Reads and writes only through `tenantDb(tenant).flows` — never `prisma.flowDefinition`, `currentSiteId()`, or `upsertFlowDefinition` (the PUBLIC/seed path below, which the admin path never calls). No DELETE — the reversible alternative is `status: "draft"` (#6156), which stops a NEW walk from starting while an in-flight walk finishes on its pinned snapshot. `slug` lives only inside `config.slug`. **A PATCH whose `config.slug` differs renames the magnet (#8641 D8):** `tenantDb(tenant).flows.rename` moves the row, this workspace's `Lead.source = 'flow:<slug>'` rows and its `FlowSession.flowSlug` rows to the new slug in one transaction, so its submissions follow it; `FlowCheckout` rows and lead payload copies are never rewritten. Refused before any write: `409 slug_fixed` (the stored slug is `onboarding`, `request-quote`, `contact` (#8661 D5), `job-application` (#8746 D3), `newsletter` (#8847 D4), `recommender` (#9071 D12) or `trial` (#9287 D11), which the server reads by name, or the row belongs to a listing) and `409 slug_reserved` (the new slug is one of those seven); inside the transaction, `409 conflict` first (another magnet holds it — #8734 D1; also the loser of two renames racing for one free slug, which fails on the `(site_id, slug)` key because the definition row is the rename's first write, D4), then `409 slug_bound` (a checkout or a waitlist register of this workspace names either slug, or a session of this workspace already sits at the new one). A lead of this workspace at `flow:<new slug>` that no magnet owns does not refuse: the rename re-stamps it `unclaimed:flow:<new slug>` (`unclaimedLeadSource`, `@working-theory/validation`) so the magnet never adopts it (#8734 D3). A rename records a `magnet.rename` audit row whose summary is `{ from, to, leads, sessions, unclaimed }`. The two operator-writable config URLs (`abandonEmail.resumeUrl`, `followUps[].cta.href`) pass an exact-origin gate against `FRONTEND_URL` before any write, the same discipline the recommender's checkout redirect already applies (#4912). Role floors from `@working-theory/validation`'s permission table (#7636 D2) (D5): list and get serve the full row to `magnets-manage` (owner, admin) and, to a caller holding only `magnets-read` (a member), a LIVE-only summary of exactly `{ id, slug, kind, title, landingPage }` — a member's list is read to completion (at most 20 pages of 50, a `warn` at the cap) and answers `nextCursor: null`, a member's `?cursor=` is a 400, and a draft's get is the same 404 as an absent id — because a magnet's `config` carries `scoring` thresholds, `offers`/`rateTable` and `deliverables` asset keys and no draft is a member's; POST, PATCH and the save need `magnets-manage`, and the Admin's create (`POST …/magnets`) refuses every agent caller `403 agent_refused` before it reads the body (#11810 D9); the per-magnet captured-people lists need `inbox-read` (every role), and for a caller without `magnets-manage` a magnet that is not live is the same 404. All three writes (POST, PATCH and the save) declare a route-level `bodyLimit` (256 KiB) and each records one `recordAgentAction` audit row. **`who` (#8171 D6, #10819)** — who can use the magnet, a People type (`flowWhoSchema`: `visitor` | `lead` | `user`, column default `visitor`, closed by the `flow_definitions_who_domain` CHECK); `user` is the member-area customer switch — is served on every full row and written by the PATCH (a value outside the three is `400`; a PATCH of it alone skips the plan check); the member summary row never carries it. **The completion setting (#8757 D1–D4):** every magnet carries `completion` (`lead` | `invite` | `checkout`, column default `lead`) and `checkoutOffering` (set exactly when `checkout`), two `FlowDefinition` columns closed by three CHECKs and read and written only through `lib/flow-completion-store.ts` (`tenant-db.ts` stays closed under the #8746 contract; `architecture.yaml` lists the store under `paths_scoped`). The migration backfilled `onboarding`, `request-quote` and `job-application` to `invite` by slug (`STANDARD_MAGNET_COMPLETIONS`); a magnet created later is `lead` until #8759. Every full row serves the pair; the member summary never does. The PATCH writes it ALONE — `{ completion, checkoutOffering }` beside any other key is `400 completion_alone`, an offering without a completion or a pair `flowCompletionSettingSchema` refuses `400 validation_failed` — with no plan check, and records `magnet.update` with summary `{ completion }`. `checkout` also needs a person (`403 completion_needs_person` for an agent key), the `commerce` claim (`409 commerce_required`, `503 license-undetermined`) and a key `services/plan-offerings.ts`'s `listPlanOfferings` lists right now (`409 offering_unknown`; a failed read `503 offerings_unavailable`). **The standard onboarding magnet (#8515 D2–D4):** every workspace holds one `diagnostic` magnet at slug `onboarding` (`ONBOARDING_FLOW_SLUG`, `onboardingFlowConfig` in `@working-theory/validation`), `draft` and `who: "user"`, written only by `lib/tenant-db.ts`'s insert-only seed (`createMany` with `skipDuplicates`, so a re-seed creates nothing and never overwrites the owner's edits or an owner's own magnet at that slug): `POST /v1/workspaces` seeds the workspace it just created, after its transaction commits (a failed seed is one `error` line and still a `201`), and the seed-presets CLI (`node dist/bin/seed-presets.js`, run once after deploy) seeds every existing workspace and prints counts only. Its two bare-id exports have one production caller each, pinned by `tests/architecture/onboarding-seed-callers.test.ts`. **The standard Contact form magnet (#8661 D1–D3):** every workspace also holds one `contact` magnet at slug `contact` (`CONTACT_FORM_FLOW_SLUG`, `contactFormFlowConfig`), titled "Contact form", `live`, `who: "visitor"`, landing page `/contact` — Name, Email, a five-option Subject, Message and a required terms checkbox. It is written by the same insert-only seed, from the same two callers (a failed seed is one `contact-form-seed` `error` line and still a `201`), and by `database/seed.ts` for the default workspace; a re-seed never duplicates it or overwrites an edit. The web /contact page reads it on every request through `GET /v1/flows/contact`, and a submission that used it is stamped `flow:contact`, an Inbox submission under "Contact form". **The standard Job application magnet (#8746 D3, D4):** every workspace also holds one `diagnostic` magnet at slug `job-application` (`JOB_APPLICATION_FLOW_SLUG`, `jobApplicationFlowConfig`), titled "Job application", `live`, `who: "visitor"`, landing page `/careers` — First name, Last name and Email (required), Phone and LinkedIn URL — with no `completion` field. It is written by the same insert-only seed, from the same two callers (a failed seed is one `job-application-seed` `error` line and still a `201`), and by `database/seed.ts` for the default workspace; `RESERVED_FLOW_SLUGS` carries its slug, so no flow-engine write, spoke seed or new listing takes it. Each web job page `/careers/<slug>` carries an Apply button to `/careers/<slug>/apply` (#8849), whose Free apply page reads it through `GET /v1/flows/job-application` and draws its field step as a one-step form, and a submission is stamped `flow:job-application`, an Inbox submission under "Job application" whose `name` is first + last and whose `job` is the posting's slug. **The standard trial magnet (#9287 D11, #9301):** every workspace also holds one `diagnostic` magnet at slug `trial` (`TRIAL_FLOW_SLUG`, `trialFlowConfig`), titled "Free trial", `live`, `who: "visitor"`, completion `lead`, landing page `/trial` — First name, Last name, Work email and a required terms box; a site may add a `company`-tagged field, which fills the Person's company. It is written by the same insert-only seed, from the same two callers (a failed seed is one `trial-seed` `error` line and still a `201`), by `database/seed.ts` for the default workspace and by the `20261025120000_trial_magnet` migration for existing workspaces; `RESERVED_FLOW_SLUGS` carries its slug. A completed walk is stamped `flow:trial`, an Inbox submission under "Free trial" whose Person carries the given name, family name and email. Module: `multi-tenant || signal-collectors`, the same gate the review-surface dashboard (`/v1/waitlist-experiments/*`, `/v1/project-listings/*`) already registers under. **`POST …/magnets/save` is `save_magnet`'s twin (#11810):** with an `id` in its body it runs the PATCH's own code; with none and `version: null` it creates a draft magnet — an agent's priced config `403 magnet_pricing_needs_person` (audited), every shape fault one `422 invalid`, a fixed slug `409 slug_reserved`, a slug another magnet holds `409 stale` with that magnet's `currentVersion`, then the Admin create's plan check, origin gate and store call. The list and get are `list_magnets` and `get_magnet`'s twins (#10948); the PATCH, the create and the captured-people lists have no MCP tool, by decision (`tests/parity/README.md`); the public `/v1/flows/*` routes and their two MCP tools are unchanged, pinned by `src/routes/flows/__tests__/parity.test.ts`. **The three new list routes (#6246 S6h)** join every magnet through `Lead.source = 'flow:' + <the resolved magnet's slug>` — the literal string `flow-engine.ts`'s `completeSubmission` stamps on every flow-engine `Lead` row regardless of kind, including `newsletter`/`waitlist` (`Subscriber` is written only by the separate, pre-flow-engine `subscribe_newsletter` path, unrelated to a magnet) — via ONE new `tenantDb(tenant).leads.listBySource(source, { limit })` accessor, an exact-source-equality sibling of #6204's allowlist-scoped `listUnhandledMessages`, served by a new `(workspaceId, source)` composite index on `Lead`. `/signups` expects `kind: "waitlist"`, `/subscribers` expects `"newsletter"`, `/messages` expects `"contact"`; a magnet id absent from the caller's workspace OR resolved to the WRONG kind for the called route is `404 not_found`, indistinguishably (mirrors the existing GET's absent-or-foreign fold). `/signups` and `/subscribers` serve four keys (`id`, `name`, `email`, `createdAt`); `/messages` serves those four plus `handledAt`. Bounded `?limit=` (default 50, max 200), newest-first — mirrors `workspaces/messages.ts`'s own query schema. Applications (Listicle) is deliberately OUT of this surface — `ProjectListing` carries no reverse link to the listicle-kind `FlowDefinition` that captured it, so "scoped to that magnet" cannot be honored without a schema change (split to #6314).
|
|
68
68
|
- `/v1/deliverables/open/:slug` (GET) — an UNGATED file deliverable's bytes, keyed by the flow slug (#8848 D5, `deliverableOpenRoute` in `src/routes/deliverables/index.ts`). Anonymous; the workspace is the caller's (`resolveCallerWorkspace`, keyless through the one-workspace predicate as the flows bullet says; a refused spoke key or an ambiguous deployment `503 tenant_unresolved`), never a request value; no `DATABASE_URL` is `503 deliverables_not_configured`. The flow must be live and carry `deliverable` with `kind: "file"` and `gated: false`; the bytes are its `deliverables` default entry's `Asset`, through `lib/deliverable-asset-store.ts` (a client's file refused), never the legacy store, never a `playbook:` key; served with the grant route's `asset_` headers (`attachment`, pinned extension, `nosniff`, the sandbox CSP, `private, no-store`). Every miss is the file's one uniform 404. Registered in its own encapsulated `deliverableopen` rate-limit scope (60 a minute) with the visitor forward-key digests, and on `FORWARDED_VISITOR_ROUTES`, so a site's proxied reads (`/reports/<slug>/file`) are counted per visitor; the grant route's own budget is unchanged. Module: `signal-collectors`. No MCP twin — a byte download on the grant route's footing, recorded in `tests/parity/README.md`.
|
|
69
|
-
- `/v1/content/{types,search,offerings,pricing,shown-offerings,discovery,:type,:type/:slug}` — public content reads. `GET /v1/content/search`, `GET /v1/content/:type` and `GET /v1/content/:type/:slug` are `search_content`'s, `list_pages`' and `read_content`'s twins (#7167, #7168, #7169): each parses its request with the `@working-theory/validation` exports in `content-reads.ts` (`contentSearchQuerySchema`; `contentListParamsSchema` + `contentListQuerySchema`; `contentPageParamsSchema` + `contentPageQuerySchema`) and answers through the shared builder in `@working-theory/content-adapters` the tool also calls (`searchContentItemList`, `listPagesItemList`, `readContentDocument`), so the pair takes the same arguments and returns the same result — the tool adopted the API; the `/v1` wire shapes are unchanged. `GET /v1/content/offerings` (`?type=&locale=`) is `get_offerings`' twin (#7177), answering `{ ok: true, data: { offerings } }` through `listOfferings` in `@working-theory/content-adapters`, the seam the tool also calls. `GET /v1/content/pricing` (`?slug=&locale=`) is `get_pricing`'s twin (#7178), answering `{ ok: true, data: { tiers } | null }` through `getPricingTiers`. `GET /v1/content/shown-offerings` is the `/pricing` page's Offerings read (#8924), answering `{ ok: true, data: { status: "shown", shownSet } | { status: "unconnected" } | { status: "empty" } }` behind the `commerce` claim, refreshing the snapshot on the bounded non-forced path, with no MCP twin. On a connected workspace with a current shown set, `GET /v1/content/pricing` (the `pricing` page) and `GET /v1/content/offerings` (unless `type=service`) answer that set through `readShownOfferings` (exported from `shown-offerings.ts`, the one read all three share, registered with one `shownSetRouteOptions` in `server.ts`) and `@working-theory/content-adapters`' shown-set mapping (`pricingTiersFromShownSet`, `listOfferingsWithShownSet`), with major-unit prices, `interval` and the full `lookupKey` (offerings: the Service pages, then the shown Products in place of the Product pages, each with `prices`); every other case — no connection, no claim, an expired or empty set, a failed read or mapping (one `warn { outcome: "shown_set_failed", errName }`) — answers page content as before; their MCP twins read the same answer through `apiClient.offerings.shown` (#8933). `GET /v1/content/discovery` is the owner's discovery switch as the deployment itself reads it (#10510, `packages/api/src/routes/content/discovery.ts`): no argument (a query string is ignored); with no `DATABASE_URL` it answers `{ ok: true, data: { discoverable: true } }` before any resolver or database import; otherwise the workspace is `resolveCallerWorkspace`'s (a spoke's key, else the one workspace) — `unresolved` is `404 not_found`, `resolved` answers `readSiteDiscovery` (`packages/api/src/services/site-discovery.ts`, the one reader and writer of the `site.discovery` `SiteSetting` row; no row or an unparsable one reads as on), a throw is `500 internal_error` logged by class name only; every answer appends `x-ailk-spoke-key` to `Vary` (`lib/vary-spoke-key.ts`, the one copy the offerings, pricing and shown-offerings routes share). apps/web and apps/mcp read it through `siteDiscoverable()` in `@working-theory/api-client`; no MCP twin, by decision.
|
|
69
|
+
- `/v1/content/{types,search,offerings,pricing,shown-offerings,discovery,agent-tools,:type,:type/:slug}` — public content reads. `GET /v1/content/search`, `GET /v1/content/:type` and `GET /v1/content/:type/:slug` are `search_content`'s, `list_pages`' and `read_content`'s twins (#7167, #7168, #7169): each parses its request with the `@working-theory/validation` exports in `content-reads.ts` (`contentSearchQuerySchema`; `contentListParamsSchema` + `contentListQuerySchema`; `contentPageParamsSchema` + `contentPageQuerySchema`) and answers through the shared builder in `@working-theory/content-adapters` the tool also calls (`searchContentItemList`, `listPagesItemList`, `readContentDocument`), so the pair takes the same arguments and returns the same result — the tool adopted the API; the `/v1` wire shapes are unchanged. `GET /v1/content/offerings` (`?type=&locale=`) is `get_offerings`' twin (#7177), answering `{ ok: true, data: { offerings } }` through `listOfferings` in `@working-theory/content-adapters`, the seam the tool also calls. `GET /v1/content/pricing` (`?slug=&locale=`) is `get_pricing`'s twin (#7178), answering `{ ok: true, data: { tiers } | null }` through `getPricingTiers`. `GET /v1/content/shown-offerings` is the `/pricing` page's Offerings read (#8924), answering `{ ok: true, data: { status: "shown", shownSet } | { status: "unconnected" } | { status: "empty" } }` behind the `commerce` claim, refreshing the snapshot on the bounded non-forced path, with no MCP twin. On a connected workspace with a current shown set, `GET /v1/content/pricing` (the `pricing` page) and `GET /v1/content/offerings` (unless `type=service`) answer that set through `readShownOfferings` (exported from `shown-offerings.ts`, the one read all three share, registered with one `shownSetRouteOptions` in `server.ts`) and `@working-theory/content-adapters`' shown-set mapping (`pricingTiersFromShownSet`, `listOfferingsWithShownSet`), with major-unit prices, `interval` and the full `lookupKey` (offerings: the Service pages, then the shown Products in place of the Product pages, each with `prices`); every other case — no connection, no claim, an expired or empty set, a failed read or mapping (one `warn { outcome: "shown_set_failed", errName }`) — answers page content as before; their MCP twins read the same answer through `apiClient.offerings.shown` (#8933). `GET /v1/content/discovery` is the owner's discovery switch as the deployment itself reads it (#10510, `packages/api/src/routes/content/discovery.ts`): no argument (a query string is ignored); with no `DATABASE_URL` it answers `{ ok: true, data: { discoverable: true } }` before any resolver or database import; otherwise the workspace is `resolveCallerWorkspace`'s (a spoke's key, else the one workspace) — `unresolved` is `404 not_found`, `resolved` answers `readSiteDiscovery` (`packages/api/src/services/site-discovery.ts`, the one reader and writer of the `site.discovery` `SiteSetting` row; no row or an unparsable one reads as on), a throw is `500 internal_error` logged by class name only; every answer appends `x-ailk-spoke-key` to `Vary` (`lib/vary-spoke-key.ts`, the one copy the offerings, pricing and shown-offerings routes share). apps/web and apps/mcp read it through `siteDiscoverable()` in `@working-theory/api-client`; no MCP twin, by decision. `GET /v1/content/agent-tools` is the public MCP server's read of which paid visitor tools it may list (#11950, `packages/api/src/routes/content/agent-tools.ts`): no argument; for each of `content-write`, `scheduling` and `signal-collectors` it answers `{ licensed, ready, on }` — `licensed` when every row `PUBLIC_AGENT_TOOL_ROUTES` names holds over this server's registered set, `ready` from the module object's own `agentReady(request)` (absent is ready, a rejection is not), `on` unless the workspace's `site.agent-tools` row (`services/agent-tool-switches.ts`, its one reader and writer) lists it in `off`; the workspace and the `404`/`500` arms are the discovery route's, and every answer appends `x-ailk-spoke-key` to `Vary`. apps/mcp reads it through `publicAgentTools` in `@working-theory/api-client`; no MCP twin, by decision.
|
|
70
70
|
- `/v1/auth/tokens`, `/v1/user/{profile,data/:key}` — local auth + user data
|
|
71
71
|
- `/v1/hub-sign-in/codes` (POST), `/v1/hub-sign-in/token` (POST), `/v1/hub-sign-in/revoke` (POST), `/v1/hub-sign-in/me` (GET) — the hub signs in its spokes (#7894, `packages-paid/api-hub/src/routes/auth/hub-sign-in.ts` over `packages-paid/api-hub/src/services/hub-sign-in.ts` — `@working-theory/api-hub` since #9571, which owns the spoke registry and the sign-in trio and hands them to `buildServer({ hub })` through `packages/api/src/lib/hub.ts`; spec `docs/specs/7894-the-hub-signs-in-its-spec.md`): an authorization code with PKCE between a spoke (a confidential client whose `OAuthClient.clientId` IS its `Spoke.id`) and this hub. `codes` is in `authScope` and answers a COOKIE session only (a personal `ApiToken` is 403, an agent key 403 at the preHandler, a hub credential 404): it mints a single-use 60 s code only for an email-verified person and a callback in the client's registered `redirectUris` (exact match), 30 a user per 10 minutes. `token` and `revoke` are in their OWN scope outside `authScope` (per-IP `rateLimitMiddleware`, scope `hubsignin`, 60/min; plus a per-client bucket of 120 exchanges a minute keyed on the VERIFIED client): the caller authenticates with `Authorization: Basic clientId:secret` AND `x-ailk-spoke-key`, which must resolve to the unrevoked spoke whose id is that client — either alone is `401 invalid_client`. `token` consumes the code first and exactly once, then checks the client, the callback and the PKCE verifier (`400 invalid_grant` for any failure, the code gone either way) and issues `ailk_hst_…`, a 24 h credential stored only as a SHA-256 digest in `OAuthAuthorization` (one row per person and spoke, so a new sign-in rotates it); it writes no `Session` row and sets no cookie. `revoke` ends a credential or burns an unexpired code of that client (`{ revoked }`, never an error). `me` answers the credential's person, read live, and is reachable only by that credential, and `billingCustomerId` — the Stripe customer of the caller's Person in the spoke's workspace, read only while that Person's `userId` is the caller and the id is the caller's own Stripe binding, else `null`; since #8047 no anonymous checkout writes it, and the one writer is the hub site's signed-in checkout, so on a spoke's workspace it is `null` until a later writer exists. Its first read links the caller's Person under the verified-email rule (`stampPersonUser` through `resolveMemberPersonId`), so this GET can write. **The credential is admitted by one branch of `middleware/auth.ts`** — only beside the same spoke's key, only while its grant is unrevoked and unexpired, its client enabled and its person's email verified, and only on `HUB_SESSION_ROUTES`, an exact list of 26 method + registered-URL strings, never a prefix (#8220): `GET /v1/hub-sign-in/me`, #7877's three member reads, #8169's eight member reads, #8170's six member writes, #8435's two contact routes, #8438's two consent routes, #8765's account-agreements pair and #8515's onboarding read and write; every other route answers `404` with no handler run (the status the account area's `read()` loads as "nothing for this caller"), and the list is extended only by a reviewed edit. **The per-person budget (#8220 D2, SEC-8169-4):** each person at each spoke gets 60 requests and 10 writes a minute and 30 writes an hour (a fixed hour window from the first admitted write, so up to twice that across a window edge), keyed on the VERIFIED spoke and person and charged only after admission (a refused credential or an off-list route never gets a bucket); over budget is `429 rate_limited` with `Retry-After`. The write limits refuse only writes, and a refused request is not counted. Every line the request logger writes for an admitted request after admission carries `spokeId` (never the key or the credential); a helper logging through the module-level `logger` carries no request binding. The server-wide per-IP limiter still counts all of one spoke's members together — a named residual whose follow-up (the visitor forward key on member calls) must land before Phase 3 (#8163) ships to a live spoke. A bearer write skips the origin check, so the cross-site-request protection for the member writes is the spoke's: its server actions that send a sealed credential carry it (Phase 3, #8163; SEC-8220-11). A completed password reset (`apps/web/auth.ts` `onPasswordReset`) revokes every credential of that person. The operator registers a spoke's client with `spokes sign-in-client --id <spoke_id> --redirect-uri <url>` (`packages-paid/api-hub/src/bin/spokes.ts`; `--disable` switches it off) — `packages-paid/api-hub/src/lib/hub-sign-in-store.ts` is the only file that names `prisma.oAuthClient` and `prisma.oAuthAuthorization`. **The `hub` claim (#9571 D4; #9568 D5):** read only inside `@working-theory/api-hub` (`src/claim.ts`), through `checkLicense()`, registry first — with no `DATABASE_URL` or no registered spoke the gate answers `not-serving` and never reads the licence; with a spoke and the claim, `claimed`; with a spoke and no claim, `unclaimed`, and `codes`, `token`, `me` (a verified credential) and `clients/:clientId` answer `403 feature_required` naming `hub`; an unreadable licence is `undetermined`, `503 license_undetermined` with `Retry-After: 300`. `revoke` is never gated; a definite answer is held 300 s, `not-serving` 30 s, `undetermined` never; `spokes register` refuses without the claim (`hub-claim-missing`). Lead capture, the resolver and magnet completion never read it, and a boot without the package answers as an empty registry (the four routes `404`). No MCP twin for any of the four — a credential exchange between a site and its hub is not an agent-facing call (#3591 exception, the `/v1/auth/tokens` footing). The browser step lives on the hub's web app: `apps/web/app/api/auth/hub/authorize/route.ts`.
|
|
72
72
|
- `/v1/hub-sign-in/entry` (POST), `/v1/hub-sign-in/google` (POST) — the spoke-hosted sign-in entry (#11096, spec `docs/specs/11096-the-spoke-hosts-the-sign-spec.md` D2, D10), in `hubSignInClientRoutes` beside `token`: each authenticates the calling spoke as `token` does (`Authorization: Basic clientId:secret` AND `x-ailk-spoke-key`). `entry` is the hub web's check before it mails a magic link a spoke's form asked for (`{ clientId, redirectUri, email }`, the client's own id and a registered callback, 60 a client a minute and 5 per client and SHA-256 of the lower-cased email per 10 minutes); it sends and writes nothing and logs no email. `google` trades a returning Google person's One Tap ID token (`{ idToken, nonce, origin }`, the origin equal to the client's registered one) for the same credential the code exchange mints, verified against Google's keys with `AILK_GOOGLE_ONE_TAP_CLIENT_ID` as its audience (unset: `404`; set, client info names it as `oneTapClientId`); a `sub` with no Google account row is `404`, never a new user. No MCP twin for either — a site's sign-in step, the `token` footing.
|
|
@@ -99,6 +99,7 @@ Routes are versioned under `/v1/*`:
|
|
|
99
99
|
- `/v1/workspaces/:workspaceId/agents` (GET `?userId=`, POST), `/v1/workspaces/:workspaceId/agents/:agentId/key` (POST), `/v1/workspaces/:workspaceId/agents/:agentId` (PATCH `{ enabled }`), `PUT /v1/workspaces/:workspaceId/agents/:agentId/grants` (`{ grants }`, #7864), and `/v1/agent/context` (GET) — the agent seat (#3591, `src/routes/workspaces/agents.ts` over `src/lib/agent-store.ts`, `// oss: false`). An agent is a stored delegate of one person, bound to one workspace. The five management routes refuse an agent caller outright (403), check `agents-manage` (owner, admin) before any read, and scope every read and write to `tenant.organizationId`, never a body or query value; an agent of another organization is the same 404 as a missing one. Create returns 201 with the key shown once; re-key returns the new key once. Each successful create, re-key, switch and grant change writes an `agents.*` audit record. **Grants (#7864, `docs/specs/7864-agent-key-grants-spec.md`).** An agent acts at `member`, plus any of nine permissions an owner or admin granted it one by one — `content-edit`, `content-publish`, `assets-write`, `magnets-manage`, `meeting-types-manage`, `people-read` since #852, `member-pieces-manage` since #7878, and `people-memory-propose` and `inbox-act` since #9679 (`@working-theory/validation`'s `AGENT_GRANTABLE_PERMISSIONS`, held to that set by the `agents_grants_allowed` CHECK). The grant PUT replaces the whole set (an empty list removes every grant) and refuses a grant the agent's person's own role does not hold, `409 grant_exceeds_person`. The clamp is one function both tenant guards call (`services/default-tenant.ts`'s `agentTenant`): an agent holds a stored grant only while its person's role holds it, so a demoted person's agent keeps the row but not the permission. The routes for the nine check `allows(tenant, "<permission>")`, which reads the grants — except that the six existing inbox `inbox-act` checks still read `can(tenant.role, …)` until #9686 moves them, and `people-memory-propose` is read today only by the workspace knowledge read (#9683, beside `people-read`); every other check keeps `can(tenant.role, …)`, so no other owner or admin permission is reachable. Every agent write on content, assets and meeting types writes one `recordAgentWrite` row naming the agent and its person (magnets already did); a person's writes there stay unaudited. The member-area writes audit every caller through `recordAuditAction`, whose actor names an agent as the agent. No grant raises the ceiling. `/v1/agent/context` is the agent's own read, unchanged by grants, and needs no permission beyond the workspace guard. Same registration scope as the routes above (`workspace || multi-tenant`).
|
|
100
100
|
- `GET /v1/workspaces/:workspaceId/clients` and `DELETE /v1/workspaces/:workspaceId/clients/:clientId[?userId=]` — the workspace's Connected clients (#10393, `src/routes/workspaces/clients.ts` over `src/lib/connected-clients-store.ts`, `// oss: false`). The GET lists, as one table, the workspace's live OAuth authorizations (one row per client and person, from the token rows bound to this workspace; `lastUsedAt` is the newest sign-in or refresh) and its enabled agent keys, each row `kind`, `id`, `client.name`, `person`, `scopes`, `lastUsedAt` and never a token or key. A person holding `agents-manage` (owner, admin) sees every row; anyone else, an agent principal included, sees only their own person's. The DELETE refuses every agent caller (403), ends an OAuth authorization by deleting its token rows for this workspace only (a caller without `agents-manage` may name only themselves — another person's row is the same 404 as a missing one) and an agent key by switching it off (`agents-manage`), touches no session, and writes one audit row and one `connected-client-revoked` log line. The GET's MCP twin is `list_connected_clients`; the DELETE has no tool, by decision. Same registration scope as the routes above (`workspace || multi-tenant`).
|
|
101
101
|
- `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
|
+
- `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).
|
|
102
103
|
- `/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`.
|
|
103
104
|
- `/v1/workspaces/:workspaceId/library/pages` (GET, `?type=&status=&limit=&page=`) and `/v1/workspaces/:workspaceId/library/assets` (GET, `?tag=&type=&limit=&page=`) — the library reads, each answering `{ workspace: { id, name }, items, total, page, nextPage }` newest first (`limit` 1–200, default 50; `page` from 1; `libraryPageListQuerySchema` / `libraryAssetListQuerySchema` in `@working-theory/validation`). The page list (`packages-paid/api-content-write/src/routes/workspaces/library-pages.ts`, in the content-write tenant scope) serves every page, drafts included, as `{ id, type, slug, locale, title, status, updatedAt }`; `status` is the Docs list's rule — `disabled` when switched off, else `live` when a version is published (a newer draft included), else `draft` — and the route needs `content-edit` (`allows`, so an agent needs the grant). A disabled page is asked for only on a person's behalf: `tenantDb` keeps every disabled row from an agent. The asset list (`packages-paid/api-workspace/src/routes/assets/manage.ts`, beside the manage list, `assets-read`) serves each file's whole record (#11801), `{ id, key, filename, title, description, version, type, size, dimensions, audience, tags, url, updatedAt }` — `title` and `description` with hidden code points removed (`null` when none is written, never left out), `version` the file's record version (`r<n>`, #11803), `type` the content type, `size` its bytes, `dimensions` a raster image's `{ width, height }` as the Admin's Details panel shows it — read from the head of the file — the few bytes a PNG, GIF or WebP needs, at most 64 KiB for a JPEG or AVIF (`tenantDb.assets.fileHeads`, which never reads a private, Knowledge or disabled file) for the answered page's images alone, a JPEG's Exif and an AVIF's `irot` quarter-turn swapping the two (`routes/assets/dimensions.ts`) — and `null` for an SVG, any other file, or a header that does not say, `audience` who may read it, `url` the public read's path, `updatedAt` when the current file was uploaded — the `createdAt` of the version `currentVersion` names (`tenantDb.assets.currentVersionTimes`), so a replace moves it, a restore takes the restored version's upload time, and a metadata edit does not move it; the list is ordered by it, newest first — narrowed by an exact `tag` and a `type` that is a whole content type (`image/png`) or its top-level part (`image`); a file tagged `private` never lists, `?tag=private` included. MCP parity: `list_workspace_pages` and `list_assets` on `/mcp/workspace`.
|
|
104
105
|
- `/v1/workspaces/:workspaceId/assets/save` (POST, #11803) — save a file's title, description and type: the body is `assetSaveBodySchema` (`{ address: { key }, version: "r<n>" | null, words: { title?, description? }, fields?: { type? } }`, strict at every level; `fields.type` (#11879) is one of the ten asset types and replaces the one the file held, every other tag kept; a type-only save sends `words: {}`), and the answer `{ kind: "asset", address, version, fields: { type }, words, state: "live" }` with the new record version. `assets-write` (`allows`, so an agent may hold it by grant) before the body is read; a wrong body is `422 invalid` with `details.issues` (`{ path, message }`, at most 20); a file the caller may not reach — for an agent also a disabled, private or Knowledge one — the plugin's one `404 not_found`; a save based on another record version, or on `null`, `409 stale` with `details.currentVersion`. One conditional UPDATE (`tenantDb.assets.saveRecord`) writes only `title`, `description`, the type tag and `record_version`, whose `where` carries the version and the reach — and, with a type, the tags it read, so a concurrent tags write reruns it. Every agent call that reaches the body is audited (`assets.save`). An agent's `PATCH …/assets/:assetId` is refused `403 agent_refused`; a person's PATCH of a title or description moves the record version. MCP parity: `save_asset` on `/mcp/workspace`.
|
|
@@ -245,7 +246,9 @@ sweep's own DB constraint (never a caller-side lock).
|
|
|
245
246
|
- Don't bundle `apps/api` (esbuild, rollup, webpack). Slice specifiers cannot survive it — see `## Deploy path`.
|
|
246
247
|
- 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.
|
|
247
248
|
|
|
248
|
-
Last updated: 2026-11-
|
|
249
|
+
Last updated: 2026-11-19 — #11953: a bullet for `GET`/`PUT /v1/workspaces/:workspaceId/agent-tools` — verified against `packages-paid/api-workspace/src/routes/workspaces/agent-tools.ts`, `packages/api/src/services/agent-tool-state.ts` and `packages/api/src/services/agent-tool-switches.ts`.
|
|
250
|
+
|
|
251
|
+
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`.
|
|
249
252
|
|
|
250
253
|
Prior: 2026-11-17 — #11878: the kinds bullet names the four lists beside `kinds` — `forms`, `offSiteForms`, `formats`, `origins` — and their source — verified against `packages/validation/src/contract/admin-kinds.ts`, `packages/validation/src/schemas/page-types.ts` and `packages/metadata/src/mcp-tool-catalog.ts`.
|
|
251
254
|
|
|
@@ -56,6 +56,9 @@ MCP_CORS_WRITE_ALLOWED_ORIGINS=
|
|
|
56
56
|
# "multi-tenant,scheduling". Unset (the default) or "" means NO paid modules
|
|
57
57
|
# — installed modules enable themselves explicitly. Recognized keys: docs,
|
|
58
58
|
# multi-tenant, scheduling, content-write. Must match apps/api's value.
|
|
59
|
+
# It gates the signed-in /mcp/workspace tools only (#11950): the public
|
|
60
|
+
# anonymous server lists a paid visitor tool when its package is installed
|
|
61
|
+
# and the hub's GET /v1/content/agent-tools answers it licensed, ready and on.
|
|
59
62
|
# AILK_ENABLED_MODULES=
|
|
60
63
|
|
|
61
64
|
# ── Abuse protection ───────────────────────────────────────────────────────────
|
|
@@ -78,9 +81,9 @@ MCP_ABUSE_CREATE_BOOKING_DAILY_CAP=20
|
|
|
78
81
|
# one-step flow creates a Lead in one call.
|
|
79
82
|
MCP_ABUSE_SUBMIT_FLOW_STEP_DAILY_CAP=50
|
|
80
83
|
|
|
81
|
-
# Comma-separated list of User-Agent substrings to
|
|
82
|
-
#
|
|
83
|
-
#
|
|
84
|
+
# Comma-separated list of User-Agent substrings to refuse (case-insensitive),
|
|
85
|
+
# on write-tool calls only — never the handshake, tools/list or a read tool.
|
|
86
|
+
# There is no built-in list, and a missing User-Agent is never refused.
|
|
84
87
|
# Example: BadBot,EvilCrawler
|
|
85
88
|
MCP_ABUSE_BLOCKED_USER_AGENTS=
|
|
86
89
|
|
|
@@ -26,8 +26,9 @@ ships to every scaffold and fails on any other import):
|
|
|
26
26
|
`import()` each, rendered by create-ailk from `MODULE_SLICES` (`paidMcpToolPackages`) and
|
|
27
27
|
`apps/mcp/package.json`; `// oss: false` on line 1 exactly when a pack is present. The
|
|
28
28
|
monorepo copy carries all three. A module-gated or signed-in tool resolves from the union of
|
|
29
|
-
the loaded packs at call time
|
|
30
|
-
|
|
29
|
+
the loaded packs at call time. A module-gated anonymous tool registers only while a loaded
|
|
30
|
+
pack serves it (#11950), so a site that does not carry its pack never lists it; the tool error
|
|
31
|
+
`MCP slice drift: no installed package serves '<name>'` is left as the drift backstop.
|
|
31
32
|
|
|
32
33
|
The suites that stay here are the composition root's: `api-parity`, `pro-tool-call-gate`,
|
|
33
34
|
`workspace-surface`, `write-tool-guard` and `create-booking-guard` (they call paid handlers through
|
|
@@ -124,47 +125,51 @@ Every tool maps 1:1 to an `apps/api` endpoint. When you change a tool, change th
|
|
|
124
125
|
|
|
125
126
|
## The free anonymous tools (enabled at launch)
|
|
126
127
|
|
|
127
|
-
**The HTTP write branch (6).** `WRITE_TOOLS` in `src/http-transport.ts` — `capture_lead`, `subscribe_newsletter`, `request_callback`, `start_purchase`, `create_booking`, `submit_flow_step` — takes the write-origin allow-list and the AbuseGuard (
|
|
128
|
+
**The HTTP write branch (6).** `WRITE_TOOLS` in `src/http-transport.ts` — `capture_lead`, `subscribe_newsletter`, `request_callback`, `start_purchase`, `create_booking`, `submit_flow_step` — takes the write-origin allow-list and the AbuseGuard (the operator's `MCP_ABUSE_BLOCKED_USER_AGENTS` list, honeypot, email format, per-IP daily cap); every other tool takes the read branch, which refuses no caller by its User-Agent (#11959). A tool that sends caller-chosen data to the hub belongs in it: `__tests__/write-tool-guard.test.ts` fails when a catalog tool that sends a non-GET request through `@working-theory/api-client` is missing, and makes every new catalog tool pick a branch (#8071).
|
|
128
129
|
|
|
129
130
|
**Read (9):** `list_pages`, `read_content`, `search_content`, `get_site_info`, `get_business_hours`, `get_locations`, `get_offerings`, `get_pricing`, `get_faq`. The first three adopted their `apps/api` routes' arguments and results (#7167, #7168, #7169 — the operator's decision of 2026-10-19): `search_content` takes `q` and answers the route's `ItemList` (`query`, `items`, `totalItems`); `list_pages` requires `type`, takes `page`/`pageSize` and answers the paginated `ItemList` (`items`, `pagination`); `read_content` takes `include` and answers the page's JSON-LD at the root with `page`, plus `body` only with `include: "body"` — a miss is the not-found body. Each parses the same `@working-theory/validation` export its route parses with and answers through the same `@working-theory/content-adapters` builder, so the parity guard holds them as `twin`s
|
|
130
131
|
**Conversion-write (3):** `capture_lead`, `subscribe_newsletter`, `request_callback` — each takes the body its `POST /v1/leads/{submit,subscribe,callback}` route parses (`leadSubmitBodySchema`: `source`, `email`, `consent`, `payload`; `leadSubscribeBodySchema`: `email`, `source`; `leadCallbackBodySchema`: `name`, `phone`, `preferredTime`, `payload`) and returns the route's 201 body `{ id, persisted, email }` unchanged (#7171, #7172, #7173 — the operator's decision of 2026-10-19), so the parity guard holds the three as `twin`s. `source` is the agent's to choose — `mcp` unless the operator says otherwise — and a consent-bearing source needs `consent: true`, exactly as a form does; `capture_lead` still spreads the spoke marker `payload.site` from `AILK_LEAD_SITE` last. The AbuseGuard reads the first two's `email` at the top level, else inside `payload` (the route lifts it from there), so a malformed address is refused wherever it sits
|
|
131
132
|
**Maintenance (2):** `audit`, `create_project` (stdio only, #9965 D13)
|
|
132
|
-
**Flow (
|
|
133
|
-
**Booking (4):** `list_availability`, `get_event_meta`, `list_meetings`, `create_booking` — module-gated (`module: "scheduling"`) and licence-feature-tagged (`feature: "scheduling"`, #7136), gated on the deployment's `scheduling` licence feature under `MCP_FEATURE_GATE_MODE`. `create_booking` takes the HTTP write branch (its own daily cap, `MCP_ABUSE_CREATE_BOOKING_DAILY_CAP`, default 20, and an `attendee.email` format check — #8071). `list_meetings` (#8843 D5) twins `GET /v1/schedule/meetings`: it takes no argument and returns the site's Live meetings — slug, visibility, position and whether each can be booked, plus a bookable one's calLink, title, length, description and price; `private` means unlisted, not secret
|
|
134
|
-
**Redirect (1):** `get_redirect` (#10202 D8) — module-gated (`module: "content-write"`) and licence-feature-tagged (`feature: "workspace"`, the content-write claim), gated on the deployment's `workspace` licence feature under `MCP_FEATURE_GATE_MODE`. It twins `GET /v1/redirects`: given an old site path (and an optional locale) it returns where the site permanently redirects it — `{ from, to, permanent: true }` — or the route's not-found body. Its handler rides `@working-theory/mcp-workspace`'s anonymous `tools` (`redirect.ts`), the pack the `workspace` and `multi-tenant` modules carry, and calls the module-level `apiClient` with no agent key
|
|
133
|
+
**Flow (3):** `list_flows`, `get_flow`, `submit_flow_step` — `list_flows` (#11954) twins `GET /v1/flows`: it takes no argument and returns each live visitor magnet's slug, kind, title and purpose line, so an agent learns a slug before `get_flow`. All three are module-gated (`module: "signal-collectors"`, D-48, #5366) and licence-feature-tagged (`feature: "flows-deliverables"`, #7136): identity-blind like every tool in this list, registered only when its pack is installed and the hub's `GET /v1/content/agent-tools` answers `signal-collectors` licensed, ready (a live visitor magnet) and on (#11950), and gated on the deployment's `flows-deliverables` licence feature under `MCP_FEATURE_GATE_MODE`, the same shape Booking below has. `submit_flow_step` takes the HTTP write branch (its own daily cap, `MCP_ABUSE_SUBMIT_FLOW_STEP_DAILY_CAP`, default 50 — #8071)
|
|
134
|
+
**Booking (4):** `list_availability`, `get_event_meta`, `list_meetings`, `create_booking` — module-gated (`module: "scheduling"`: registered only when its pack is installed and the hub answers `scheduling` licensed, ready — a connected calendar — and on, #11950) and licence-feature-tagged (`feature: "scheduling"`, #7136), gated on the deployment's `scheduling` licence feature under `MCP_FEATURE_GATE_MODE`. `create_booking` takes the HTTP write branch (its own daily cap, `MCP_ABUSE_CREATE_BOOKING_DAILY_CAP`, default 20, and an `attendee.email` format check — #8071). `list_meetings` (#8843 D5) twins `GET /v1/schedule/meetings`: it takes no argument and returns the site's Live meetings — slug, visibility, position and whether each can be booked, plus a bookable one's calLink, title, length, description and price; `private` means unlisted, not secret
|
|
135
|
+
**Redirect (1):** `get_redirect` (#10202 D8) — module-gated (`module: "content-write"`: registered only when its pack is installed and the hub answers `content-write` licensed — its redirect route served — and on, #11950) and licence-feature-tagged (`feature: "workspace"`, the content-write claim), gated on the deployment's `workspace` licence feature under `MCP_FEATURE_GATE_MODE`. It twins `GET /v1/redirects`: given an old site path (and an optional locale) it returns where the site permanently redirects it — `{ from, to, permanent: true }` — or the route's not-found body. Its handler rides `@working-theory/mcp-workspace`'s anonymous `tools` (`redirect.ts`), the pack the `workspace` and `multi-tenant` modules carry, and calls the module-level `apiClient` with no agent key
|
|
135
136
|
|
|
136
|
-
### Why the parity test counts
|
|
137
|
+
### Why the parity test counts 23 and a keyless server registers 21 (22 over stdio once Free is released)
|
|
137
138
|
|
|
138
|
-
- **
|
|
139
|
-
`packages/metadata/src/mcp-tool-catalog.ts` defines
|
|
139
|
+
- **23 in the `TOOLS` array / parity test**: the `TOOLS` array in
|
|
140
|
+
`packages/metadata/src/mcp-tool-catalog.ts` defines 23 anonymous tools; the
|
|
140
141
|
parity test counts that full array. It also holds the sixty-two signed-in
|
|
141
142
|
workspace tools (#3591; the content-suggestion pair `draft_page_suggestions`
|
|
142
143
|
and `decide_page_suggestion` since #10218; the draft pair `save_draft` and
|
|
143
144
|
`read_report` since #10336; the knowledge-base pair `read_knowledge` and
|
|
144
145
|
`read_knowledge_doc` since #10345), which no anonymous view returns — see § The
|
|
145
146
|
signed-in workspace surface below.
|
|
146
|
-
- **
|
|
147
|
-
while the Free level is held or over HTTP —
|
|
148
|
-
released** (#5971, #9534, #9965 D13): `createMcpServer` (`apps/mcp/src/server.ts`) registers
|
|
147
|
+
- **21 registered on a KEYLESS deployment, 22 on a commerce-claimed one,
|
|
148
|
+
while the Free level is held or over HTTP — 22 and 23 over stdio once it is
|
|
149
|
+
released, with every module's tools served** (#5971, #9534, #9965 D13): `createMcpServer` (`apps/mcp/src/server.ts`) registers
|
|
149
150
|
`getMcpToolRegistrations()` minus the topology seam's `UNSERVED_MCP_TOOLS`,
|
|
150
151
|
minus `create_project` while create-ailk's `release-scope.json` holds
|
|
151
152
|
`levels.free` (the release-scope filter, #9534) and on any transport but
|
|
152
153
|
stdio (the transport filter, #9965 D13), minus `OSS_DISABLED_TOOLS`
|
|
153
|
-
(now empty), minus module-gated tools
|
|
154
|
+
(now empty), minus module-gated tools not served from state (#11950: the
|
|
155
|
+
tool's pack is installed and the hub's `GET /v1/content/agent-tools` answers
|
|
156
|
+
its capability licensed, ready and on — read at boot and every
|
|
157
|
+
`MCP_CLAIM_REFRESH_MS` by `lib/public-agent-tools.ts`, failing closed;
|
|
158
|
+
`AILK_ENABLED_MODULES` gates `/mcp/workspace` only), minus any
|
|
154
159
|
`addon`-tagged tool whose claim this deployment does not hold.
|
|
155
160
|
`start_purchase` carries `addon: "commerce"`, so it is the one entry whose
|
|
156
161
|
presence depends on the licence — one fewer without the claim.
|
|
157
|
-
- **
|
|
162
|
+
- **21 anonymous tools while Free is held or over HTTP (22 over stdio once released)**: since #5853 retired the three content-write
|
|
158
163
|
tools, every registered tool remains anonymous — call-time gating checks a
|
|
159
|
-
licence claim, never an identity. The
|
|
160
|
-
(`get_flow`, `submit_flow_step`, `list_availability`, `get_event_meta`,
|
|
164
|
+
licence claim, never an identity. The eight carrying `tier: "pro"`
|
|
165
|
+
(`list_flows`, `get_flow`, `submit_flow_step`, `list_availability`, `get_event_meta`,
|
|
161
166
|
`list_meetings`, `create_booking`, `get_redirect`) are gated at REGISTRATION **and at call time** (#7315):
|
|
162
|
-
each needs its
|
|
167
|
+
each needs its pack installed and its capability served by the hub (#11950), and each catalog row names the licence `feature:`
|
|
163
168
|
that entitles it. `start_purchase` is gated at call time by both this
|
|
164
169
|
server-wide gate and its own Gate 2 in `tools/purchase.ts`.
|
|
165
170
|
`MCP_FEATURE_GATE_MODE` (`packages/metadata`) decides what an unheld
|
|
166
|
-
feature does. In `"warn"` mode (this release) the
|
|
167
|
-
|
|
171
|
+
feature does. In `"warn"` mode (this release) the eight register on the four
|
|
172
|
+
facts above alone, and the boot (`bootMcp()`) logs one warning (stderr) per tool
|
|
168
173
|
served without its feature. In `"refuse"` mode (the next release) they
|
|
169
174
|
also need the deployment's licence to hold the feature, and
|
|
170
175
|
`/.well-known/mcp.json` drops them in step. The claim is resolved at boot
|
|
@@ -182,8 +187,8 @@ here. Spec: `docs/specs/3591-tenant-scoped-agent-auth-secure-spec.md` D13–D16.
|
|
|
182
187
|
anonymous path: POST only and always stateless (a fresh transport and
|
|
183
188
|
`createWorkspaceMcpServer()` per request, no session map), so GET and DELETE are 405. A POST
|
|
184
189
|
needs `Authorization: Bearer ailk_agt_<43 base64url>` — anything else, a personal `tok_` token
|
|
185
|
-
included, is 401 before the body is read. A JSON-RPC batch is 400.
|
|
186
|
-
|
|
190
|
+
included, is 401 before the body is read. A JSON-RPC batch is 400. Rate limiting is apps/api's
|
|
191
|
+
per-agent limiter.
|
|
187
192
|
- **apps/mcp checks only the key's shape.** The key is attached as the SDK's `req.auth` for that
|
|
188
193
|
request alone and reaches a tool as `extra.authInfo.token`. apps/api is the one place it is
|
|
189
194
|
checked, and its tenant guard and the caller's clamped role decide every answer.
|
|
@@ -334,7 +339,9 @@ Example (lead routing):
|
|
|
334
339
|
- Don't add a tool without the matching `apps/api` endpoint.
|
|
335
340
|
- Don't put business logic in tool handlers — they're adapters.
|
|
336
341
|
|
|
337
|
-
Last updated: 2026-11-
|
|
342
|
+
Last updated: 2026-11-19 — #11954: `list_flows` (`mcp-signal-collectors`' `list_flows.ts`) twins `GET /v1/flows`, which registers inside `getFlowRoute` — 23 in `TOOLS`, 21 registered keyless and 22 commerce-claimed while Free is held, eight `tier: "pro"`; the nine visitor tools' descriptions say when to use each and what comes next — verified against `packages/metadata/src/mcp-tool-catalog.ts`, `packages-paid/mcp-signal-collectors/src/index.ts`, `packages-paid/api-signal-collectors/src/routes/flows/index.ts` and `tests/parity/api-parity/kinds/site.ts`.
|
|
343
|
+
|
|
344
|
+
Prior: 2026-11-18 — #11909: `list_kinds` and `GET /v1/workspaces/:workspaceId/kinds` answer ten formats, the tenth `platform`, and five off-site forms, the fifth `profile` (`platform` only), with `proposal` also allowing `platform`; only the two constants change, and the pair stays a twin — verified against `packages/validation/src/contract/admin-kinds.ts`, `packages/metadata/src/mcp-tool-catalog.ts` and `tests/parity/api-parity/fixtures/site-wire.ts`.
|
|
338
345
|
|
|
339
346
|
Prior: 2026-11-17 — #11882: `open_page` and `open_document` take `as` (`record` or `working-copy`), with `form` its old name for one release; the route refuses the two when they disagree, and the pair stays a twin — verified against `packages/metadata/src/mcp-tool-catalog.ts`, `packages-paid/mcp-workspace/src/content_draft.ts` and `tests/parity/api-parity/kinds/site.ts`.
|
|
340
347
|
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* MCP_ABUSE_START_PURCHASE_DAILY_CAP=20
|
|
18
18
|
* MCP_ABUSE_CREATE_BOOKING_DAILY_CAP=20
|
|
19
19
|
* MCP_ABUSE_SUBMIT_FLOW_STEP_DAILY_CAP=50
|
|
20
|
-
* MCP_ABUSE_BLOCKED_USER_AGENTS= (comma-separated substrings)
|
|
20
|
+
* MCP_ABUSE_BLOCKED_USER_AGENTS= (comma-separated substrings; write tools only)
|
|
21
21
|
*
|
|
22
22
|
* Content adapter (all optional; `CONTENT_ADAPTER` default: mdx):
|
|
23
23
|
* CONTENT_ADAPTER=mdx|projection|database
|