create-ailk 0.42.0 → 0.42.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/export-content.d.ts +10 -3
- package/dist/export-content.js +52 -8
- package/dist/lib/import-mdx.d.ts +2 -0
- package/dist/lib/import-mdx.js +36 -15
- package/dist/migrate-content.d.ts +12 -3
- package/dist/migrate-content.js +62 -11
- package/package.json +3 -3
- package/templates/apps/api/CLAUDE.md +1 -0
- package/templates/apps/mcp/CLAUDE.md +7 -3
- package/templates/apps/web/CLAUDE.md +3 -1
- package/versions.json +51 -51
package/dist/export-content.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ export declare class ExportContentRefusedError extends Error {
|
|
|
5
5
|
readonly exitCode = 2;
|
|
6
6
|
constructor(message: string);
|
|
7
7
|
}
|
|
8
|
+
/** The site's words codec, and the importer's tag rule when the site's validation package carries it. */
|
|
9
|
+
type ExportCodec = WordsCodec & {
|
|
10
|
+
publicPageTags?: (tags: readonly unknown[]) => string[];
|
|
11
|
+
};
|
|
8
12
|
export declare const SPOKE_HINT = "the site's read does not serve this workspace's published version \u2014 is the spoke at --store database?";
|
|
9
13
|
/**
|
|
10
14
|
* The site-relative file a stored page is written to, and whether it is
|
|
@@ -18,7 +22,7 @@ export declare function fileFor(targetDir: string, type: string, slug: string, l
|
|
|
18
22
|
* The file whose import yields `content` again with `sections` as its layout,
|
|
19
23
|
* or why there is none.
|
|
20
24
|
*/
|
|
21
|
-
export declare function recombine(content: Record<string, unknown>, sections: readonly unknown[] | undefined, codec:
|
|
25
|
+
export declare function recombine(content: Record<string, unknown>, sections: readonly unknown[] | undefined, codec: ExportCodec, editorial: boolean, pinned?: Record<LanguageItemKind, Map<string, Record<string, string>>>): {
|
|
22
26
|
text: string;
|
|
23
27
|
} | {
|
|
24
28
|
reason: string;
|
|
@@ -32,7 +36,9 @@ export interface ExportContentOptions {
|
|
|
32
36
|
env?: NodeJS.ProcessEnv;
|
|
33
37
|
fetch?: typeof globalThis.fetch;
|
|
34
38
|
/** Injectable for tests; defaults to the site's installed codec. */
|
|
35
|
-
codec?:
|
|
39
|
+
codec?: ExportCodec;
|
|
40
|
+
/** Injectable for tests; the wait before a rate-limited retry. */
|
|
41
|
+
sleep?: (ms: number) => Promise<void>;
|
|
36
42
|
onLine?: (line: string) => void;
|
|
37
43
|
}
|
|
38
44
|
export interface ExportedPage {
|
|
@@ -54,5 +60,6 @@ export interface ExportContentArgs {
|
|
|
54
60
|
workspaceId: string | undefined;
|
|
55
61
|
help: boolean;
|
|
56
62
|
}
|
|
57
|
-
export declare const EXPORT_CONTENT_HELP = "create-ailk export-content \u2014 write every published page back to its content file.\n\nUsage:\n AILK_AGENT_KEY=<key> create-ailk export-content [<dir>] [--dry-run] [--api-url <origin>] [--workspace <wksp_id>]\n\nArguments:\n <dir> The site. Defaults to the current dir.\n\nOptions:\n --dry-run Print what would be written, and write nothing.\n --api-url <origin> The API origin that holds the workspace \u2014 on a\n spoke, its hub's. Else AILK_API_URL.\n --workspace <wksp_id> The workspace. Else AILK_WORKSPACE_ID.\n -h, --help Show this help.\n\nThe rollback for a cutover: every page the workspace list reports published\nin the default locale is written to the file migrate-content reads it from\n\u2014 content/en/<Type>/<slug>.mdx (or the legacy content/<Type>/<slug>.mdx that\nexists), apps/web/content/en/blog/<slug>.mdx for a post,\napps/web/content/en/blog/<series>/<slug>.mdx for a post in a series and the\nsame under docs for a docs page; a post or doc goes to whichever of\n<slug>.mdx or <slug>/index.mdx is on disk, <slug>.mdx when neither is \u2014 with\nits words moved back into its sections, so a re-run of migrate-content\nreports every page unchanged. Published edits are\
|
|
63
|
+
export declare const EXPORT_CONTENT_HELP = "create-ailk export-content \u2014 write every published page back to its content file.\n\nUsage:\n AILK_AGENT_KEY=<key> create-ailk export-content [<dir>] [--dry-run] [--api-url <origin>] [--workspace <wksp_id>]\n\nArguments:\n <dir> The site. Defaults to the current dir.\n\nOptions:\n --dry-run Print what would be written, and write nothing.\n --api-url <origin> The API origin that holds the workspace \u2014 on a\n spoke, its hub's. Else AILK_API_URL.\n --workspace <wksp_id> The workspace. Else AILK_WORKSPACE_ID.\n -h, --help Show this help.\n\nThe rollback for a cutover: every page the workspace list reports published\nin the default locale is written to the file migrate-content reads it from\n\u2014 content/en/<Type>/<slug>.mdx (or the legacy content/<Type>/<slug>.mdx that\nexists), apps/web/content/en/blog/<slug>.mdx for a post,\napps/web/content/en/blog/<series>/<slug>.mdx for a post in a series and the\nsame under docs for a docs page; a post or doc goes to whichever of\n<slug>.mdx or <slug>/index.mdx is on disk, <slug>.mdx when neither is \u2014 with\nits words moved back into its sections, so a re-run of migrate-content\nreports every page unchanged. Published edits are kept. The hub's own tags\nare not written: a blog post keeps its public tags, every other page none. A\nrate-limited read waits out its retry-after, up to three times, and\ncontinues. A page with a draft ahead of its published version fails by name:\npublish or revert it in Admin, then re-run. The site's own API read must\nserve the workspace's published version (on a spoke, the hub's row at\n--store database). Each page prints created, written, unchanged or failed.\nThe agent key needs the content-edit grant; on a spoke, AILK_SPOKE_KEY is\nneeded too. Exit 0 when no page failed, 1 when any did, 2 on a refusal.\n";
|
|
58
64
|
export declare function parseExportContentArgs(argv: string[]): ExportContentArgs;
|
|
65
|
+
export {};
|
package/dist/export-content.js
CHANGED
|
@@ -52,6 +52,12 @@ const EDITORIAL_DIRS = {
|
|
|
52
52
|
const EDITORIAL_RENAMES = { publishedAt: "date", updatedAt: "updated" };
|
|
53
53
|
/** Keys an editorial file does not carry: its path decides both. */
|
|
54
54
|
const EDITORIAL_DROPPED = new Set(["type", "slug"]);
|
|
55
|
+
/**
|
|
56
|
+
* The blog collection, whose sent `tags` the store keeps (`PAGE_TAG_TYPES`,
|
|
57
|
+
* the validation package's `site-fields.ts`, restated: no runtime dep). Every
|
|
58
|
+
* other page's stored `tags` are the hub's own (#11750 D2).
|
|
59
|
+
*/
|
|
60
|
+
const BLOG_TAG_TYPES = new Set(["BlogPosting", "BlogList"]);
|
|
55
61
|
/** The hub's live-source mark (#10898 D7): evidence about the draft's words, never a file's key. */
|
|
56
62
|
const LIVE_SOURCE_KEY = "liveSource";
|
|
57
63
|
/**
|
|
@@ -64,9 +70,9 @@ const WRITTEN_FROM_KEY = "writtenFrom";
|
|
|
64
70
|
/**
|
|
65
71
|
* Never written from `siteFields` (#10806 D6): a mapped fumadocs key, an
|
|
66
72
|
* address key, the strip marker, the live-source mark, the written-from
|
|
67
|
-
* record, or a prototype name.
|
|
73
|
+
* record, the stored tags (#11750 D3), or a prototype name.
|
|
68
74
|
*/
|
|
69
|
-
const NOT_SITE_FIELDS = new Set(["date", "updated", "type", "slug", "oss", "siteFields", LIVE_SOURCE_KEY, WRITTEN_FROM_KEY, "__proto__"]);
|
|
75
|
+
const NOT_SITE_FIELDS = new Set(["date", "updated", "type", "slug", "oss", "siteFields", LIVE_SOURCE_KEY, WRITTEN_FROM_KEY, "tags", "__proto__"]);
|
|
70
76
|
const INDEX_SLUG = "index";
|
|
71
77
|
/** The store's address shapes, restated (create-ailk has no runtime dep): a path built from them stays in the site. */
|
|
72
78
|
const TYPE_SHAPE = /^[A-Z][A-Za-z]*$/;
|
|
@@ -74,8 +80,15 @@ const SLUG_SHAPE = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
|
|
|
74
80
|
const LOCALE_SHAPE = /^[a-z]{2}(-[A-Z]{2})?$/;
|
|
75
81
|
/** A blog series' shape (`PARENT` in `lib/import-mdx.ts`), restated: a directory built from it stays in the blog. */
|
|
76
82
|
const SERIES_SHAPE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
77
|
-
/**
|
|
78
|
-
const
|
|
83
|
+
/** Every read, and each retry of it, times out as the kit's other reads do (`inventory.ts`). */
|
|
84
|
+
const REQUEST_TIMEOUT_MS = 15_000;
|
|
85
|
+
/**
|
|
86
|
+
* A 429 is waited out and sent again this many times; the next one is the
|
|
87
|
+
* read's answer. Each wait is the `retry-after` in whole seconds from 1 to the
|
|
88
|
+
* max, else the max (`lib/import-mdx.ts`, restated, as `language-import.ts` does).
|
|
89
|
+
*/
|
|
90
|
+
const RATE_LIMIT_RETRIES = 3;
|
|
91
|
+
const RATE_LIMIT_WAIT_MAX_S = 60;
|
|
79
92
|
export const SPOKE_HINT = "the site's read does not serve this workspace's published version — is the spoke at --store database?";
|
|
80
93
|
// ── File addressing (D6) ────────────────────────────────────────────────────
|
|
81
94
|
/**
|
|
@@ -113,6 +126,16 @@ export function recombine(content, sections, codec, editorial, pinned) {
|
|
|
113
126
|
for (const [key, value] of Object.entries(editorial ? stored : rest)) {
|
|
114
127
|
if (key === LIVE_SOURCE_KEY || key === WRITTEN_FROM_KEY || (editorial && EDITORIAL_DROPPED.has(key)))
|
|
115
128
|
continue;
|
|
129
|
+
if (key === "tags") {
|
|
130
|
+
// #11750 D1/D2 — the store writes `tags` itself: a blog page keeps the
|
|
131
|
+
// public subset the importer sends, any other page none of them.
|
|
132
|
+
const own = editorial && BLOG_TAG_TYPES.has(String(content["type"])) && Array.isArray(value) && codec.publicPageTags
|
|
133
|
+
? codec.publicPageTags(value)
|
|
134
|
+
: [];
|
|
135
|
+
if (own.length > 0)
|
|
136
|
+
frontmatter[key] = own;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
116
139
|
frontmatter[editorial ? (EDITORIAL_RENAMES[key] ?? key) : key] = value;
|
|
117
140
|
}
|
|
118
141
|
// #10806 D6 — an editorial page's site fields are its file's own keys, after
|
|
@@ -154,7 +177,7 @@ export async function exportContent(opts) {
|
|
|
154
177
|
const targetDir = resolve(opts.targetDir);
|
|
155
178
|
const env = opts.env ?? process.env;
|
|
156
179
|
const onLine = opts.onLine ?? (() => undefined);
|
|
157
|
-
const fetch = opts.fetch ?? globalThis.fetch;
|
|
180
|
+
const fetch = rateLimited(opts.fetch ?? globalThis.fetch, opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))), onLine);
|
|
158
181
|
const dryRun = opts.dryRun === true;
|
|
159
182
|
const refuse = (message) => {
|
|
160
183
|
throw new ExportContentRefusedError(`export-content: ${message} Nothing was written.`);
|
|
@@ -297,7 +320,7 @@ export async function exportContent(opts) {
|
|
|
297
320
|
headers: { authorization: `Bearer ${access.apiKey}` },
|
|
298
321
|
// A redirect would re-send the key to another URL.
|
|
299
322
|
redirect: "error",
|
|
300
|
-
signal: AbortSignal.timeout(
|
|
323
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
301
324
|
});
|
|
302
325
|
status = response.status;
|
|
303
326
|
body = (await response.json().catch(() => undefined));
|
|
@@ -319,6 +342,25 @@ export async function exportContent(opts) {
|
|
|
319
342
|
return any ? items : undefined;
|
|
320
343
|
}
|
|
321
344
|
}
|
|
345
|
+
/**
|
|
346
|
+
* `fetch`, with a 429 waited out by its `retry-after` and sent again, up to
|
|
347
|
+
* `RATE_LIMIT_RETRIES` times (#11750 D4), as `migrate-content` does. A retry
|
|
348
|
+
* carries a fresh timeout: the first attempt's may have fired during the wait.
|
|
349
|
+
*/
|
|
350
|
+
function rateLimited(fetch, sleep, onLine) {
|
|
351
|
+
return async (input, init) => {
|
|
352
|
+
for (let retry = 0;; retry++) {
|
|
353
|
+
const response = await fetch(input, retry === 0 ? init : { ...init, signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) });
|
|
354
|
+
if (response.status !== 429 || retry === RATE_LIMIT_RETRIES)
|
|
355
|
+
return response;
|
|
356
|
+
const header = response.headers.get("retry-after");
|
|
357
|
+
const asked = header !== null && /^\d+$/.test(header) ? Number(header) : 0;
|
|
358
|
+
const seconds = asked >= 1 && asked <= RATE_LIMIT_WAIT_MAX_S ? asked : RATE_LIMIT_WAIT_MAX_S;
|
|
359
|
+
onLine(`rate limited — waiting ${seconds}s`);
|
|
360
|
+
await sleep(seconds * 1000);
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
}
|
|
322
364
|
export const EXPORT_CONTENT_HELP = `create-ailk export-content — write every published page back to its content file.
|
|
323
365
|
|
|
324
366
|
Usage:
|
|
@@ -342,8 +384,10 @@ apps/web/content/en/blog/<series>/<slug>.mdx for a post in a series and the
|
|
|
342
384
|
same under docs for a docs page; a post or doc goes to whichever of
|
|
343
385
|
<slug>.mdx or <slug>/index.mdx is on disk, <slug>.mdx when neither is — with
|
|
344
386
|
its words moved back into its sections, so a re-run of migrate-content
|
|
345
|
-
reports every page unchanged. Published edits are
|
|
346
|
-
|
|
387
|
+
reports every page unchanged. Published edits are kept. The hub's own tags
|
|
388
|
+
are not written: a blog post keeps its public tags, every other page none. A
|
|
389
|
+
rate-limited read waits out its retry-after, up to three times, and
|
|
390
|
+
continues. A page with a draft ahead of its published version fails by name:
|
|
347
391
|
publish or revert it in Admin, then re-run. The site's own API read must
|
|
348
392
|
serve the workspace's published version (on a spoke, the hub's row at
|
|
349
393
|
--store database). Each page prints created, written, unchanged or failed.
|
package/dist/lib/import-mdx.d.ts
CHANGED
|
@@ -107,6 +107,8 @@ export type ImportMdxOutcome = {
|
|
|
107
107
|
slug: string;
|
|
108
108
|
/** With `liveSource` and `publishCheck`: what the hub's publish gate will answer (#10898 D6). */
|
|
109
109
|
publishVerdict?: PublishVerdict;
|
|
110
|
+
/** `updated` with the words already matching the hub: only the layout changed (#11749 D5). */
|
|
111
|
+
layoutOnly?: true;
|
|
110
112
|
} | {
|
|
111
113
|
root: ImportMdxRoot;
|
|
112
114
|
path: string;
|
package/dist/lib/import-mdx.js
CHANGED
|
@@ -16,8 +16,11 @@
|
|
|
16
16
|
* sections — layout and data — go to the structure layer through
|
|
17
17
|
* `PUT …/structure` under the draft's structure token (#10643), never into the
|
|
18
18
|
* stored content. An unchanged layout writes nothing, so a re-run still
|
|
19
|
-
* reports `unchanged
|
|
20
|
-
*
|
|
19
|
+
* reports `unchanged`. A changed layout on a page whose words did not change
|
|
20
|
+
* and whose draft is its live version is refused `draft_is_live`; the
|
|
21
|
+
* importer then saves a draft with the same words under the version it read
|
|
22
|
+
* and sends the layout once more (#11749 D2), so the live page does not change
|
|
23
|
+
* until it is published. A second refusal fails the page with that reason.
|
|
21
24
|
*
|
|
22
25
|
* A section string that holds inline HTML is converted first (#10804) — a
|
|
23
26
|
* link to `[label](href)`, a line break to a newline, a block to a blank
|
|
@@ -619,31 +622,49 @@ async function writePage(t, page, locale, content, layout, publicTags) {
|
|
|
619
622
|
let live = false;
|
|
620
623
|
let stored;
|
|
621
624
|
let sent = false;
|
|
622
|
-
const outcome = (result) => ({
|
|
623
|
-
outcome: { root, path, result, type, slug },
|
|
625
|
+
const outcome = (result, layoutOnly = false) => ({
|
|
626
|
+
outcome: { root, path, result, type, slug, ...(layoutOnly && { layoutOnly: true }) },
|
|
624
627
|
live,
|
|
625
628
|
stored,
|
|
626
629
|
sent,
|
|
627
630
|
});
|
|
628
631
|
// The words are written; now the layout, under the token the draft holds
|
|
629
|
-
// (`null` for a page that has none yet).
|
|
630
|
-
|
|
632
|
+
// (`null` for a page that has none yet). `version` is the read's, given
|
|
633
|
+
// only when the words compared equal and were not saved (#11749 D2).
|
|
634
|
+
const done = async (result, structureToken = null, version) => {
|
|
631
635
|
if (layout === undefined)
|
|
632
636
|
return outcome(result);
|
|
633
|
-
const
|
|
637
|
+
const writeLayout = () => call(t, "PUT", `${pagePath}/structure${query}`, {
|
|
634
638
|
structureToken,
|
|
635
639
|
structure: layout,
|
|
636
640
|
});
|
|
641
|
+
let put = await writeLayout();
|
|
642
|
+
// #11749 D2 — the hub refuses a layout on a live tip and names the remedy:
|
|
643
|
+
// save a draft (the same words, under the version read), then write the
|
|
644
|
+
// layout once more. A save carries the structure token forward (§1).
|
|
645
|
+
const redraft = version !== undefined &&
|
|
646
|
+
!("network" in put) &&
|
|
647
|
+
put.status === 409 &&
|
|
648
|
+
put.code === "draft_is_live";
|
|
649
|
+
if (redraft) {
|
|
650
|
+
const saved = await call(t, "PATCH", address, content, version);
|
|
651
|
+
if ("network" in saved || saved.status !== 200)
|
|
652
|
+
return refusedAnswer(page, saved);
|
|
653
|
+
stored = saved.data["content"];
|
|
654
|
+
sent = true;
|
|
655
|
+
const mismatch = wrongLocale(page, saved, locale);
|
|
656
|
+
if (mismatch !== undefined)
|
|
657
|
+
return mismatch;
|
|
658
|
+
put = await writeLayout();
|
|
659
|
+
}
|
|
637
660
|
if ("network" in put || put.status !== 200)
|
|
638
661
|
return refusedAnswer(page, put);
|
|
662
|
+
// #10804 D6 — with no token the hub writes the layout (or refuses a
|
|
663
|
+
// live tip), so a dry run's `written: false` never makes it unchanged.
|
|
664
|
+
const layoutOnly = result === "unchanged" &&
|
|
665
|
+
(redraft || structureToken === null || put.data["written"] === true);
|
|
639
666
|
return (wrongLocale(page, put, locale) ??
|
|
640
|
-
outcome(
|
|
641
|
-
// #10804 D6 — with no token the hub writes the layout (or refuses a
|
|
642
|
-
// live tip), so a dry run's `written: false` never makes it unchanged.
|
|
643
|
-
result === "unchanged" &&
|
|
644
|
-
(structureToken === null || put.data["written"] === true)
|
|
645
|
-
? "updated"
|
|
646
|
-
: result));
|
|
667
|
+
outcome(layoutOnly ? "updated" : result, layoutOnly));
|
|
647
668
|
};
|
|
648
669
|
for (let reread = false;; reread = true) {
|
|
649
670
|
const read = await call(t, "GET", address);
|
|
@@ -664,7 +685,7 @@ async function writePage(t, page, locale, content, layout, publicTags) {
|
|
|
664
685
|
const liveTip = read.data["status"] === "published";
|
|
665
686
|
if (canonical(compared(liveTip ? withoutHubRecords(stored) : stored, content, publicTags)) ===
|
|
666
687
|
canonical(compared(liveTip ? withoutHubRecords(content) : content, content, publicTags))) {
|
|
667
|
-
return done("unchanged", structureToken);
|
|
688
|
+
return done("unchanged", structureToken, version);
|
|
668
689
|
}
|
|
669
690
|
// The token is the version just compared against, so a draft saved
|
|
670
691
|
// since the read is a 409, never a silent overwrite.
|
|
@@ -31,8 +31,17 @@ export interface MigrateContentOptions {
|
|
|
31
31
|
* A fetch that sends `GET`s through `inner` and never sends a write: a `POST`
|
|
32
32
|
* is answered `201` and a `PATCH` `200` locally, with the one member of a
|
|
33
33
|
* write's answer `importMdx` reads (`data.locale`), and the structure write's
|
|
34
|
-
* `PUT` (#10534) `200
|
|
35
|
-
*
|
|
34
|
+
* `PUT` (#10534) `200`. Any other method throws.
|
|
35
|
+
*
|
|
36
|
+
* The `PUT` answers `data.written` from the layout the hub's draft read
|
|
37
|
+
* returned (#11749 D4): each 200 `GET`'s `data.structure` is kept per page
|
|
38
|
+
* address, and a `PUT` to that address's `/structure` URL answers
|
|
39
|
+
* `written: true` when its body's `structure` is not `isDeepStrictEqual` to
|
|
40
|
+
* it — the hub's own comparison. Any other `PUT` (an equal layout, an address
|
|
41
|
+
* never read, a read with no `structure` member, no string body, a `Request`
|
|
42
|
+
* input) answers `written: false`. It never answers 409: a live tip with a
|
|
43
|
+
* changed layout is planned `update`, what `--apply` reports after its
|
|
44
|
+
* re-draft. The memory lasts one run, as the transport does.
|
|
36
45
|
*/
|
|
37
46
|
export declare function readOnlyFetch(inner: typeof globalThis.fetch, locale: string): typeof globalThis.fetch;
|
|
38
47
|
/** What a dry run prints when the site's contract cannot give a verdict. */
|
|
@@ -51,5 +60,5 @@ export interface MigrateContentArgs {
|
|
|
51
60
|
languageSeed: string | undefined;
|
|
52
61
|
help: boolean;
|
|
53
62
|
}
|
|
54
|
-
export declare const MIGRATE_CONTENT_HELP = "create-ailk migrate-content \u2014 import an existing site's pages into its workspace.\n\nUsage:\n AILK_AGENT_KEY=<key> create-ailk migrate-content [<dir>] [--apply] [--api-url <origin>] [--workspace <wksp_id>] [--language-seed <file>]\n\nArguments:\n <dir> The site. Defaults to the current dir.\n\nOptions:\n --apply Write the pages. Without it the command reads the\n workspace, prints what it would do, and writes\n nothing.\n --api-url <origin> The API origin that holds the workspace \u2014 on a\n spoke, its hub's. Else AILK_API_URL. https: only\n (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 --language-seed <file> A Language seed file (language/<entity>.json).\n Each of its topics becomes one Topic holding all\n its keywords. Its items are not read.\n -h, --help Show this help.\n\nEach content/en/<Type>/<slug>.mdx page (and each legacy\ncontent/<Type>/<slug>.mdx) is written to the workspace as a draft through\nthe API's content routes, with the agent key, which is read from\nAILK_AGENT_KEY only and needs the content-edit grant. Nothing is published,\nso the live site does not change. The site needs no .ailk-site-manifest.json\nand may be a spoke; its dependencies must be installed. A page whose\nfrontmatter carries sections is converted: its words are written to the\npage's Markdown and its sections to its layout.\n\nEach FAQ item and glossary-index term becomes one Language item of its kind,\nset Live when the run creates it, and its section pins the items in the\norder the file lists them. A question on several pages is one item, with\nthe FAQ page's words (the glossary page's, for a term). Lines prefixed\nlanguage: report each item, and each page the database read will not show\nas its file does. An API with no Language collection leaves them inline.\n\nWith --language-seed, each topic in the seed file is written after the\npages as one Topic: its name, its pillar page, and every keyword with its\nmonthly searches and as-of date, its primary marked. A Topic the workspace\nalready holds keeps its spelling, notes and newer numbers, and gains what it\nlacks. Lines prefixed language: topic/ report each one; a second --apply\nreports every topic unchanged. A seed file that is not readable, or whose\ntopics the hub would refuse, is refused before anything is sent.\n\nWhen the site has apps/web/content, each blog post and docs page in it is\nwritten too: apps/web/content/en/blog/<slug>.mdx (or <slug>/index.mdx) as a\nBlogPosting, or one series down, blog/<series>/<post>.mdx, as a BlogPosting\nwhose parent is the series; the same under docs as a DocsDetail, and each\ndirectory's own index.mdx as its BlogList or DocsList index. A file the walk\nskips is listed with the rule it failed. Their lines are prefixed\neditorial: \u2014 each outcome's root is content or editorial.\n\nA dry run prints create, update, unchanged, skipped or failed per page. It\ncannot see a write the API would refuse at --apply (a conflict or a server\nerror),
|
|
63
|
+
export declare const MIGRATE_CONTENT_HELP = "create-ailk migrate-content \u2014 import an existing site's pages into its workspace.\n\nUsage:\n AILK_AGENT_KEY=<key> create-ailk migrate-content [<dir>] [--apply] [--api-url <origin>] [--workspace <wksp_id>] [--language-seed <file>]\n\nArguments:\n <dir> The site. Defaults to the current dir.\n\nOptions:\n --apply Write the pages. Without it the command reads the\n workspace, prints what it would do, and writes\n nothing.\n --api-url <origin> The API origin that holds the workspace \u2014 on a\n spoke, its hub's. Else AILK_API_URL. https: only\n (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 --language-seed <file> A Language seed file (language/<entity>.json).\n Each of its topics becomes one Topic holding all\n its keywords. Its items are not read.\n -h, --help Show this help.\n\nEach content/en/<Type>/<slug>.mdx page (and each legacy\ncontent/<Type>/<slug>.mdx) is written to the workspace as a draft through\nthe API's content routes, with the agent key, which is read from\nAILK_AGENT_KEY only and needs the content-edit grant. Nothing is published,\nso the live site does not change. The site needs no .ailk-site-manifest.json\nand may be a spoke; its dependencies must be installed. A page whose\nfrontmatter carries sections is converted: its words are written to the\npage's Markdown and its sections to its layout.\n\nEach FAQ item and glossary-index term becomes one Language item of its kind,\nset Live when the run creates it, and its section pins the items in the\norder the file lists them. A question on several pages is one item, with\nthe FAQ page's words (the glossary page's, for a term). Lines prefixed\nlanguage: report each item, and each page the database read will not show\nas its file does. An API with no Language collection leaves them inline.\n\nWith --language-seed, each topic in the seed file is written after the\npages as one Topic: its name, its pillar page, and every keyword with its\nmonthly searches and as-of date, its primary marked. A Topic the workspace\nalready holds keeps its spelling, notes and newer numbers, and gains what it\nlacks. Lines prefixed language: topic/ report each one; a second --apply\nreports every topic unchanged. A seed file that is not readable, or whose\ntopics the hub would refuse, is refused before anything is sent.\n\nWhen the site has apps/web/content, each blog post and docs page in it is\nwritten too: apps/web/content/en/blog/<slug>.mdx (or <slug>/index.mdx) as a\nBlogPosting, or one series down, blog/<series>/<post>.mdx, as a BlogPosting\nwhose parent is the series; the same under docs as a DocsDetail, and each\ndirectory's own index.mdx as its BlogList or DocsList index. A file the walk\nskips is listed with the rule it failed. Their lines are prefixed\neditorial: \u2014 each outcome's root is content or editorial.\n\nA dry run prints create, update, unchanged, skipped or failed per page. It\ncannot see a write the API would refuse at --apply (a conflict or a server\nerror), and a page whose content fails its page type is planned and saved\nwith errors the editor shows, not failed. An update whose words already\nmatch the workspace prints \"update \u2014 layout only\". A layout change to a page\nwhose draft is its live version is saved as a new draft with the same words,\nso the live site does not change until the page is published. --apply prints created, updated,\nunchanged, skipped or failed per page, so a re-run is safe. Exit 0 when no\npage failed, 1 when any did, 2 on a refusal (nothing is sent).\n\nEvery page is written with a live-source mark: its words already ship on the\nlive site, so the hub lists a heading the page type's template asks for and\nthe page lacks as advisory, and publish takes the page. Editing the page's\nwords in the hub drops the mark. A dry run prints a publish line after each\npage: publishable, the advisory headings the hub will list, or the status and\nfindings that will stop the publish. The verdict is the site's installed\n@working-theory/validation's, not the hub's; it sees no library-file finding\nand no layout the hub repairs differently. A site whose validation predates\nthe live-source report prints one \"publish: not checked\" line instead.\n";
|
|
55
64
|
export declare function parseMigrateContentArgs(argv: string[]): MigrateContentArgs;
|
package/dist/migrate-content.js
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
*/
|
|
35
35
|
import { readFileSync } from "node:fs";
|
|
36
36
|
import { join, resolve } from "node:path";
|
|
37
|
-
import { parseArgs } from "node:util";
|
|
37
|
+
import { isDeepStrictEqual, parseArgs } from "node:util";
|
|
38
38
|
import { languageLines, languageOffLine, seedTopics, seedTopicsOf, topicSeedLines, withLanguage, } from "./language-import.js";
|
|
39
39
|
import { formatImportMdxReport, importMdx, isDirectory, loadSiteMdxAdapter, outcomePath, } from "./lib/import-mdx.js";
|
|
40
40
|
import { ParseError } from "./parse-args.js";
|
|
@@ -63,18 +63,64 @@ function given(value) {
|
|
|
63
63
|
* A fetch that sends `GET`s through `inner` and never sends a write: a `POST`
|
|
64
64
|
* is answered `201` and a `PATCH` `200` locally, with the one member of a
|
|
65
65
|
* write's answer `importMdx` reads (`data.locale`), and the structure write's
|
|
66
|
-
* `PUT` (#10534) `200
|
|
67
|
-
*
|
|
66
|
+
* `PUT` (#10534) `200`. Any other method throws.
|
|
67
|
+
*
|
|
68
|
+
* The `PUT` answers `data.written` from the layout the hub's draft read
|
|
69
|
+
* returned (#11749 D4): each 200 `GET`'s `data.structure` is kept per page
|
|
70
|
+
* address, and a `PUT` to that address's `/structure` URL answers
|
|
71
|
+
* `written: true` when its body's `structure` is not `isDeepStrictEqual` to
|
|
72
|
+
* it — the hub's own comparison. Any other `PUT` (an equal layout, an address
|
|
73
|
+
* never read, a read with no `structure` member, no string body, a `Request`
|
|
74
|
+
* input) answers `written: false`. It never answers 409: a live tip with a
|
|
75
|
+
* changed layout is planned `update`, what `--apply` reports after its
|
|
76
|
+
* re-draft. The memory lasts one run, as the transport does.
|
|
68
77
|
*/
|
|
69
78
|
export function readOnlyFetch(inner, locale) {
|
|
79
|
+
const layouts = new Map();
|
|
80
|
+
/** Whether the hub would write a dry run's layout `PUT` (#11749 D4). */
|
|
81
|
+
function layoutWritten(input, init) {
|
|
82
|
+
if (input instanceof Request || typeof init?.body !== "string")
|
|
83
|
+
return false;
|
|
84
|
+
const url = String(input);
|
|
85
|
+
const address = url.replace(/\/structure(?=\?|$)/, "");
|
|
86
|
+
if (address === url || !layouts.has(address))
|
|
87
|
+
return false;
|
|
88
|
+
let sent;
|
|
89
|
+
try {
|
|
90
|
+
sent = JSON.parse(init.body)?.structure;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
return !isDeepStrictEqual(sent, layouts.get(address));
|
|
96
|
+
}
|
|
70
97
|
return (async (input, init) => {
|
|
71
98
|
const method = (init?.method ?? (input instanceof Request ? input.method : "GET")).toUpperCase();
|
|
72
|
-
if (method === "GET")
|
|
73
|
-
|
|
99
|
+
if (method === "GET") {
|
|
100
|
+
const response = await inner(input, init);
|
|
101
|
+
if (response.status === 200) {
|
|
102
|
+
const url = input instanceof Request ? input.url : String(input);
|
|
103
|
+
try {
|
|
104
|
+
// Parsed here, never by `Response.json()`, so both sides of the
|
|
105
|
+
// comparison are this module's plain objects.
|
|
106
|
+
const data = JSON.parse(await response.clone().text())?.data;
|
|
107
|
+
if (data !== null && typeof data === "object" && "structure" in data) {
|
|
108
|
+
layouts.set(url, data.structure);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
layouts.delete(url);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
// Not JSON: nothing is recorded; the response goes back as it came.
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return response;
|
|
119
|
+
}
|
|
74
120
|
if (method !== "POST" && method !== "PATCH" && method !== "PUT") {
|
|
75
121
|
throw new Error(`a dry run sends no ${method} request`);
|
|
76
122
|
}
|
|
77
|
-
const data = method === "PUT" ? { locale, written:
|
|
123
|
+
const data = method === "PUT" ? { locale, written: layoutWritten(input, init) } : { locale };
|
|
78
124
|
return new Response(JSON.stringify({ ok: true, data }), {
|
|
79
125
|
status: method === "POST" ? 201 : 200,
|
|
80
126
|
headers: { "content-type": "application/json" },
|
|
@@ -92,8 +138,11 @@ const PLAN_VERB = {
|
|
|
92
138
|
};
|
|
93
139
|
function planLine(outcome) {
|
|
94
140
|
const verb = PLAN_VERB[outcome.result];
|
|
95
|
-
|
|
96
|
-
|
|
141
|
+
if ("reason" in outcome)
|
|
142
|
+
return `${outcomePath(outcome)}: ${verb} — ${outcome.reason}`;
|
|
143
|
+
// #11749 D5 — an update whose words already match says so.
|
|
144
|
+
return outcome.layoutOnly === true
|
|
145
|
+
? `${outcomePath(outcome)}: ${verb} — layout only`
|
|
97
146
|
: `${outcomePath(outcome)}: ${verb}`;
|
|
98
147
|
}
|
|
99
148
|
// ── The publish verdict (#10898 D6) ─────────────────────────────────────────
|
|
@@ -321,9 +370,11 @@ editorial: — each outcome's root is content or editorial.
|
|
|
321
370
|
|
|
322
371
|
A dry run prints create, update, unchanged, skipped or failed per page. It
|
|
323
372
|
cannot see a write the API would refuse at --apply (a conflict or a server
|
|
324
|
-
error),
|
|
325
|
-
|
|
326
|
-
|
|
373
|
+
error), and a page whose content fails its page type is planned and saved
|
|
374
|
+
with errors the editor shows, not failed. An update whose words already
|
|
375
|
+
match the workspace prints "update — layout only". A layout change to a page
|
|
376
|
+
whose draft is its live version is saved as a new draft with the same words,
|
|
377
|
+
so the live site does not change until the page is published. --apply prints created, updated,
|
|
327
378
|
unchanged, skipped or failed per page, so a re-run is safe. Exit 0 when no
|
|
328
379
|
page failed, 1 when any did, 2 on a refusal (nothing is sent).
|
|
329
380
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-ailk",
|
|
3
|
-
"version": "0.42.
|
|
3
|
+
"version": "0.42.1",
|
|
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.70.0",
|
|
32
|
+
"@working-theory/templates": "0.70.0"
|
|
33
33
|
},
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|
|
@@ -91,6 +91,7 @@ Routes are versioned under `/v1/*`:
|
|
|
91
91
|
- `/v1/consent/cookie` (POST), `/v1/consent/unsubscribe` (POST), `/v1/consent/sign-up` (GET), `/v1/consent/account` (GET, POST), `/v1/consent/platform` (GET, POST), `/v1/member/consents` (GET, POST), `/v1/workspaces/:workspaceId/people/:personId/consents` (GET) — the consent ledger's routes (#8438, spec `docs/specs/8438-consent-registry-and-ledger-step-spec.md`; #8765, spec `docs/specs/8765-sign-up-refuses-without-the-spec.md`). `consent_grants` is THE ledger: append-only (the database refuses any change to a stored row, and any truncation, on it and on `consent_visitor_links`), every row naming its `source`, its `policyVersion` and, when known, its Person; it has two writers — `src/services/consent.ts` (`recordConsent`, `recordPersonConsent`, `recordCookieChoice`, `linkConsentVisitor`, `recordCheckoutConsent`; every source) and the web's sign-up hook `apps/web/lib/sign-up-agreements.ts` (#8765 D4), which writes only `sign_up` rows (subject `user`) of a user it creates in the same Better Auth transaction, from the evidence `GET /v1/consent/sign-up` built with `consent.ts`'s own functions — and every reader is `src/lib/consent-store.ts` (`DISTINCT ON` current-state reads, never a window). **Two readings of a Person's rows:** the OWN reading (`sign_up`, `account_settings`, `email_unsubscribe` — a verified caller or a signed link) is what the member's screens and any send read; the ANY-SOURCE reading (adds `magnet`, `api`, `cookie_banner`, `checkout`, and linked visitors' cookie rows) is the operator's, marked `unverified` — an anonymous form's row never changes a member's own answer. **The checkout grant (#8765 D13, D14):** `checkout` is the eighth source (the `consent_grants_source_known` CHECK names all eight). The hub webhook's `checkout.session.completed` arm, after the flow-checkout Person step, writes one `account_terms` row (subject `person`, source `checkout`, `sourceRef` the Checkout Session id, locale `en`, the current statement and version) through `recordCheckoutConsent` — one transaction under the `ailk:consent:<workspaceId>:checkout:<sessionId>` lock, nothing written when that Person already holds that session's row — only when `consent.terms_of_service` is `accepted` and `metadata.ailk_terms` is `account_terms@<current version>`; the Person is `services/checkout-buyer.ts`'s `checkoutBuyerPerson` (a proposal session → the piece's Person in its `ailk_workspace` through `lib/proposal-paid-store.ts`'s `proposalPersonId`; a flow checkout → the Person the Person step's `resolveCheckoutPerson` found or created, never created here; a signed-in buyer's `ailk_user_id` → the Person of that user's verified email in the site workspace, test mode included; else, for a paid live-mode session only, `customer_details.email`'s Person). **A spoke purchase records the same grant (#8778):** a spoke's checkout runs on the spoke's own Stripe account, so the hub webhook never sees it; instead the first write of a `spokeCheckout` lead with a Person (`services/lead-routing.ts`) whose `payload.termsAccepted` equals the current `account_terms@<version>` stamp (`currentAccountTermsStamp`) calls `recordCheckoutConsent` for the lead's Person, `sourceRef` the lead's `Idempotency-Key` (the Checkout Session id) — a `null` or absent value writes nothing (`consent_absent`), any other value nothing (`terms_unstamped`), a replay never reaches it (and `termsAccepted` is left out of the replay comparison, so a redelivery across a spoke's update still replays), and the store's per-session guard keeps it to one row; it logs `{ event: "checkout-consent", outcome, siteId }` only and never changes the lead's answer. A `checkout` row is unverified: the payer is not a signed-in user, so it never satisfies the account interstitial. It logs `{ event: "checkout-consent", outcome, eventIdPrefix }` only (`consent_absent`, `terms_unstamped`, `person_unresolved`, `recorded`, `unchanged`, `version_changed` — the site registry has moved past the stamped version, so nothing is written — and `failed`, which adds the error's `errName`) and never changes the 200. A write appends only when the answer changes the reading it is checked against, under an advisory lock on the (subject, purpose) pair. `POST /v1/consent/cookie` takes `{ visitorId, choice, locale }` and never a workspace (it comes from `resolvePublicWorkspace`); `POST /v1/consent/unsubscribe` takes a token signed with `AILK_CONSENT_LINK_SECRET` (≥ 32 bytes, optional; unset ⇒ `503 link_secret_not_configured`) and answers every defect as one `400 invalid_link`. Both are top-level, outside every module gate, in their own rate-limit scopes (`consent`, `unsubscribe`) and on `FORWARDED_VISITOR_ROUTES`. **A sign-up agreement is the account's (#8765 C3, D5, D6):** a `signUp` purpose (`account_terms`) is recorded once per `User`, subject `user` / the user id in the deployment's own site workspace (`resolveSiteWorkspaceId()`, the owner platform consents' footing, read by `userPlatformRows`), never per Person, so the hub and every spoke signed in through it read one row. `GET /v1/consent/sign-up` is anonymous: `{ workspaceId, agreements: [{ purposeId, policyVersion, locale, statement, statementHash }] }` for the site workspace (`locale` default `en`, `null` workspace `503 tenant_unresolved`, `Cache-Control: no-store`), top level beside the cookie route in its own rate-limit scope `signupevidence`, outside every module gate. **Its budget is per site key (#8805):** a request presenting a valid `x-ailk-spoke-key` (`resolveCallerSite` → a registered, unrevoked spoke) is counted against that key's `site,<spokeId>` bucket at `DEFAULT_SIGNUPEVIDENCE_PER_KEY_PER_MINUTE` (120; `AILK_RATE_LIMIT_SIGNUPEVIDENCE_PER_KEY_PER_MINUTE` overrides) and let through the server-wide per-IP ceiling, so a spoofed `X-Forwarded-For` cannot spend it; an invalid or absent key, or a failed lookup, keeps `DEFAULT_PER_IP_PER_MINUTE_STRICT` per IP. The key picks the bucket only — the workspace stays `resolveSiteWorkspaceId()` (`middleware/rate-limit.ts`'s `siteKeyReader`, `SITE_KEYED_ROUTES`). `GET /v1/consent/account` answers `{ agreements: [{ id, statement, policyVersion, acceptedVersion, acceptedAt, current }], complete }` for the caller (`memberCaller` — a cookie session or a hub credential; a personal token `401`); `POST` takes `{ purposeIds, locale? }`, refuses any id that is not a `signUp` agreement `404 purpose_unknown` before writing anything, writes each through `recordPersonConsent` (source `account_settings`, `sourceRef: spoke:<id>` for a hub credential) and answers the GET body; both register in `authScope` unconditionally and log `{ event: "account-agreements", outcome }` only. The member pair reads and writes that same row for a `signUp` purpose (no Person is created) and is unchanged for every other purpose; a `null` site workspace keeps the old per-Person reading; a hub credential's `via: "sign_up"` is `400 sign_up_window_closed` with nothing written (SEC-8765-B). The member pair and the account pair are in `HUB_SESSION_ROUTES` (26 entries since #8765); the anonymous `GET /v1/consent/sign-up` is not, and neither is `/v1/consent/platform` — it is the deployment owner's own consent to Working Theory, a cookie session holding `platform-consents`, under `multi-tenant`. The banner's visitor id travels in `x-ailk-consent-visitor` (only a v4 UUID counts) on the lead and flow routes and the member write, linking the visitor to the Person; the header is never echoed or logged. A `consent` flow field now stores `{ [purposeId]: boolean }` and writes the ledger at completion (source `magnet`, `sourceRef` the flow slug). The operator's `…/consents` answers `{ own, anySource, history, nextCursor }` (history 500 a page, `Cache-Control: private, no-store`, never a subject id). No MCP twin for any of them, recorded in `tests/parity/README.md`.
|
|
92
92
|
- `/v1/workspaces/:workspaceId/requests` (GET, `?limit=`), `/v1/workspaces/:workspaceId/requests/:requestId` (GET), `/v1/workspaces/:workspaceId/people/:personId/pieces/:pieceId/versions` (POST) — the provider routes (#8171, `src/routes/workspaces/{requests,pieces}.ts` over `tenantDb(tenant).memberArea`; spec `docs/specs/8171-provider-routes-the-workspace-requests-spec.md`). **The Requests read** lists the workspace's inbound member rows (#8170's messages, quote requests and reviews), newest first, `limit` 1–50 (default 50, no cursor), behind `inbox-read` (every role) checked with `can(tenant.role, …)`. It is tiered: a role holding `people-read` (owner, admin) gets the full row — the subject, body and the kind's own fields (a message's `link`, a quote's `items`, a review's `pieceId`, `version`, `review`); every other caller, every agent key included, gets `{ id, kind, person, createdAt }` and the content is never selected. A row whose payload fails its kind's schema, or whose Person is gone, is left out and counted in one `warn`. **Deliver a version** numbers version n+1 under the piece lock (`withPieceStagesLock`), behind `member-pieces-manage` through `allows` (an agent granted it delivers); the body is exactly one of an `https` link (`isHttpsLink`, else `400 link_not_https`) and a private attachable asset of this workspace (`400 asset_not_found` / `asset_not_attachable`), plus an optional note; `version`, `deliveredBy` and `deliveredAt` are the server's (a body naming one is `400 validation_failed`); a piece with `approvedAt` set is `409 piece_approved`; a malformed, absent or foreign Person or piece is `404 not_found`. There is no round count, limit or remaining count (#8140 disposition 3). It answers `201 { version: { id, pieceId, version, file, link, note, deliveredAt } }` — the file's download name, never an asset id or `deliveredBy` — and every call that reaches the store writes one `people.version.create` audit row. **The single Requests read (#9847, spec `docs/specs/9847-agent-reads-member-request-spec.md`):** `GET /v1/workspaces/:workspaceId/requests/:requestId` answers one inbound member row of the caller's workspace in the list's full shape (`workspaceRequestSchema`, `{ ok: true, data: <row> }`) through `tenantDb(tenant).memberArea.getRequest`. Gate: `inboxAllowed(tenant, "people-read")` before any read — a person whose role holds `people-read`, an agent holding BOTH the `people-read` and `inbox-act` grants (the reply grant, #9714 D5; `member-pieces-manage` is not an alternative); a refusal is `403`. A malformed, absent, outbound, other workspace's or unservable id (payload failing its kind's schema, Person gone — logged `dropped: 1` at `warn`) is one `404 not_found`. The subject, body and each quote answer pass `inbox-messages.ts`'s `stripHiddenText` (zero-width, bidi, BOM and tag characters, SEC-9847-1); the stored row is untouched. Every agent call writes exactly one `people.request.read` audit row — `refused`/`failed` against the workspace, `succeeded` against the interaction with summary `{ kind }` and thread `hub:<personId>` — carrying its session; a person's call writes none. The list's agent view stays the summary row. The thread's `request` entry carries `requestId`, the row's `intx_` id, so an agent can find it. Same registration, scope and tenant guard as the routes above (`workspace || multi-tenant`). No MCP twin, by decision — member-area MCP tools are a later phase of the CRM nucleus, recorded in `tests/parity/README.md`.
|
|
93
93
|
- `/v1/workspaces/:workspaceId/callbacks` (GET, `?limit=`) — the Inbox callbacks read (#9254, `src/routes/workspaces/callbacks.ts` over `tenantDb(tenant).callbacks`; spec `docs/specs/9254-callback-rows-inbox-spec.md`): the workspace's request-and-confirm `Callback` rows (#5970), newest first, `limit` 1–50 (default 50, the Requests read's own query; any other key `400 validation_failed`), behind `inbox-read` (every role, a member and an agent key included) through `permitted`, checked before any read. Same registration, scope and tenant guard as the Requests read (`workspace || multi-tenant`); the scope is always `request.tenant.workspaceId`. The row is `id`, `name`, `phone`, `preferredTime` (the window asked for, as typed), `personId` (`null` for a callback captured with no email), `confirmedAt`, `confirmedTime`, `paidAt` and `createdAt` — read through the fixed `CALLBACK_ROW_SELECT`, so never `payload`, the confirm digest or expiry, `buyerEmail`, `amountMinor`, `currency` or a Stripe id. The confirm state is the reader's to derive (`paidAt` → paid, else `confirmedAt` → confirmed, else awaiting). No item read, no cursor, no stamp, no audit row; the body is re-parsed against its own `.strict()` schema. The Admin Inbox lists each row under Interested. No MCP twin, recorded in `tests/parity/README.md`.
|
|
94
|
+
- `/v1/workspaces/:workspaceId/work-requests` (GET, POST), `/v1/workspaces/:workspaceId/work-requests/:requestId` (GET), `/v1/workspaces/:workspaceId/work-requests/:requestId/issue` (PATCH) — custom-work requests (#11756, `src/routes/workspaces/work-requests.ts` over `tenantDb(tenant).workRequests`; spec `docs/specs/11756-a-custom-work-request-can-spec.md`): an Inbox item an agent files that points to one `Document` of its workspace, and the GitHub issue a person links to it. Same registration, scope and tenant guard as the callbacks read (one `TENANCY` row in `tenant:settings`); the scope is always `request.tenant.workspaceId`, and the routes never set `mcpPinSwitch`, so an all-workspaces token writes only in its session's pinned workspace — the pin is an accident fence, and the authorization is the live per-workspace `inbox-act` check. **The create** takes a strict `{ documentSlug, summary }` (the content slug grammar; the summary trimmed, 1–280 visible characters, a hidden code point or line break refused) behind `inboxAllowed(tenant, "inbox-act")` — an agent needs the grant; no permission was added — then charges `chargeWriteBudget` scope `workrequest`, the person in this workspace first (`by,<workspaceId>:<userId>`, 5 an hour, shared by all of that person's agents and connected apps — an OAuth agent id is a client registration many people share), then the workspace (`ws,`, 10 an hour) only when the person passed (`429 rate_limited` with `Retry-After`), before the body is parsed. It stores the request only when the slug resolves to a `Document` of the workspace at the default locale that the caller may read (`docs-read` and the Audience/Disabled rule; any miss `404 document_not_found`) and answers `201`. **The reads** (`inbox-read`) serve `{ items, total }` — at most 200, newest first, no query — and one row; a malformed, absent or foreign id is one `404 not_found`. A row is `{ id, summary, document: { slug, title } | null, githubIssue: { owner, repo, number } | null, byAgent, createdAt, updatedAt }`: the document is resolved live, in one query scoped to the workspace and the `Document` type, and is `null` when deleted, archived, retyped or not readable by the caller, or when the caller lacks `docs-read`; the title is stripped of hidden characters and cut at 200. **The link** is a person's act — every agent is `403` — behind `inbox-act`: `{ issueUrl }` is a `https://github.com/<owner>/<repo>/issues/<n>` URL or `null` (`400 issue_url_invalid` for anything else), stored only as `<owner>/<repo>#<n>` (CHECKed in the database); nothing calls GitHub and no GitHub credential is read. An agent's create that passed the gate and the budget writes one `inbox.create_work_request` audit row (`succeeded`, or `failed` with `validation_failed` / `document_not_found`); a link change writes one `inbox.set_work_request_issue` row; a 401, 403 or 429 writes none. No row or log line carries the summary, slug, title, URL or ref. MCP parity: the create's twin is `create_work_request` on `/mcp/workspace`; the list, the item and the link have no tool, by decision (recorded in `tests/parity/README.md`).
|
|
94
95
|
- `/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`.
|
|
95
96
|
- `/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).
|
|
96
97
|
- `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`.
|
|
@@ -209,7 +209,7 @@ here. Spec: `docs/specs/3591-tenant-scoped-agent-auth-secure-spec.md` D13–D16.
|
|
|
209
209
|
tools, `list_proposals` and `create_proposal`, twinning `GET`/`POST
|
|
210
210
|
/v1/workspaces/:workspaceId/people/:personId/proposals` with the same grant: a proposal is
|
|
211
211
|
private to one client, `payments` says whether approval leads to a Stripe page, and an agent's
|
|
212
|
-
price is refused `proposal_needs_person` (a person prices) — and (#10957) `send_person_message`, twinning `POST …/people/:personId/messages`: one message on a client's member feed, saved then emailed (an agent's only to a proved address), needing `inbox-act` with `people-read` or `member-pieces-manage`, and `assets-write` for a file; the operator's message list has no tool, by decision — and (#9681) the four person-thread tools, `get_person_thread`, `set_person_thread_state`, `list_external_threads` and `add_external_thread`, twinning `GET`/`PATCH …/people/:personId/thread` and `GET`/`POST …/people/:personId/external-threads`: a client's whole thread page by page with its read/archived/resolved state, and pointers to email and Slack threads (never message text); reading needs the `people-read` grant, writing also `inbox-act`, and the client erasure route has no tool, by decision — and (#9682) the three person-memory tools, `list_person_memories`, `get_person_memory` and `propose_person_memory`, twinning `GET …/people/:personId/memories`, `GET …/memories/:path` and `POST …/memories`: an agent reads only live, unexpired memories (confirmed by a person, read within 180 days) and its proposal is never live — a new path is a draft, a confirmed one gets a pending version — needing the `people-read` or `people-memory-propose` grant to read and `people-memory-propose` to propose; the six person-only memory routes (edit, delete, confirm, redact, the versions list, restore) have no tool, by decision — and (#9749) `get_slack_connection_status`, twin of `GET /v1/workspaces/:workspaceId/slack-connection` (registered with `workspace`/`multi-tenant`, its route's `TENANCY` row: whether the Organization's Slack is connected, its team name and the date, never a credential; connect and disconnect are a person's act and have no tool, by decision), and `get_prospect_channel_settings` / `set_prospect_channel_settings`, twins of `GET`/`PUT …/prospect-channel` (registered with `scheduling`, their routes' module): the update replaces every field, needs the `meeting-types-manage` grant, is refused `slack_not_connected` while the Organization has no Slack connection, and an agent may change only `enabled`, `channelPrefix` and `archiveDays` — a change to `memberIds` or `welcomeTemplate` is refused `prospect_channel_needs_person` — and (#10950) the three meeting tools, `list_meeting_types`, `save_meeting_types` and `list_appointments`, twinning `GET`/`PUT …/meetings` and `GET /v1/schedule/appointments` (registered with `scheduling`): the meeting types from the connected calendar, each with whether it is Live (`enabled`) and who can book it (`visibility`: `public`, `private` or `authenticated`), the provider's `providerEventTypeId` and `createdAt` when it serves them, and, with the `meeting-types-manage` grant, `providerEditUrl` — the read takes no `include` (#11122 D4); the save needs that grant and its required `enabledSlugs` replaces the Live list, while `customerSlugs` (Authenticated) and `privateSlugs` (Private) are exclusive — a slug in both is refused — and an omitted one keeps the stored list less the sent list's slugs, and no price is set there; the appointments read is every role's, and an agent's only with the `people-read` grant (#10986), takes `eventTypeId` for one type's bookings (#11122 D12), and its attendee names and emails are public-written text; the three scheduling-connection routes have no tool, by decision — and (#10218) the content-suggestion pair, `draft_page_suggestions` and `decide_page_suggestion` — and (#10336) the draft pair, `save_draft` and `read_report`, twinning `PATCH`/`GET …/content/:type/:slug` with the `content-edit` grant: `save_draft` takes the page's `content` whole as the PATCH body and its `version` as `X-Draft-Version`, writes a draft version that never goes live, and answers 409 `conflict` with `currentVersion` when the draft moved; `read_report` returns the draft tip, the version a save must send, the page's stored layout (`structure`, #10962) and the token `save_structure` must send, its open suggestions and the route's check report (`ready`, `needs repair` or `needs your words`), computed by the route and never by the tool — and (#10956) `create_page`, twinning `POST …/content` with the `content-edit` grant: it creates a page and its first draft from `content` sent whole (its `type` and `slug` are the address), never publishes, and answers 409 `conflict` when the page exists and 409 `slug_taken` when another page holds the link — and (#10661) `publish_draft`, twinning `POST …/content/:type/:slug/publish` with the `content-publish` grant: it publishes the draft tip (or a named version) exactly as a person holding that permission does, an agent without the grant is refused 403 `agent_refused` before anything is read, and it never widens Audience or re-enables a doc — and (#10345) the knowledge-base pair, `read_knowledge` and `read_knowledge_doc`, twinning `GET …/knowledge-base` and `GET …/knowledge-base/:type/:slug` with no grant (`docs-read` is every role's): the docs a named member may read (`userId`, by default the agent's own person), at the lower of the agent's person's role and that member's, so naming someone only narrows; Live does not gate them and a disabled doc never appears; `filter: "workspace-memory"` answers the always-loaded set with its `totalTokens` and an 8000-token `warning` — and (#10951) `get_workspace_settings`, twin of `GET /v1/workspaces/:workspaceId/general` (`mcp-workspace`'s `workspace_settings.ts`, no grant): the workspace's name, its own logo (`null` when the organization's applies) and the deployment's deliverable sender (`null` when none is configured, so a magnet's results and completion emails do not go out); the PUT, which renames the workspace and sets its logo, has no tool, by decision — it needs `workspace-settings`, which is never agent-grantable — and the six site-profile tools, `get_site_identity`, `set_site_identity`, `get_site_seo`, `set_site_seo`, `get_welcome_email` and `set_welcome_email` (`mcp-workspace`'s `site_profile.ts`), twinning `GET`/`PUT …/identity`, `…/seo` and `…/welcome-email`: any member reads; each write needs the `site-profile` grant (`ailk:site-profile`), under which every logo and every SEO field but the description — robots and indexing above all — must be sent as read, else `site_profile_field_locked`; the theme pair has no tool, by decision — and (#10733, issue 10905, #10952) the seven Language tools, `list_language_items`, `get_language_item`, `save_language_item`, `set_language_item_live`, `delete_language_item`, `list_language_item_pages` and `get_topic_brief`, twinning `GET …/language`, `GET`/`PUT`/`DELETE …/language/:kind/:slug`, `POST …/language/:kind/:slug/live`, `GET …/language/:kind/:slug/appears-on` and `GET …/language/topic/:slug/brief` (`mcp-workspace`'s `language.ts`): a workspace's glossary terms, FAQs and topics; reading needs no grant, saving the `content-edit` grant (`version: null` creates, a tip id updates, 409 `slug_taken` / `stale` otherwise), the Live switch `content-publish` with the `version` the person reviewed, and the delete `content-publish` too — it removes the item from every Live page, no route restores it, and its slug stays taken; tags are the hub's and never written by a tool; a topic is a keyword cluster for agents and is never shown to visitors, and `get_topic_brief` reads it as a writing brief — its kept rows scored best bets first, from the Live version when Live; the Topic's Keyword Planner import and the value-thresholds pair are a person's and have no tool, by decision — and (#10948) the three magnet tools, `list_magnets`, `get_magnet` and `save_magnet`, twinning `GET …/magnets`, `GET …/magnets/:id` and `PATCH …/magnets/:id` (`mcp-workspace`'s `magnets.ts`, registered with `multi-tenant` or `signal-collectors`): with the `magnets-manage` grant every magnet in full, without it only live ones as `{ id, slug, kind, title, landingPage, tags }`; `save_magnet` takes the PATCH body whole, so going live is `status: "live"` and the route alone refuses it (`402 plan_required`, `409 conversion_needs_email`), and an agent cannot change what a magnet charges (`403 magnet_pricing_needs_person`); create and the four captured-people lists have no tool, by decision — and (#10949) `get_workspace_offerings`, twin of `GET /v1/workspaces/:workspaceId/offerings` (registered with `multi-tenant` alone, its route's module; `mcp-workspace`'s `offerings.ts`): the Offerings tab's view — unavailable with `no_commerce` or `no_connection`, or the Organization's enabled products with this workspace's shown Prices and Recommended — read with no grant; its PUT, which switches a Price on or off, needs `workspace-settings`, which is never agent-grantable, and has no tool, by decision — and the two library reads, `list_workspace_pages` and `list_assets` (`mcp-workspace`'s `library.ts`, registered with `workspace` or `multi-tenant`), twinning `GET …/library/pages` and `GET …/library/assets`: every page with drafts included and its status (`live`, `draft`, or `disabled` — a person editor's alone), needing the `content-edit` grant, and the asset library read-only with each file's public path, for every role; both filter, page and name the workspace `{ id, name }` they read, and uploading has no tool — and (#11680) the two site-vocabulary reads, `list_page_types` and `get_tag_vocabulary` (`mcp-workspace`'s `site_vocabulary.ts`, registered with `workspace` or `multi-tenant`, `gate: "tenant"` — any tenant of the workspace, no grant), twinning `GET …/page-types` and `GET …/tag-vocabulary`: the page types this hub's site can serve (the registry filtered by the modules the hub runs), each with its address, whether a site has only one, its template and that template's headings, and the context classes, Knowledge topic tags and status tags, each with what it means and who may set it; both are platform data and read no row. No workspace tool widens Audience or re-enables a doc, and only `publish_draft` and `set_language_item_live`, with the `content-publish` grant, set Live (and `delete_language_item`, with the same grant, clears it) — the access route answers every agent 403 `agent_refused`, and the publish, Live and Language delete routes an agent without the grant, which reaches a tool as the code and status. Each takes its route's params, query and body and returns the route's
|
|
212
|
+
price is refused `proposal_needs_person` (a person prices) — and (#10957) `send_person_message`, twinning `POST …/people/:personId/messages`: one message on a client's member feed, saved then emailed (an agent's only to a proved address), needing `inbox-act` with `people-read` or `member-pieces-manage`, and `assets-write` for a file; the operator's message list has no tool, by decision — and (#9681) the four person-thread tools, `get_person_thread`, `set_person_thread_state`, `list_external_threads` and `add_external_thread`, twinning `GET`/`PATCH …/people/:personId/thread` and `GET`/`POST …/people/:personId/external-threads`: a client's whole thread page by page with its read/archived/resolved state, and pointers to email and Slack threads (never message text); reading needs the `people-read` grant, writing also `inbox-act`, and the client erasure route has no tool, by decision — and (#9682) the three person-memory tools, `list_person_memories`, `get_person_memory` and `propose_person_memory`, twinning `GET …/people/:personId/memories`, `GET …/memories/:path` and `POST …/memories`: an agent reads only live, unexpired memories (confirmed by a person, read within 180 days) and its proposal is never live — a new path is a draft, a confirmed one gets a pending version — needing the `people-read` or `people-memory-propose` grant to read and `people-memory-propose` to propose; the six person-only memory routes (edit, delete, confirm, redact, the versions list, restore) have no tool, by decision — and (#9749) `get_slack_connection_status`, twin of `GET /v1/workspaces/:workspaceId/slack-connection` (registered with `workspace`/`multi-tenant`, its route's `TENANCY` row: whether the Organization's Slack is connected, its team name and the date, never a credential; connect and disconnect are a person's act and have no tool, by decision), and `get_prospect_channel_settings` / `set_prospect_channel_settings`, twins of `GET`/`PUT …/prospect-channel` (registered with `scheduling`, their routes' module): the update replaces every field, needs the `meeting-types-manage` grant, is refused `slack_not_connected` while the Organization has no Slack connection, and an agent may change only `enabled`, `channelPrefix` and `archiveDays` — a change to `memberIds` or `welcomeTemplate` is refused `prospect_channel_needs_person` — and (#10950) the three meeting tools, `list_meeting_types`, `save_meeting_types` and `list_appointments`, twinning `GET`/`PUT …/meetings` and `GET /v1/schedule/appointments` (registered with `scheduling`): the meeting types from the connected calendar, each with whether it is Live (`enabled`) and who can book it (`visibility`: `public`, `private` or `authenticated`), the provider's `providerEventTypeId` and `createdAt` when it serves them, and, with the `meeting-types-manage` grant, `providerEditUrl` — the read takes no `include` (#11122 D4); the save needs that grant and its required `enabledSlugs` replaces the Live list, while `customerSlugs` (Authenticated) and `privateSlugs` (Private) are exclusive — a slug in both is refused — and an omitted one keeps the stored list less the sent list's slugs, and no price is set there; the appointments read is every role's, and an agent's only with the `people-read` grant (#10986), takes `eventTypeId` for one type's bookings (#11122 D12) and `workspaceId` when the connection reaches several workspaces (#11753), and its attendee names and emails are public-written text; the three scheduling-connection routes have no tool, by decision — and (#10218) the content-suggestion pair, `draft_page_suggestions` and `decide_page_suggestion` — and (#10336) the draft pair, `save_draft` and `read_report`, twinning `PATCH`/`GET …/content/:type/:slug` with the `content-edit` grant: `save_draft` takes the page's `content` whole as the PATCH body and its `version` as `X-Draft-Version`, writes a draft version that never goes live, and answers 409 `conflict` with `currentVersion` when the draft moved; `read_report` returns the draft tip, the version a save must send, the page's stored layout (`structure`, #10962) and the token `save_structure` must send, its open suggestions and the route's check report (`ready`, `needs repair` or `needs your words`), computed by the route and never by the tool — and (#10956) `create_page`, twinning `POST …/content` with the `content-edit` grant: it creates a page and its first draft from `content` sent whole (its `type` and `slug` are the address), never publishes, and answers 409 `conflict` when the page exists and 409 `slug_taken` when another page holds the link — and (#10661) `publish_draft`, twinning `POST …/content/:type/:slug/publish` with the `content-publish` grant: it publishes the draft tip (or a named version) exactly as a person holding that permission does, an agent without the grant is refused 403 `agent_refused` before anything is read, and it never widens Audience or re-enables a doc — and (#10345) the knowledge-base pair, `read_knowledge` and `read_knowledge_doc`, twinning `GET …/knowledge-base` and `GET …/knowledge-base/:type/:slug` with no grant (`docs-read` is every role's): the docs a named member may read (`userId`, by default the agent's own person), at the lower of the agent's person's role and that member's, so naming someone only narrows; Live does not gate them and a disabled doc never appears; `filter: "workspace-memory"` answers the always-loaded set with its `totalTokens` and an 8000-token `warning` — and (#10951) `get_workspace_settings`, twin of `GET /v1/workspaces/:workspaceId/general` (`mcp-workspace`'s `workspace_settings.ts`, no grant): the workspace's name, its own logo (`null` when the organization's applies) and the deployment's deliverable sender (`null` when none is configured, so a magnet's results and completion emails do not go out); the PUT, which renames the workspace and sets its logo, has no tool, by decision — it needs `workspace-settings`, which is never agent-grantable — and the six site-profile tools, `get_site_identity`, `set_site_identity`, `get_site_seo`, `set_site_seo`, `get_welcome_email` and `set_welcome_email` (`mcp-workspace`'s `site_profile.ts`), twinning `GET`/`PUT …/identity`, `…/seo` and `…/welcome-email`: any member reads; each write needs the `site-profile` grant (`ailk:site-profile`), under which every logo and every SEO field but the description — robots and indexing above all — must be sent as read, else `site_profile_field_locked`; the theme pair has no tool, by decision — and (#10733, issue 10905, #10952) the seven Language tools, `list_language_items`, `get_language_item`, `save_language_item`, `set_language_item_live`, `delete_language_item`, `list_language_item_pages` and `get_topic_brief`, twinning `GET …/language`, `GET`/`PUT`/`DELETE …/language/:kind/:slug`, `POST …/language/:kind/:slug/live`, `GET …/language/:kind/:slug/appears-on` and `GET …/language/topic/:slug/brief` (`mcp-workspace`'s `language.ts`): a workspace's glossary terms, FAQs and topics; reading needs no grant, saving the `content-edit` grant (`version: null` creates, a tip id updates, 409 `slug_taken` / `stale` otherwise), the Live switch `content-publish` with the `version` the person reviewed, and the delete `content-publish` too — it removes the item from every Live page, no route restores it, and its slug stays taken; tags are the hub's and never written by a tool; a topic is a keyword cluster for agents and is never shown to visitors, and `get_topic_brief` reads it as a writing brief — its kept rows scored best bets first, from the Live version when Live; the Topic's Keyword Planner import and the value-thresholds pair are a person's and have no tool, by decision — and (#10948) the three magnet tools, `list_magnets`, `get_magnet` and `save_magnet`, twinning `GET …/magnets`, `GET …/magnets/:id` and `PATCH …/magnets/:id` (`mcp-workspace`'s `magnets.ts`, registered with `multi-tenant` or `signal-collectors`): with the `magnets-manage` grant every magnet in full, without it only live ones as `{ id, slug, kind, title, landingPage, tags }`; `save_magnet` takes the PATCH body whole, so going live is `status: "live"` and the route alone refuses it (`402 plan_required`, `409 conversion_needs_email`), and an agent cannot change what a magnet charges (`403 magnet_pricing_needs_person`); create and the four captured-people lists have no tool, by decision — and (#10949) `get_workspace_offerings`, twin of `GET /v1/workspaces/:workspaceId/offerings` (registered with `multi-tenant` alone, its route's module; `mcp-workspace`'s `offerings.ts`): the Offerings tab's view — unavailable with `no_commerce` or `no_connection`, or the Organization's enabled products with this workspace's shown Prices and Recommended — read with no grant; its PUT, which switches a Price on or off, needs `workspace-settings`, which is never agent-grantable, and has no tool, by decision — and the two library reads, `list_workspace_pages` and `list_assets` (`mcp-workspace`'s `library.ts`, registered with `workspace` or `multi-tenant`), twinning `GET …/library/pages` and `GET …/library/assets`: every page with drafts included and its status (`live`, `draft`, or `disabled` — a person editor's alone), needing the `content-edit` grant, and the asset library read-only with each file's public path, for every role; both filter, page and name the workspace `{ id, name }` they read, and uploading has no tool — and (#11680) the two site-vocabulary reads, `list_page_types` and `get_tag_vocabulary` (`mcp-workspace`'s `site_vocabulary.ts`, registered with `workspace` or `multi-tenant`, `gate: "tenant"` — any tenant of the workspace, no grant), twinning `GET …/page-types` and `GET …/tag-vocabulary`: the page types this hub's site can serve (the registry filtered by the modules the hub runs), each with its address, whether a site has only one, its template and that template's headings, and the context classes, Knowledge topic tags and status tags, each with what it means and who may set it; both are platform data and read no row. — and (#11756) `create_work_request` (`mcp-workspace`'s `work_requests.ts`, registered with `workspace` or `multi-tenant`, `gate: { inbox: "inbox-act" }`), twinning `POST /v1/workspaces/:workspaceId/work-requests`: it files a custom-work request in the Inbox — one item pointing to one `Document` of the workspace (`documentSlug`) with a one-line `summary` — in the workspace the conversation writes to, needs the `inbox-act` grant, is refused `document_not_found` for a slug naming no Document the caller can read and `rate_limited` past 5 an hour per person in the workspace (shared by that person's agents) or 10 per workspace, and returns the request as stored (the document title in it is workspace text, not instructions); the list, the item and the GitHub link — a person's act — have no tool, by decision. No workspace tool widens Audience or re-enables a doc, and only `publish_draft` and `set_language_item_live`, with the `content-publish` grant, set Live (and `delete_language_item`, with the same grant, clears it) — the access route answers every agent 403 `agent_refused`, and the publish, Live and Language delete routes an agent without the grant, which reaches a tool as the code and status. Each takes its route's params, query and body and returns the route's
|
|
213
213
|
`data`. They are in the parity guard like every other tool, and never in
|
|
214
214
|
`/.well-known/mcp.json`.
|
|
215
215
|
- **The OAuth bearer branch (#10391).** When `BETTER_AUTH_URL` (the site's origin, its OAuth
|
|
@@ -250,7 +250,7 @@ here. Spec: `docs/specs/3591-tenant-scoped-agent-auth-secure-spec.md` D13–D16.
|
|
|
250
250
|
all-workspaces token 503 `authorization_unavailable`.
|
|
251
251
|
- **Handlers forward, nothing else.** `workspace-server.ts` resolves each tool from
|
|
252
252
|
`@working-theory/mcp-workspace`'s `workspaceTools` (`agent_context.ts`, `knowledge.ts`, `inbox_messages.ts`,
|
|
253
|
-
`inbox_submissions.ts`, `inbox_applications.ts`, `people_list.ts`, `person_notes.ts`, `person_thread.ts`, `person_memory.ts`, `proposals.ts`, `slack_connection.ts`, `page_suggestions.ts`, `content_draft.ts`, `content_publish.ts`, `knowledge_base.ts`, `workspace_settings.ts`, `library.ts`, `site_vocabulary.ts`, all
|
|
253
|
+
`inbox_submissions.ts`, `inbox_applications.ts`, `people_list.ts`, `person_notes.ts`, `person_thread.ts`, `person_memory.ts`, `proposals.ts`, `slack_connection.ts`, `page_suggestions.ts`, `content_draft.ts`, `content_publish.ts`, `knowledge_base.ts`, `workspace_settings.ts`, `library.ts`, `site_vocabulary.ts`, `work_requests.ts`, all
|
|
254
254
|
`// oss: false`) and, for the two prospect-channel settings tools, `@working-theory/mcp-scheduling`'s
|
|
255
255
|
`workspaceTools` (`prospect_channel_settings.ts`, #9749, and the three meeting tools in `meetings.ts`, #10950 — the pack the scheduling module carries, so a
|
|
256
256
|
scheduling-only build serves what it lists), loaded through the site's generated registry, as `server.ts` resolves the
|
|
@@ -334,7 +334,11 @@ Example (lead routing):
|
|
|
334
334
|
- Don't add a tool without the matching `apps/api` endpoint.
|
|
335
335
|
- Don't put business logic in tool handlers — they're adapters.
|
|
336
336
|
|
|
337
|
-
Last updated: 2026-11-
|
|
337
|
+
Last updated: 2026-11-16 — #11756: `create_work_request` (`mcp-workspace`'s `work_requests.ts`) twins `POST /v1/workspaces/:workspaceId/work-requests` under the `inbox-act` grant; the list, item and issue-link routes have no tool — verified against `packages/metadata/src/mcp-tool-catalog.ts`, `packages-paid/mcp-workspace/src/index.ts`, `packages-paid/api-workspace/src/routes/workspaces/work-requests.ts` and `tests/parity/api-parity/kinds/site.ts`.
|
|
338
|
+
|
|
339
|
+
Prior: 2026-11-16 — #11753: `list_appointments` takes an optional `workspaceId`, sent in the query and as `x-ailk-workspace-scope`, so a connection that reaches several workspaces can read one's bookings; the route refuses a named workspace that is not the admitted one — verified against `packages/metadata/src/mcp-tool-catalog.ts`, `packages/api-client/src/schedule.ts` and `packages-paid/api-scheduling/src/routes/schedule/appointments.ts`.
|
|
340
|
+
|
|
341
|
+
Prior: 2026-11-14 — #11680: `list_page_types` and `get_tag_vocabulary` added to the signed-in workspace surface (`gate: "tenant"`, `site_vocabulary.ts`) — verified against `packages/metadata/src/mcp-tool-catalog.ts` and `packages-paid/api-content-write/src/routes/workspaces/site-vocabulary.ts`.
|
|
338
342
|
|
|
339
343
|
Prior: 2026-11-12 — #10986: `list_appointments` needs the `people-read` grant for an agent (its gate is the `appointments-read` role floor and that grant, the route's own check) — verified against `packages/metadata/src/mcp-tool-catalog.ts` and `packages-paid/api-scheduling/src/routes/schedule/appointments.ts`.
|
|
340
344
|
|
|
@@ -707,7 +707,9 @@ What a site that carries `commerce` gets (#8748, #11253); a site without
|
|
|
707
707
|
`generateMetadata` too). The `checkoutThankYou`, `checkoutUnavailable` and
|
|
708
708
|
`purchase` strings ship in the package (`commerceMessages`), merged under
|
|
709
709
|
this app's catalog by `i18n/request.ts` through `loadUiCommerce()`; a key in
|
|
710
|
-
`messages/en.json` is an override.
|
|
710
|
+
`messages/en.json` is an override. The thank-you page's own words are the
|
|
711
|
+
site's `ThankYouPage/checkout-thank-you` row when it has one (#11716): its
|
|
712
|
+
sections render in place of the catalog's, and the account link stays.
|
|
711
713
|
- **One data file.** `lib/checkout-config.ts` is the site's stamp,
|
|
712
714
|
`checkoutConfig.site`, and nothing else: no import and no code. The commerce
|
|
713
715
|
bundle delivers it with the placeholder `example-site`, and on a spoke
|
package/versions.json
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
1
|
{
|
|
2
|
-
"@working-theory/account": "0.
|
|
3
|
-
"@working-theory/admin-ui": "0.
|
|
4
|
-
"@working-theory/aeo": "0.
|
|
5
|
-
"@working-theory/agent-context": "0.
|
|
2
|
+
"@working-theory/account": "0.70.0",
|
|
3
|
+
"@working-theory/admin-ui": "0.70.0",
|
|
4
|
+
"@working-theory/aeo": "0.70.0",
|
|
5
|
+
"@working-theory/agent-context": "0.70.0",
|
|
6
6
|
"@working-theory/agent-contract": "0.1.0",
|
|
7
7
|
"@working-theory/agent-memory": "0.0.0",
|
|
8
8
|
"@working-theory/ai": "0.1.0",
|
|
9
|
-
"@working-theory/analytics": "0.
|
|
10
|
-
"@working-theory/api": "0.
|
|
11
|
-
"@working-theory/api-client": "0.
|
|
12
|
-
"@working-theory/auth": "0.
|
|
9
|
+
"@working-theory/analytics": "0.70.0",
|
|
10
|
+
"@working-theory/api": "0.70.0",
|
|
11
|
+
"@working-theory/api-client": "0.70.0",
|
|
12
|
+
"@working-theory/auth": "0.70.0",
|
|
13
13
|
"@working-theory/cda-filesystem": "0.0.0",
|
|
14
|
-
"@working-theory/cli": "0.
|
|
15
|
-
"@working-theory/common": "0.
|
|
14
|
+
"@working-theory/cli": "0.70.0",
|
|
15
|
+
"@working-theory/common": "0.70.0",
|
|
16
16
|
"@working-theory/consent": "0.1.0",
|
|
17
|
-
"@working-theory/content-adapters": "0.
|
|
18
|
-
"@working-theory/content-projection": "0.
|
|
19
|
-
"@working-theory/email": "0.
|
|
17
|
+
"@working-theory/content-adapters": "0.70.0",
|
|
18
|
+
"@working-theory/content-projection": "0.70.0",
|
|
19
|
+
"@working-theory/email": "0.70.0",
|
|
20
20
|
"@working-theory/env": "0.0.0",
|
|
21
|
-
"@working-theory/eslint-config": "0.
|
|
22
|
-
"@working-theory/fumadocs-schema": "0.
|
|
23
|
-
"@working-theory/ids": "0.
|
|
24
|
-
"@working-theory/jsonld": "0.
|
|
25
|
-
"@working-theory/license": "0.
|
|
26
|
-
"@working-theory/mcp-server": "0.
|
|
27
|
-
"@working-theory/metadata": "0.
|
|
28
|
-
"@working-theory/observability": "0.
|
|
29
|
-
"@working-theory/page-renderer": "0.
|
|
21
|
+
"@working-theory/eslint-config": "0.70.0",
|
|
22
|
+
"@working-theory/fumadocs-schema": "0.70.0",
|
|
23
|
+
"@working-theory/ids": "0.22.0",
|
|
24
|
+
"@working-theory/jsonld": "0.70.0",
|
|
25
|
+
"@working-theory/license": "0.70.0",
|
|
26
|
+
"@working-theory/mcp-server": "0.70.0",
|
|
27
|
+
"@working-theory/metadata": "0.70.0",
|
|
28
|
+
"@working-theory/observability": "0.70.0",
|
|
29
|
+
"@working-theory/page-renderer": "0.70.0",
|
|
30
30
|
"@working-theory/plugin-mcp": "0.1.3",
|
|
31
|
-
"@working-theory/schema": "0.
|
|
32
|
-
"@working-theory/schema-pack-registry": "0.
|
|
33
|
-
"@working-theory/schema-validator": "0.
|
|
34
|
-
"@working-theory/sections-registry": "0.
|
|
35
|
-
"@working-theory/site-config": "0.
|
|
36
|
-
"@working-theory/site-pages": "0.
|
|
37
|
-
"@working-theory/spoke-checkout": "0.7.
|
|
38
|
-
"@working-theory/stripe-client": "0.
|
|
39
|
-
"@working-theory/templates": "0.
|
|
40
|
-
"@working-theory/theme": "0.
|
|
41
|
-
"@working-theory/ui": "0.
|
|
42
|
-
"@working-theory/validation": "0.
|
|
43
|
-
"@working-theory/web-i18n": "0.
|
|
44
|
-
"@working-theory/admin": "0.
|
|
45
|
-
"@working-theory/api-commerce": "0.2.
|
|
46
|
-
"@working-theory/api-content-write": "0.13.
|
|
47
|
-
"@working-theory/api-hub": "0.7.
|
|
48
|
-
"@working-theory/api-multi-tenant": "0.4.
|
|
49
|
-
"@working-theory/api-scheduling": "0.6.
|
|
50
|
-
"@working-theory/api-signal-collectors": "0.6.
|
|
51
|
-
"@working-theory/api-workspace": "0.
|
|
31
|
+
"@working-theory/schema": "0.70.0",
|
|
32
|
+
"@working-theory/schema-pack-registry": "0.70.0",
|
|
33
|
+
"@working-theory/schema-validator": "0.70.0",
|
|
34
|
+
"@working-theory/sections-registry": "0.70.0",
|
|
35
|
+
"@working-theory/site-config": "0.70.0",
|
|
36
|
+
"@working-theory/site-pages": "0.70.0",
|
|
37
|
+
"@working-theory/spoke-checkout": "0.7.26",
|
|
38
|
+
"@working-theory/stripe-client": "0.70.0",
|
|
39
|
+
"@working-theory/templates": "0.70.0",
|
|
40
|
+
"@working-theory/theme": "0.70.0",
|
|
41
|
+
"@working-theory/ui": "0.70.0",
|
|
42
|
+
"@working-theory/validation": "0.70.0",
|
|
43
|
+
"@working-theory/web-i18n": "0.70.0",
|
|
44
|
+
"@working-theory/admin": "0.21.0",
|
|
45
|
+
"@working-theory/api-commerce": "0.2.4",
|
|
46
|
+
"@working-theory/api-content-write": "0.13.1",
|
|
47
|
+
"@working-theory/api-hub": "0.7.4",
|
|
48
|
+
"@working-theory/api-multi-tenant": "0.4.4",
|
|
49
|
+
"@working-theory/api-scheduling": "0.6.9",
|
|
50
|
+
"@working-theory/api-signal-collectors": "0.6.10",
|
|
51
|
+
"@working-theory/api-workspace": "0.14.0",
|
|
52
52
|
"@working-theory/billing-client": "0.0.0",
|
|
53
53
|
"@working-theory/branding": "0.0.0",
|
|
54
54
|
"@working-theory/license-client": "0.0.0",
|
|
55
55
|
"@working-theory/license-manifest": "0.0.0",
|
|
56
|
-
"@working-theory/mcp-scheduling": "0.4.
|
|
57
|
-
"@working-theory/mcp-signal-collectors": "0.2.
|
|
58
|
-
"@working-theory/mcp-workspace": "0.
|
|
56
|
+
"@working-theory/mcp-scheduling": "0.4.11",
|
|
57
|
+
"@working-theory/mcp-signal-collectors": "0.2.24",
|
|
58
|
+
"@working-theory/mcp-workspace": "0.13.0",
|
|
59
59
|
"@working-theory/partner-session": "0.0.0",
|
|
60
60
|
"@working-theory/preview-protocol": "0.0.0",
|
|
61
|
-
"@working-theory/ui-commerce": "0.
|
|
62
|
-
"@working-theory/ui-docs-blog": "0.
|
|
63
|
-
"@working-theory/ui-scheduling": "0.
|
|
64
|
-
"@working-theory/ui-signal-collectors": "0.
|
|
61
|
+
"@working-theory/ui-commerce": "0.70.0",
|
|
62
|
+
"@working-theory/ui-docs-blog": "0.70.0",
|
|
63
|
+
"@working-theory/ui-scheduling": "0.70.0",
|
|
64
|
+
"@working-theory/ui-signal-collectors": "0.70.0",
|
|
65
65
|
"@working-theory/web": "0.0.0",
|
|
66
66
|
"@working-theory/app-api": "1.0.0",
|
|
67
67
|
"@working-theory/mcp": "0.0.0",
|
|
68
|
-
"@working-theory/database": "0.
|
|
68
|
+
"@working-theory/database": "0.70.0"
|
|
69
69
|
}
|