@plitzi/sdk-mcp 0.39.2 → 0.39.4
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/CHANGELOG.md +27 -0
- package/README.md +39 -39
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/modules/mcp/answerBudgets.d.ts +29 -0
- package/dist/modules/mcp/answerBudgets.js +37 -0
- package/dist/modules/mcp/apps/example/view/index.tsx +0 -1
- package/dist/modules/mcp/apps/render/view/index.tsx +0 -1
- package/dist/modules/mcp/helpers/guide/reference.d.ts +1 -1
- package/dist/modules/mcp/helpers/guide/reference.js +7 -2
- package/dist/modules/mcp/helpers/guide/structure.d.ts +1 -1
- package/dist/modules/mcp/helpers/guide/structure.js +1 -0
- package/dist/modules/mcp/helpers/opResult.d.ts +3 -1
- package/dist/modules/mcp/helpers/opResult.js +3 -1
- package/dist/modules/mcp/localScreenshotClient.d.ts +10 -0
- package/dist/modules/mcp/localScreenshotClient.js +46 -16
- package/dist/modules/mcp/previewClient.js +2 -2
- package/dist/modules/mcp/resources/canonical.js +2 -2
- package/dist/modules/mcp/server.d.ts +1 -1
- package/dist/modules/mcp/server.js +3 -2
- package/dist/modules/mcp/tools/activity.js +2 -2
- package/dist/modules/mcp/tools/apply/dispatch.js +7 -1
- package/dist/modules/mcp/tools/apply/index.d.ts +25 -1
- package/dist/modules/mcp/tools/apply/index.js +21 -5
- package/dist/modules/mcp/tools/describeOperation.js +1 -1
- package/dist/modules/mcp/tools/intents.js +26 -4
- package/dist/modules/mcp/tools/look.d.ts +1 -0
- package/dist/modules/mcp/tools/look.js +2 -1
- package/dist/modules/mcp/tools/operations/actions/deleteAction.js +1 -1
- package/dist/modules/mcp/tools/operations/actions/patchAction.js +3 -3
- package/dist/modules/mcp/tools/operations/actions/upsertAction.js +1 -1
- package/dist/modules/mcp/tools/operations/connectors/deleteConnector.js +1 -1
- package/dist/modules/mcp/tools/operations/connectors/patchConnector.js +2 -2
- package/dist/modules/mcp/tools/operations/data/index.js +3 -3
- package/dist/modules/mcp/tools/operations/functions/index.js +2 -2
- package/dist/modules/mcp/tools/operations/index.d.ts +97 -4
- package/dist/modules/mcp/tools/operations/index.js +1 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +1 -1
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +1 -1
- package/dist/modules/mcp/tools/operations/schema/components/deleteComponent.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/components/upsertComponent.js +8 -8
- package/dist/modules/mcp/tools/operations/schema/elements/addSpec.d.ts +29 -0
- package/dist/modules/mcp/tools/operations/schema/elements/addSpec.js +118 -0
- package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +4 -4
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +2 -0
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +3 -3
- package/dist/modules/mcp/tools/operations/schema/flags/deleteFlag.js +1 -1
- package/dist/modules/mcp/tools/operations/schema/flags/upsertFlag.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +1 -1
- package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +1 -1
- package/dist/modules/mcp/tools/operations/schema/index.d.ts +1 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +4 -4
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +1 -1
- package/dist/modules/mcp/tools/operations/schema/operations.d.ts +25 -1
- package/dist/modules/mcp/tools/operations/schema/operations.js +2 -0
- package/dist/modules/mcp/tools/operations/schema/pages/deleteLayout.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +1 -1
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +4 -0
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +14 -7
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +8 -1
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +9 -6
- package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +3 -2
- package/dist/modules/mcp/tools/operations/schema/write.js +3 -3
- package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +2 -1
- package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +1 -1
- package/dist/modules/mcp/tools/operations/style/fonts/deleteFont.js +2 -2
- package/dist/modules/mcp/tools/operations/style/fonts/upsertFont.js +1 -1
- package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +2 -1
- package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +1 -1
- package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +2 -1
- package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +1 -1
- package/dist/modules/mcp/tools/operations/style/validate.js +6 -6
- package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +3 -2
- package/dist/modules/mcp/tools/operations/style/write.js +1 -1
- package/dist/modules/mcp/tools/render.d.ts +24 -1
- package/dist/modules/mcp/tools/renderWidget.d.ts +24 -1
- package/dist/modules/mcp/tools/search.js +1 -1
- package/dist/modules/mcp/tools/shared/agentHtml.d.ts +8 -0
- package/dist/modules/mcp/tools/shared/agentHtml.js +18 -0
- package/dist/modules/mcp/tools/shared/lintDraft.js +1 -0
- package/dist/modules/mcp/tools/shared/look.d.ts +2 -0
- package/dist/modules/mcp/tools/shared/look.js +15 -8
- package/dist/modules/mcp/tools/shared/repeats.d.ts +1 -1
- package/dist/modules/mcp/tools/shared/repeats.js +1 -1
- package/dist/modules/mcp/tools/shared/tool.d.ts +2 -0
- package/dist/modules/mcp/tools/shared/validator/connectors.js +3 -0
- package/dist/modules/mcp/tools/shared/validator/css.js +2 -0
- package/dist/modules/mcp/tools/shared/validator/elements.js +3 -0
- package/dist/modules/mcp/tools/shared/validator/index.js +39 -0
- package/dist/modules/mcp/tools/shared/validator/interactions.js +1 -0
- package/dist/modules/mcp/tools/shared/validator/refs.js +3 -0
- package/dist/modules/mcp/tools/tryFunction.js +2 -2
- package/dist/modules/mcp/types/aiSchema.d.ts +3 -0
- package/dist/modules/mcp/types/previewTypes.d.ts +9 -1
- package/dist/options.d.ts +1 -1
- package/dist/preview/createPreview.js +38 -7
- package/package.json +8 -8
|
@@ -71,6 +71,19 @@ export declare const elementOps: {
|
|
|
71
71
|
inside: "inside";
|
|
72
72
|
}>;
|
|
73
73
|
}, import('zod/v4/core').$strip>;
|
|
74
|
+
addSpec: import('zod').ZodObject<{
|
|
75
|
+
type: import('zod').ZodLiteral<"addSpec">;
|
|
76
|
+
pageRef: import('zod').ZodString;
|
|
77
|
+
parentRef: import('zod').ZodOptional<import('zod').ZodString>;
|
|
78
|
+
position: import('zod').ZodOptional<import('zod').ZodEnum<{
|
|
79
|
+
before: "before";
|
|
80
|
+
after: "after";
|
|
81
|
+
inside: "inside";
|
|
82
|
+
}>>;
|
|
83
|
+
replaces: import('zod').ZodOptional<import('zod').ZodString>;
|
|
84
|
+
spec: import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodUnknown>;
|
|
85
|
+
classes: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodUnknown>>>;
|
|
86
|
+
}, import('zod/v4/core').$strip>;
|
|
74
87
|
upsertPage: import('zod').ZodObject<{
|
|
75
88
|
type: import('zod').ZodLiteral<"upsertPage">;
|
|
76
89
|
ref: import('zod').ZodString;
|
|
@@ -86,6 +99,10 @@ export declare const elementOps: {
|
|
|
86
99
|
noBounce: "noBounce";
|
|
87
100
|
}>>>;
|
|
88
101
|
flag: import('zod').ZodOptional<import('zod').ZodNullable<import('zod').ZodString>>;
|
|
102
|
+
style: import('zod').ZodOptional<import('zod').ZodObject<{
|
|
103
|
+
base: import('zod').ZodOptional<import('zod').ZodArray<import('zod').ZodString>>;
|
|
104
|
+
slots: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodArray<import('zod').ZodString>>>;
|
|
105
|
+
}, import('zod/v4/core').$strip>>;
|
|
89
106
|
}, import('zod/v4/core').$strip>;
|
|
90
107
|
deletePage: import('zod').ZodObject<{
|
|
91
108
|
type: import('zod').ZodLiteral<"deletePage">;
|
|
@@ -304,9 +321,16 @@ export declare const elementOps: {
|
|
|
304
321
|
dark: import('zod').ZodOptional<import('zod').ZodString>;
|
|
305
322
|
}, import('zod/v4/core').$strip>]>>;
|
|
306
323
|
robotsTxt: import('zod').ZodOptional<import('zod').ZodString>;
|
|
307
|
-
|
|
324
|
+
securityTxt: import('zod').ZodOptional<import('zod').ZodString>;
|
|
325
|
+
llmsTxt: import('zod').ZodOptional<import('zod').ZodString>;
|
|
326
|
+
blockAiCrawlers: import('zod').ZodOptional<import('zod').ZodArray<import('zod').ZodEnum<{
|
|
327
|
+
training: "training";
|
|
328
|
+
assistants: "assistants";
|
|
329
|
+
search: "search";
|
|
330
|
+
}>>>;
|
|
308
331
|
viewTransitions: import('zod').ZodOptional<import('zod').ZodBoolean>;
|
|
309
332
|
withheldPage: import('zod').ZodOptional<import('zod').ZodString>;
|
|
333
|
+
wholeDocument: import('zod').ZodOptional<import('zod').ZodBoolean>;
|
|
310
334
|
channels: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodNullable<import('zod').ZodObject<{
|
|
311
335
|
access: import('zod').ZodObject<{
|
|
312
336
|
mode: import('zod').ZodEnum<{
|
|
@@ -3,6 +3,7 @@ import { patchBindingOp } from "./bindings/patchBinding.js";
|
|
|
3
3
|
import { upsertBindingOp } from "./bindings/upsertBinding.js";
|
|
4
4
|
import { deleteComponentOp } from "./components/deleteComponent.js";
|
|
5
5
|
import { upsertComponentOp } from "./components/upsertComponent.js";
|
|
6
|
+
import { addSpecOp } from "./elements/addSpec.js";
|
|
6
7
|
import { deleteElementOp } from "./elements/deleteElement.js";
|
|
7
8
|
import { moveElementOp } from "./elements/moveElement.js";
|
|
8
9
|
import { patchElementOp } from "./elements/patchElement.js";
|
|
@@ -29,6 +30,7 @@ var elementOps = {
|
|
|
29
30
|
patchElement: patchElementOp,
|
|
30
31
|
deleteElement: deleteElementOp,
|
|
31
32
|
moveElement: moveElementOp,
|
|
33
|
+
addSpec: addSpecOp,
|
|
32
34
|
upsertPage: upsertPageOp,
|
|
33
35
|
deletePage: deletePageOp,
|
|
34
36
|
upsertLayout: upsertLayoutOp,
|
|
@@ -10,7 +10,7 @@ var deleteLayoutOp = z.object({
|
|
|
10
10
|
}).describe("Delete a layout shell and everything in it. Refused while a page still renders inside it (detach with upsertPage { layout: null }). Destructive: what it holds is on every page that uses it — confirm first.");
|
|
11
11
|
var deleteLayout = (space, env, op) => {
|
|
12
12
|
const layout = findLayoutByRef(space.schema, op.ref);
|
|
13
|
-
if (!layout) return fail("ref", `Layout "${op.ref}" not found`, `Read plitzi://schema/${env}/layouts for valid refs`);
|
|
13
|
+
if (!layout) return fail("missing", "ref", `Layout "${op.ref}" not found`, `Read plitzi://schema/${env}/layouts for valid refs`);
|
|
14
14
|
/**
|
|
15
15
|
* A shell still in use is not deleted, it is REFUSED — and the pages are named.
|
|
16
16
|
*
|
|
@@ -19,7 +19,7 @@ var deleteLayout = (space, env, op) => {
|
|
|
19
19
|
* a decision about pages the caller did not mention.
|
|
20
20
|
*/
|
|
21
21
|
const inUse = pagesUsingLayout(space.schema, layout.id);
|
|
22
|
-
if (inUse.length > 0) return fail("ref", `Layout "${op.ref}" is still used by ${inUse.length} page(s): ${inUse.map((page) => page.id).join(", ")}`, "Detach them first with upsertPage { layout: null }, or point them at another shell");
|
|
22
|
+
if (inUse.length > 0) return fail("in-use", "ref", `Layout "${op.ref}" is still used by ${inUse.length} page(s): ${inUse.map((page) => page.id).join(", ")}`, "Detach them first with upsertPage { layout: null }, or point them at another shell");
|
|
23
23
|
const removedIds = descendants(space.schema.flat, layout.id);
|
|
24
24
|
const removed = removedIds.map((id) => space.schema.flat[id]);
|
|
25
25
|
for (const id of [...removedIds, layout.id]) Reflect.deleteProperty(space.schema.flat, id);
|
|
@@ -10,7 +10,7 @@ var deletePageOp = z.object({
|
|
|
10
10
|
}).describe("Delete a page and every element on it.");
|
|
11
11
|
var deletePage = (space, env, op) => {
|
|
12
12
|
const page = findPageByRef(space.schema, op.ref);
|
|
13
|
-
if (!page) return fail("ref", `Page "${op.ref}" not found`, "Read the pages resource for valid refs");
|
|
13
|
+
if (!page) return fail("missing", "ref", `Page "${op.ref}" not found`, "Read the pages resource for valid refs");
|
|
14
14
|
const removedIds = descendants(space.schema.flat, page.id);
|
|
15
15
|
const removed = removedIds.map((id) => space.schema.flat[id]);
|
|
16
16
|
for (const id of [...removedIds, page.id]) Reflect.deleteProperty(space.schema.flat, id);
|
|
@@ -16,6 +16,10 @@ export declare const upsertPageOp: z.ZodObject<{
|
|
|
16
16
|
noBounce: "noBounce";
|
|
17
17
|
}>>>;
|
|
18
18
|
flag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
19
|
+
style: z.ZodOptional<z.ZodObject<{
|
|
20
|
+
base: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
21
|
+
slots: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
22
|
+
}, z.core.$strip>>;
|
|
19
23
|
}, z.core.$strip>;
|
|
20
24
|
export type UpsertPage = z.infer<typeof upsertPageOp>;
|
|
21
25
|
export declare const upsertPage: (space: Space, env: Env, op: UpsertPage) => OpResult;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
2
2
|
import { layoutsUri, pageUri, pagesUri } from "../../../../helpers/uris.js";
|
|
3
3
|
import { findFolderByRef, findLayoutByRef, findPageByRef, indexAddPage, resolveRef } from "../../../../helpers/space.js";
|
|
4
|
-
import { elementFlag } from "../shared.js";
|
|
4
|
+
import { elementFlag, styleRefs } from "../shared.js";
|
|
5
5
|
import { guardNewRef } from "../write.js";
|
|
6
6
|
import { DOCUMENT_SCROLLS, flagGateOf } from "@plitzi/sdk-authoring";
|
|
7
7
|
import { z } from "zod";
|
|
@@ -17,8 +17,14 @@ var upsertPageOp = z.object({
|
|
|
17
17
|
layoutContainer: z.string().nullable().optional().describe("Ref of the container INSIDE that shell where this page body goes — the slot. Must belong to it."),
|
|
18
18
|
enabled: z.boolean().optional().describe("false disables the page in the published SDK runtime (not routable/accessible to end users); it stays editable here. Defaults to true"),
|
|
19
19
|
documentScroll: z.enum(DOCUMENT_SCROLLS).nullable().optional().describe("\"locked\": the document never moves, only overflow:auto panels scroll; \"noBounce\": no rubber band"),
|
|
20
|
-
flag: elementFlag.nullable().optional()
|
|
20
|
+
flag: elementFlag.nullable().optional(),
|
|
21
|
+
style: styleRefs.optional().describe("The page's own classes — its root: the page's background, its padding, how it lays its body out. Replaces what the page wore; a class is a definition (upsertDefinition)")
|
|
21
22
|
}).describe("Create a page, or update it when ref already exists (only the fields you pass change).");
|
|
23
|
+
/** A page root's selectors, from the classes the operation names: base, and each slot's. */
|
|
24
|
+
var selectorsOf = (style) => ({
|
|
25
|
+
base: (style.base ?? []).join(" "),
|
|
26
|
+
...Object.fromEntries(Object.entries(style.slots ?? {}).map(([slot, classes]) => [slot, classes.join(" ")]))
|
|
27
|
+
});
|
|
22
28
|
var upsertPage = (space, env, op) => {
|
|
23
29
|
const slug = op.slug === void 0 ? void 0 : op.slug.replace(/^\/+/, "");
|
|
24
30
|
let folderValue;
|
|
@@ -26,7 +32,7 @@ var upsertPage = (space, env, op) => {
|
|
|
26
32
|
if (op.folder === null || op.folder === "") folderValue = "";
|
|
27
33
|
else {
|
|
28
34
|
const resolved = findFolderByRef(space.schema, op.folder);
|
|
29
|
-
if (!resolved) return fail("folder", `Folder "${op.folder}" not found`, "Create it with upsertFolder, or read plitzi://folders");
|
|
35
|
+
if (!resolved) return fail("missing", "folder", `Folder "${op.folder}" not found`, "Create it with upsertFolder, or read plitzi://folders");
|
|
30
36
|
folderValue = resolved.id;
|
|
31
37
|
}
|
|
32
38
|
}
|
|
@@ -41,7 +47,7 @@ var upsertPage = (space, env, op) => {
|
|
|
41
47
|
let slotValue;
|
|
42
48
|
if (op.layout !== void 0) {
|
|
43
49
|
if (op.layout === null || op.layout === "") layoutValue = "";
|
|
44
|
-
else if (!findLayoutByRef(space.schema, op.layout)) return fail("layout", `Layout "${op.layout}" not found`, "Create it with upsertLayout, or read plitzi://schema/" + env + "/layouts");
|
|
50
|
+
else if (!findLayoutByRef(space.schema, op.layout)) return fail("missing", "layout", `Layout "${op.layout}" not found`, "Create it with upsertLayout, or read plitzi://schema/" + env + "/layouts");
|
|
45
51
|
else layoutValue = op.layout;
|
|
46
52
|
}
|
|
47
53
|
if (op.layoutContainer !== void 0) {
|
|
@@ -50,8 +56,8 @@ var upsertPage = (space, env, op) => {
|
|
|
50
56
|
const existingPage = findPageByRef(space.schema, op.ref);
|
|
51
57
|
const shellRef = layoutValue ?? existingPage?.attributes.layout;
|
|
52
58
|
const shell = shellRef ? findLayoutByRef(space.schema, shellRef) : void 0;
|
|
53
|
-
if (!shell) return fail("layoutContainer", "A slot needs a layout to be part of", "Pass `layout` in the same op (or set it first) so the slot can be checked against that shell");
|
|
54
|
-
if (!resolveRef(space.schema, shell, op.layoutContainer)) return fail("layoutContainer", `"${op.layoutContainer}" is not an element of layout "${shell.id}"`, `Read plitzi://schema/${env}/pages/${shell.id} and name a container from that tree`);
|
|
59
|
+
if (!shell) return fail("wrong-options", "layoutContainer", "A slot needs a layout to be part of", "Pass `layout` in the same op (or set it first) so the slot can be checked against that shell");
|
|
60
|
+
if (!resolveRef(space.schema, shell, op.layoutContainer)) return fail("bad-value", "layoutContainer", `"${op.layoutContainer}" is not an element of layout "${shell.id}"`, `Read plitzi://schema/${env}/pages/${shell.id} and name a container from that tree`);
|
|
55
61
|
slotValue = op.layoutContainer;
|
|
56
62
|
}
|
|
57
63
|
}
|
|
@@ -69,6 +75,7 @@ var upsertPage = (space, env, op) => {
|
|
|
69
75
|
};
|
|
70
76
|
if (op.documentScroll === null) Reflect.deleteProperty(existing.attributes, "documentScroll");
|
|
71
77
|
else if (op.documentScroll !== void 0) existing.attributes.documentScroll = op.documentScroll;
|
|
78
|
+
if (op.style) existing.definition.styleSelectors = selectorsOf(op.style);
|
|
72
79
|
if (op.flag === null) Reflect.deleteProperty(existing.definition, "flag");
|
|
73
80
|
else if (op.flag !== void 0) existing.definition.flag = flagGateOf(op.flag, `Page "${op.ref}"`);
|
|
74
81
|
return {
|
|
@@ -101,7 +108,7 @@ var upsertPage = (space, env, op) => {
|
|
|
101
108
|
label: op.label ?? op.ref,
|
|
102
109
|
type: "page",
|
|
103
110
|
items: [],
|
|
104
|
-
styleSelectors: { base: "" },
|
|
111
|
+
styleSelectors: op.style ? selectorsOf(op.style) : { base: "" },
|
|
105
112
|
...op.flag ? { flag: flagGateOf(op.flag, `Page "${op.ref}"`) } : {}
|
|
106
113
|
}
|
|
107
114
|
};
|
|
@@ -45,9 +45,16 @@ export declare const patchSettingsOp: z.ZodObject<{
|
|
|
45
45
|
dark: z.ZodOptional<z.ZodString>;
|
|
46
46
|
}, z.core.$strip>]>>;
|
|
47
47
|
robotsTxt: z.ZodOptional<z.ZodString>;
|
|
48
|
-
|
|
48
|
+
securityTxt: z.ZodOptional<z.ZodString>;
|
|
49
|
+
llmsTxt: z.ZodOptional<z.ZodString>;
|
|
50
|
+
blockAiCrawlers: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
51
|
+
training: "training";
|
|
52
|
+
assistants: "assistants";
|
|
53
|
+
search: "search";
|
|
54
|
+
}>>>;
|
|
49
55
|
viewTransitions: z.ZodOptional<z.ZodBoolean>;
|
|
50
56
|
withheldPage: z.ZodOptional<z.ZodString>;
|
|
57
|
+
wholeDocument: z.ZodOptional<z.ZodBoolean>;
|
|
51
58
|
channels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodObject<{
|
|
52
59
|
access: z.ZodObject<{
|
|
53
60
|
mode: z.ZodEnum<{
|
|
@@ -2,7 +2,7 @@ import { empty, fail } from "../../../../helpers/opResult.js";
|
|
|
2
2
|
import { settingsUri } from "../../../../helpers/uris.js";
|
|
3
3
|
import { NOTIFICATIONS_FIELDS, splitNotificationsCss, withNotificationsCss } from "@plitzi/sdk-authoring";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { spaceIdentity, spaceIdentityProblems, withheldPageOf } from "@plitzi/sdk-shared/schema";
|
|
5
|
+
import { AI_CRAWLER_KINDS, spaceIdentity, spaceIdentityProblems, withheldPageOf } from "@plitzi/sdk-shared/schema";
|
|
6
6
|
import { channelProblems } from "@plitzi/sdk-shared/realtime";
|
|
7
7
|
// src/modules/mcp/tools/operations/schema/settings/patchSettings.ts
|
|
8
8
|
var userProvider = z.string();
|
|
@@ -62,9 +62,12 @@ var patchSettingsOp = z.object({
|
|
|
62
62
|
dark: z.string().optional()
|
|
63
63
|
})]).optional(),
|
|
64
64
|
robotsTxt: z.string().optional(),
|
|
65
|
-
|
|
65
|
+
securityTxt: z.string().optional().describe("/.well-known/security.txt, as written (RFC 9116: Contact, Expires)"),
|
|
66
|
+
llmsTxt: z.string().optional().describe("/llms.txt, as written; left out, the site writes one from its public pages (404 with assistants kept out)"),
|
|
67
|
+
blockAiCrawlers: z.array(z.enum(AI_CRAWLER_KINDS)).optional().describe("AI crawlers robots.txt keeps out, by kind: training, assistants (fetching for a person), search"),
|
|
66
68
|
viewTransitions: z.boolean().optional(),
|
|
67
69
|
withheldPage: z.string().optional().describe("Page id drawn for a withheld page (its 401/403); \"\" = Plitzi's words"),
|
|
70
|
+
wholeDocument: z.boolean().optional().describe("Whole space with every page, not in parts"),
|
|
68
71
|
channels: z.record(z.string(), channel.nullable()).optional().describe("Realtime channels by topic pattern (`board:{id}`); null removes one. See the guide")
|
|
69
72
|
}).describe("Merge space-level settings — global CSS, notifications, kept state, auth, realtime channels, the site's identity and robots.txt. Only the fields sent change. customCss is for site-wide CSS, never to style one element (attach a definition for that).");
|
|
70
73
|
/** The space's channels with the patch merged in, pattern by pattern — `null` takes one out. */
|
|
@@ -94,13 +97,13 @@ var patchSettings = (space, env, op) => {
|
|
|
94
97
|
const { type, channels, customCss, notifications: notificationsPatch, ...patch } = op;
|
|
95
98
|
for (const [pattern, declaration] of Object.entries(channels ?? {})) {
|
|
96
99
|
const [problem] = declaration === null ? [] : channelProblems(pattern, declaration);
|
|
97
|
-
if (problem) return fail(`channels["${pattern}"]`, `Channel "${pattern}": ${problem}.`, "Fix the pattern or declaration and send it again");
|
|
100
|
+
if (problem) return fail("bad-value", `channels["${pattern}"]`, `Channel "${pattern}": ${problem}.`, "Fix the pattern or declaration and send it again");
|
|
98
101
|
}
|
|
99
102
|
const [identityProblem] = spaceIdentityProblems(spaceIdentity({
|
|
100
103
|
...space.schema.settings,
|
|
101
104
|
...patch
|
|
102
105
|
}));
|
|
103
|
-
if (identityProblem) return fail("settings", identityProblem, "Fix the field and send it again");
|
|
106
|
+
if (identityProblem) return fail("bad-value", "settings", identityProblem, "Fix the field and send it again");
|
|
104
107
|
const next = { ...space.schema.settings };
|
|
105
108
|
for (const [key, value] of Object.entries(patch)) next[key] = value;
|
|
106
109
|
if (channels) next.channels = mergeChannels(space.schema.settings.channels, channels);
|
|
@@ -109,14 +112,14 @@ var patchSettings = (space, env, op) => {
|
|
|
109
112
|
try {
|
|
110
113
|
next.customCss = patchCustomCss(typeof current === "string" ? current : "", customCss, notificationsPatch);
|
|
111
114
|
} catch (error) {
|
|
112
|
-
return fail("notifications", error instanceof Error ? error.message : String(error), "Write one CSS value per field — a colour, a length or a token like var(--card)");
|
|
115
|
+
return fail("bad-value", "notifications", error instanceof Error ? error.message : String(error), "Write one CSS value per field — a colour, a length or a token like var(--card)");
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
118
|
if (next.withheldPage === "") delete next.withheldPage;
|
|
116
119
|
else if (next.withheldPage !== void 0 && withheldPageOf({
|
|
117
120
|
...space.schema,
|
|
118
121
|
settings: next
|
|
119
|
-
}) === void 0) return fail("withheldPage", `withheldPage "${next.withheldPage}" is no page of the space, or one with an access of its own — withheld from the visitor it is drawn for.`, "Name the id of a page every visitor may see, or \"\" for the platform's words");
|
|
122
|
+
}) === void 0) return fail("bad-value", "withheldPage", `withheldPage "${next.withheldPage}" is no page of the space, or one with an access of its own — withheld from the visitor it is drawn for.`, "Name the id of a page every visitor may see, or \"\" for the platform's words");
|
|
120
123
|
space.schema.settings = next;
|
|
121
124
|
return {
|
|
122
125
|
...empty(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { empty } from "../../../../helpers/opResult.js";
|
|
1
|
+
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
2
2
|
import { schemaVarsUri } from "../../../../helpers/uris.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
// src/modules/mcp/tools/operations/schema/variables/deleteVariable.ts
|
|
@@ -7,7 +7,8 @@ var deleteVariableOp = z.object({
|
|
|
7
7
|
name: z.string().describe("Name of the schema variable to delete")
|
|
8
8
|
}).describe("Delete a space-level schema variable by name.");
|
|
9
9
|
var deleteVariable = (space, env, op) => {
|
|
10
|
-
|
|
10
|
+
if (!space.schema.variables.some((variable) => variable.name === op.name)) return fail("missing", "name", `No variable "${op.name}"`, `Read ${schemaVarsUri(env)} for the variables the space has`);
|
|
11
|
+
space.schema.variables = space.schema.variables.filter((variable) => variable.name !== op.name);
|
|
11
12
|
return {
|
|
12
13
|
...empty(),
|
|
13
14
|
deleted: 1,
|
|
@@ -16,7 +16,7 @@ var guardNewRef = (space, ref, field) => {
|
|
|
16
16
|
const elsewhere = documentIds(space.document ?? space.schema).has(ref) ? `"${ref}" is already used by another element here` : null;
|
|
17
17
|
const conflict = elementIdConflict(space.schema.flat, ref) ?? elsewhere;
|
|
18
18
|
if (!conflict) return null;
|
|
19
|
-
return isValidElementId(ref) ? fail(field, conflict, TAKEN_HINT) : fail(field, conflict, ID_REF_HINT);
|
|
19
|
+
return isValidElementId(ref) ? fail("exists", field, conflict, TAKEN_HINT) : fail("bad-value", field, conflict, ID_REF_HINT);
|
|
20
20
|
};
|
|
21
21
|
/** Where an op's `position` puts an element, in the vocabulary of the tree operations every writer shares. */
|
|
22
22
|
var DROP_POSITION = {
|
|
@@ -89,9 +89,9 @@ var resolveTargetRef = (space, elementId) => {
|
|
|
89
89
|
* errors as patchElement without repeating them. */
|
|
90
90
|
var resolveElement = (space, env, pageRef, ref) => {
|
|
91
91
|
const page = findRootByRef(space.schema, pageRef);
|
|
92
|
-
if (!page) return { error: fail("pageRef", `Page or layout "${pageRef}" not found`, `Read plitzi://schema/${env}/pages for valid refs — a layout shell is named there too`) };
|
|
92
|
+
if (!page) return { error: fail("missing", "pageRef", `Page or layout "${pageRef}" not found`, `Read plitzi://schema/${env}/pages for valid refs — a layout shell is named there too`) };
|
|
93
93
|
const el = resolveRef(space.schema, page, ref);
|
|
94
|
-
if (!el || el.id === page.id) return { error: fail("ref", `Element "${ref}" not found in page "${pageRef}"`, "Name an element this page holds") };
|
|
94
|
+
if (!el || el.id === page.id) return { error: fail("missing", "ref", `Element "${ref}" not found in page "${pageRef}"`, "Name an element this page holds") };
|
|
95
95
|
return { el };
|
|
96
96
|
};
|
|
97
97
|
export { DROP_POSITION, ID_REF_HINT, collectInputRefs, createElement, folderUri, foldersUri, guardNewRef, layoutsUri, pageUri, pagesUri, resolveElement, resolveTargetRef, schemaVarsUri, settingsUri, writeInitialState };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defUri, defsUri } from "../../../../helpers/uris.js";
|
|
2
|
-
import { empty } from "../../../../helpers/opResult.js";
|
|
2
|
+
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
3
3
|
import { MODES, guardKind } from "../write.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
// src/modules/mcp/tools/operations/style/definitions/deleteDefinition.ts
|
|
@@ -10,6 +10,7 @@ var deleteDefinitionOp = z.object({
|
|
|
10
10
|
var deleteDefinition = (space, env, op) => {
|
|
11
11
|
const guard = guardKind(space.style, op.ref, "class");
|
|
12
12
|
if (guard) return guard;
|
|
13
|
+
if (!MODES.some((mode) => Object.hasOwn(space.style.platform[mode], op.ref))) return fail("missing", "ref", `No class "${op.ref}"`, `Read ${defsUri(env)} for what there is`);
|
|
13
14
|
for (const mode of MODES) Reflect.deleteProperty(space.style.platform[mode], op.ref);
|
|
14
15
|
return {
|
|
15
16
|
...empty(),
|
|
@@ -14,7 +14,7 @@ var patchDefinition = (space, env, op) => {
|
|
|
14
14
|
const guard = guardKind(space.style, op.ref, "class");
|
|
15
15
|
if (guard) return guard;
|
|
16
16
|
const existing = definitionToAI(space.style, op.ref);
|
|
17
|
-
if (!existing) return fail("ref", `Definition "${op.ref}" not found`, "patchDefinition only updates an existing definition; use upsertDefinition to create one");
|
|
17
|
+
if (!existing) return fail("missing", "ref", `Definition "${op.ref}" not found`, "patchDefinition only updates an existing definition; use upsertDefinition to create one");
|
|
18
18
|
const { type, ref, slots: slotsPatch, ...basePatch } = op;
|
|
19
19
|
const { base, slots } = mergePatch(existing, basePatch, slotsPatch);
|
|
20
20
|
const problem = writeStyleItem(space.style, ref, base, slots, "class", void 0);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { empty } from "../../../../helpers/opResult.js";
|
|
1
|
+
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
2
2
|
import { fontUri, fontsUri } from "../../../../helpers/uris.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
// src/modules/mcp/tools/operations/style/fonts/deleteFont.ts
|
|
@@ -9,7 +9,7 @@ var deleteFontOp = z.object({
|
|
|
9
9
|
var deleteFont = (space, env, op) => {
|
|
10
10
|
const fonts = space.style.fonts ?? [];
|
|
11
11
|
const index = fonts.findIndex((item) => item.family === op.family);
|
|
12
|
-
if (index === -1) return
|
|
12
|
+
if (index === -1) return fail("missing", "family", `The space has no font "${op.family}"`, `Read ${fontsUri(env)} for the fonts it has`);
|
|
13
13
|
fonts.splice(index, 1);
|
|
14
14
|
return {
|
|
15
15
|
...empty(),
|
|
@@ -43,7 +43,7 @@ var upsertFont = (space, env, op) => {
|
|
|
43
43
|
});
|
|
44
44
|
} catch (err) {
|
|
45
45
|
if (!(err instanceof FontValidationError)) throw err;
|
|
46
|
-
return fail("font", err.message, "Fix the field the message names and send the operation again.");
|
|
46
|
+
return fail("bad-value", "font", err.message, "Fix the field the message names and send the operation again.");
|
|
47
47
|
}
|
|
48
48
|
const fonts = space.style.fonts ??= [];
|
|
49
49
|
const index = fonts.findIndex((item) => item.family === font.family);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { globalUri, globalsUri } from "../../../../helpers/uris.js";
|
|
2
|
-
import { empty } from "../../../../helpers/opResult.js";
|
|
2
|
+
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
3
3
|
import { MODES, guardKind } from "../write.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
// src/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.ts
|
|
@@ -10,6 +10,7 @@ var deleteGlobalStyleOp = z.object({
|
|
|
10
10
|
var deleteGlobalStyle = (space, env, op) => {
|
|
11
11
|
const guard = guardKind(space.style, op.componentType, "element");
|
|
12
12
|
if (guard) return guard;
|
|
13
|
+
if (!MODES.some((mode) => Object.hasOwn(space.style.platform[mode], op.componentType))) return fail("missing", "componentType", `No global style for "${op.componentType}"`, `Read ${globalsUri(env)} for what there is`);
|
|
13
14
|
for (const mode of MODES) Reflect.deleteProperty(space.style.platform[mode], op.componentType);
|
|
14
15
|
return {
|
|
15
16
|
...empty(),
|
|
@@ -14,7 +14,7 @@ var patchGlobalStyle = (space, env, op) => {
|
|
|
14
14
|
const guard = guardKind(space.style, op.componentType, "element");
|
|
15
15
|
if (guard) return guard;
|
|
16
16
|
const existing = globalStyleToAI(space.style, op.componentType);
|
|
17
|
-
if (!existing) return fail("componentType", `No global style for "${op.componentType}"`, "patchGlobalStyle only updates an existing global; use upsertGlobalStyle to create one");
|
|
17
|
+
if (!existing) return fail("missing", "componentType", `No global style for "${op.componentType}"`, "patchGlobalStyle only updates an existing global; use upsertGlobalStyle to create one");
|
|
18
18
|
const { type, componentType, slots: slotsPatch, ...basePatch } = op;
|
|
19
19
|
const { base, slots } = mergePatch(existing, basePatch, slotsPatch);
|
|
20
20
|
const problem = writeStyleItem(space.style, componentType, base, slots, "element", componentType);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { idUri, idsUri } from "../../../../helpers/uris.js";
|
|
2
|
-
import { empty } from "../../../../helpers/opResult.js";
|
|
2
|
+
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
3
3
|
import { MODES, guardKind } from "../write.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
// src/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.ts
|
|
@@ -10,6 +10,7 @@ var deleteIdStyleOp = z.object({
|
|
|
10
10
|
var deleteIdStyle = (space, env, op) => {
|
|
11
11
|
const guard = guardKind(space.style, op.targetId, "id");
|
|
12
12
|
if (guard) return guard;
|
|
13
|
+
if (!MODES.some((mode) => Object.hasOwn(space.style.platform[mode], op.targetId))) return fail("missing", "targetId", `No id rule for "${op.targetId}"`, `Read ${idsUri(env)} for what there is`);
|
|
13
14
|
for (const mode of MODES) Reflect.deleteProperty(space.style.platform[mode], op.targetId);
|
|
14
15
|
return {
|
|
15
16
|
...empty(),
|
|
@@ -14,7 +14,7 @@ var patchIdStyle = (space, env, op) => {
|
|
|
14
14
|
const guard = guardKind(space.style, op.targetId, "id");
|
|
15
15
|
if (guard) return guard;
|
|
16
16
|
const existing = idStyleToAI(space.style, op.targetId);
|
|
17
|
-
if (!existing) return fail("targetId", `No id rule for "${op.targetId}"`, "patchIdStyle only updates an existing id rule; use upsertIdStyle to create one");
|
|
17
|
+
if (!existing) return fail("missing", "targetId", `No id rule for "${op.targetId}"`, "patchIdStyle only updates an existing id rule; use upsertIdStyle to create one");
|
|
18
18
|
const { type, targetId, slots: slotsPatch, ...basePatch } = op;
|
|
19
19
|
const { base, slots } = mergePatch(existing, basePatch, slotsPatch);
|
|
20
20
|
const problem = writeStyleItem(space.style, targetId, base, slots, "id", void 0);
|
|
@@ -13,18 +13,18 @@ var rulesOf = (part) => [...MODES.flatMap((mode) => part[mode] ? [expandShorthan
|
|
|
13
13
|
var pseudoProblem = (path, name, part) => {
|
|
14
14
|
if (!isStylePseudo(name)) {
|
|
15
15
|
const bare = name.replace(/^:+/, "");
|
|
16
|
-
return fail(path, `"${name}" is not a pseudo-element a class dresses`, isStylePseudo(bare) ? `Write it without the colons: "${bare}".` : `Use one of ${STYLE_PSEUDOS.join(", ")}.`, [...STYLE_PSEUDOS]);
|
|
16
|
+
return fail("bad-value", path, `"${name}" is not a pseudo-element a class dresses`, isStylePseudo(bare) ? `Write it without the colons: "${bare}".` : `Use one of ${STYLE_PSEUDOS.join(", ")}.`, [...STYLE_PSEUDOS]);
|
|
17
17
|
}
|
|
18
18
|
const rules = rulesOf(part);
|
|
19
19
|
for (const rule of rules) for (const [property, value] of Object.entries(rule)) {
|
|
20
20
|
if (property === "content") {
|
|
21
|
-
if (!CONTENT_PSEUDOS.includes(name)) return fail(path, `content on ::${name} draws nothing`, `Only ${CONTENT_PSEUDOS.map((pseudo) => `::${pseudo}`).join(", ")} take one.`);
|
|
22
|
-
if (!isContentValue(String(value))) return fail(path, `content: ${String(value)} on ::${name} is not text CSS can read, so nothing is drawn`, `Write the text in quotes inside the string — "\\"${String(value)}\\"" — and an empty box as "\\"\\""; counter(), attr() and url() are written as they are.`);
|
|
21
|
+
if (!CONTENT_PSEUDOS.includes(name)) return fail("bad-value", path, `content on ::${name} draws nothing`, `Only ${CONTENT_PSEUDOS.map((pseudo) => `::${pseudo}`).join(", ")} take one.`);
|
|
22
|
+
if (!isContentValue(String(value))) return fail("bad-value", path, `content: ${String(value)} on ::${name} is not text CSS can read, so nothing is drawn`, `Write the text in quotes inside the string — "\\"${String(value)}\\"" — and an empty box as "\\"\\""; counter(), attr() and url() are written as they are.`);
|
|
23
23
|
continue;
|
|
24
24
|
}
|
|
25
|
-
if (!pseudoHonours(name, property)) return fail(path, `${property} on ::${name} is dropped by every browser`, `::${name} honours ${(PSEUDO_PROPERTIES[name] ?? []).join(", ")}; style the element itself for the rest.`);
|
|
25
|
+
if (!pseudoHonours(name, property)) return fail("bad-value", path, `${property} on ::${name} is dropped by every browser`, `::${name} honours ${(PSEUDO_PROPERTIES[name] ?? []).join(", ")}; style the element itself for the rest.`);
|
|
26
26
|
}
|
|
27
|
-
if (GENERATED_PSEUDOS.includes(name) && !rules.some((rule) => Object.hasOwn(rule, "content"))) return fail(path, `::${name} has no content, so nothing is drawn`, "Give it one: content \"\\\"\\\"\" for an empty box.");
|
|
27
|
+
if (GENERATED_PSEUDOS.includes(name) && !rules.some((rule) => Object.hasOwn(rule, "content"))) return fail("bad-value", path, `::${name} has no content, so nothing is drawn`, "Give it one: content \"\\\"\\\"\" for an empty box.");
|
|
28
28
|
return null;
|
|
29
29
|
};
|
|
30
30
|
var pseudosProblem = (path, pseudos) => {
|
|
@@ -42,7 +42,7 @@ var slotProblem = (path, slot) => {
|
|
|
42
42
|
if (problem) return problem;
|
|
43
43
|
}
|
|
44
44
|
for (const [key, condition] of Object.entries(slot.conditions ?? {})) {
|
|
45
|
-
if (!canonicalCondition(key)) return fail(`${path}conditions.${key}`, `"${key}" is not a condition a class's rules can hold under`, CONDITION_HINT);
|
|
45
|
+
if (!canonicalCondition(key)) return fail("bad-value", `${path}conditions.${key}`, `"${key}" is not a condition a class's rules can hold under`, CONDITION_HINT);
|
|
46
46
|
const problem = pseudosProblem(`${path}conditions.${key}.`, condition.pseudos);
|
|
47
47
|
if (problem) return problem;
|
|
48
48
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { empty } from "../../../../helpers/opResult.js";
|
|
1
|
+
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
2
2
|
import { styleCategory } from "../shared.js";
|
|
3
3
|
import { styleVarUri, styleVarsUri } from "../../../../helpers/uris.js";
|
|
4
4
|
import { z } from "zod";
|
|
@@ -10,7 +10,8 @@ var deleteStyleVariableOp = z.object({
|
|
|
10
10
|
}).describe("Delete a design token by category + name.");
|
|
11
11
|
var deleteStyleVariable = (space, env, op) => {
|
|
12
12
|
const group = space.style.variables[op.category];
|
|
13
|
-
if (group
|
|
13
|
+
if (!group || !Object.hasOwn(group, op.name)) return fail("missing", "name", `No ${op.category} token "${op.name}"`, `Read ${styleVarUri(env, op.category)} for the tokens of that category`);
|
|
14
|
+
Reflect.deleteProperty(group, op.name);
|
|
14
15
|
return {
|
|
15
16
|
...empty(),
|
|
16
17
|
deleted: 1,
|
|
@@ -28,7 +28,7 @@ var KIND_FIELD = {
|
|
|
28
28
|
var guardKind = (style, ref, want) => {
|
|
29
29
|
const clash = MODES.map((mode) => style.platform[mode][ref]).find((item) => item !== void 0 && item.type !== want);
|
|
30
30
|
if (!clash) return null;
|
|
31
|
-
return fail(KIND_FIELD[want], `"${ref}" is already ${KIND_LABEL[clash.type]}; it cannot be edited as ${KIND_LABEL[want]}`, `Edit it with ${KIND_TOOL[clash.type]}, or choose a different ${KIND_FIELD[want]}.`);
|
|
31
|
+
return fail("exists", KIND_FIELD[want], `"${ref}" is already ${KIND_LABEL[clash.type]}; it cannot be edited as ${KIND_LABEL[want]}`, `Edit it with ${KIND_TOOL[clash.type]}, or choose a different ${KIND_FIELD[want]}.`);
|
|
32
32
|
};
|
|
33
33
|
/** A part with rules and states — a pseudo-element, a variant, a condition — at one breakpoint, or nothing there. */
|
|
34
34
|
var partAt = (part, mode) => {
|
|
@@ -70,6 +70,18 @@ export declare const renderShape: {
|
|
|
70
70
|
after: "after";
|
|
71
71
|
inside: "inside";
|
|
72
72
|
}>;
|
|
73
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
74
|
+
type: z.ZodLiteral<"addSpec">;
|
|
75
|
+
pageRef: z.ZodString;
|
|
76
|
+
parentRef: z.ZodOptional<z.ZodString>;
|
|
77
|
+
position: z.ZodOptional<z.ZodEnum<{
|
|
78
|
+
before: "before";
|
|
79
|
+
after: "after";
|
|
80
|
+
inside: "inside";
|
|
81
|
+
}>>;
|
|
82
|
+
replaces: z.ZodOptional<z.ZodString>;
|
|
83
|
+
spec: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
84
|
+
classes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
73
85
|
}, z.core.$strict>, z.ZodObject<{
|
|
74
86
|
type: z.ZodLiteral<"upsertPage">;
|
|
75
87
|
ref: z.ZodString;
|
|
@@ -85,6 +97,10 @@ export declare const renderShape: {
|
|
|
85
97
|
noBounce: "noBounce";
|
|
86
98
|
}>>>;
|
|
87
99
|
flag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
100
|
+
style: z.ZodOptional<z.ZodObject<{
|
|
101
|
+
base: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
102
|
+
slots: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
103
|
+
}, z.core.$strip>>;
|
|
88
104
|
}, z.core.$strict>, z.ZodObject<{
|
|
89
105
|
type: z.ZodLiteral<"deletePage">;
|
|
90
106
|
ref: z.ZodString;
|
|
@@ -287,9 +303,16 @@ export declare const renderShape: {
|
|
|
287
303
|
dark: z.ZodOptional<z.ZodString>;
|
|
288
304
|
}, z.core.$strip>]>>;
|
|
289
305
|
robotsTxt: z.ZodOptional<z.ZodString>;
|
|
290
|
-
|
|
306
|
+
securityTxt: z.ZodOptional<z.ZodString>;
|
|
307
|
+
llmsTxt: z.ZodOptional<z.ZodString>;
|
|
308
|
+
blockAiCrawlers: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
309
|
+
training: "training";
|
|
310
|
+
assistants: "assistants";
|
|
311
|
+
search: "search";
|
|
312
|
+
}>>>;
|
|
291
313
|
viewTransitions: z.ZodOptional<z.ZodBoolean>;
|
|
292
314
|
withheldPage: z.ZodOptional<z.ZodString>;
|
|
315
|
+
wholeDocument: z.ZodOptional<z.ZodBoolean>;
|
|
293
316
|
channels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodObject<{
|
|
294
317
|
access: z.ZodObject<{
|
|
295
318
|
mode: z.ZodEnum<{
|
|
@@ -75,6 +75,18 @@ export declare const renderWidgetShape: {
|
|
|
75
75
|
after: "after";
|
|
76
76
|
inside: "inside";
|
|
77
77
|
}>;
|
|
78
|
+
}, import('zod/v4/core').$strict>, import('zod').ZodObject<{
|
|
79
|
+
type: import('zod').ZodLiteral<"addSpec">;
|
|
80
|
+
pageRef: import('zod').ZodString;
|
|
81
|
+
parentRef: import('zod').ZodOptional<import('zod').ZodString>;
|
|
82
|
+
position: import('zod').ZodOptional<import('zod').ZodEnum<{
|
|
83
|
+
before: "before";
|
|
84
|
+
after: "after";
|
|
85
|
+
inside: "inside";
|
|
86
|
+
}>>;
|
|
87
|
+
replaces: import('zod').ZodOptional<import('zod').ZodString>;
|
|
88
|
+
spec: import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodUnknown>;
|
|
89
|
+
classes: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodUnknown>>>;
|
|
78
90
|
}, import('zod/v4/core').$strict>, import('zod').ZodObject<{
|
|
79
91
|
type: import('zod').ZodLiteral<"upsertPage">;
|
|
80
92
|
ref: import('zod').ZodString;
|
|
@@ -90,6 +102,10 @@ export declare const renderWidgetShape: {
|
|
|
90
102
|
noBounce: "noBounce";
|
|
91
103
|
}>>>;
|
|
92
104
|
flag: import('zod').ZodOptional<import('zod').ZodNullable<import('zod').ZodString>>;
|
|
105
|
+
style: import('zod').ZodOptional<import('zod').ZodObject<{
|
|
106
|
+
base: import('zod').ZodOptional<import('zod').ZodArray<import('zod').ZodString>>;
|
|
107
|
+
slots: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodArray<import('zod').ZodString>>>;
|
|
108
|
+
}, import('zod/v4/core').$strip>>;
|
|
93
109
|
}, import('zod/v4/core').$strict>, import('zod').ZodObject<{
|
|
94
110
|
type: import('zod').ZodLiteral<"deletePage">;
|
|
95
111
|
ref: import('zod').ZodString;
|
|
@@ -292,9 +308,16 @@ export declare const renderWidgetShape: {
|
|
|
292
308
|
dark: import('zod').ZodOptional<import('zod').ZodString>;
|
|
293
309
|
}, import('zod/v4/core').$strip>]>>;
|
|
294
310
|
robotsTxt: import('zod').ZodOptional<import('zod').ZodString>;
|
|
295
|
-
|
|
311
|
+
securityTxt: import('zod').ZodOptional<import('zod').ZodString>;
|
|
312
|
+
llmsTxt: import('zod').ZodOptional<import('zod').ZodString>;
|
|
313
|
+
blockAiCrawlers: import('zod').ZodOptional<import('zod').ZodArray<import('zod').ZodEnum<{
|
|
314
|
+
training: "training";
|
|
315
|
+
assistants: "assistants";
|
|
316
|
+
search: "search";
|
|
317
|
+
}>>>;
|
|
296
318
|
viewTransitions: import('zod').ZodOptional<import('zod').ZodBoolean>;
|
|
297
319
|
withheldPage: import('zod').ZodOptional<import('zod').ZodString>;
|
|
320
|
+
wholeDocument: import('zod').ZodOptional<import('zod').ZodBoolean>;
|
|
298
321
|
channels: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodNullable<import('zod').ZodObject<{
|
|
299
322
|
access: import('zod').ZodObject<{
|
|
300
323
|
mode: import('zod').ZodEnum<{
|
|
@@ -11,7 +11,7 @@ var searchShape = {
|
|
|
11
11
|
filters: z.object({
|
|
12
12
|
type: z.string().optional(),
|
|
13
13
|
pageRef: z.string().optional()
|
|
14
|
-
}).optional(),
|
|
14
|
+
}).optional().describe("Only elements of this `type`, or on the page `pageRef`"),
|
|
15
15
|
include: z.literal("detail").optional().describe("Set to \"detail\" to inline each hit's full props/style so an edit needs no follow-up read"),
|
|
16
16
|
limit: z.number().int().min(1).max(100).optional().describe("Max element hits to return (default 50). Response echoes total and, if more remain, nextOffset."),
|
|
17
17
|
offset: z.number().int().min(0).optional().describe("Element hits to skip (default 0). Page by re-calling with offset = nextOffset until it is absent.")
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A page's HTML as an agent reads it: the markup, without what it cannot use — the hydration payload (the space's whole
|
|
3
|
+
* document as JSON, megabytes on a large space), scripts and stylesheets — and cut at a size an answer may hold, said
|
|
4
|
+
* where it is cut. Whole, a look at Plitzi's own pricing page answered 3 MB: 923,000 tokens, more than any context.
|
|
5
|
+
*/
|
|
6
|
+
/** What an answer's HTML may hold, in characters: ~25,000 tokens. */
|
|
7
|
+
export declare const AGENT_HTML_CHARS = 100000;
|
|
8
|
+
export declare const agentHtml: (html: string, limit?: number) => string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/modules/mcp/tools/shared/agentHtml.ts
|
|
2
|
+
/**
|
|
3
|
+
* A page's HTML as an agent reads it: the markup, without what it cannot use — the hydration payload (the space's whole
|
|
4
|
+
* document as JSON, megabytes on a large space), scripts and stylesheets — and cut at a size an answer may hold, said
|
|
5
|
+
* where it is cut. Whole, a look at Plitzi's own pricing page answered 3 MB: 923,000 tokens, more than any context.
|
|
6
|
+
*/
|
|
7
|
+
/** What an answer's HTML may hold, in characters: ~25,000 tokens. */
|
|
8
|
+
var AGENT_HTML_CHARS = 1e5;
|
|
9
|
+
var kilobytes = (chars) => `${String(Math.round(chars / 1e3))} KB`;
|
|
10
|
+
var agentHtml = (html, limit = AGENT_HTML_CHARS) => {
|
|
11
|
+
const markup = html.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, (script) => {
|
|
12
|
+
const open = /^<script\b[^>]*>/i.exec(script)?.[0] ?? "<script>";
|
|
13
|
+
return script.length > open.length + 9 ? `${open}<!-- ${kilobytes(script.length)} left out --><\/script>` : script;
|
|
14
|
+
}).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, (style) => style.length > 200 ? `<style><!-- ${kilobytes(style.length)} of CSS left out --></style>` : style);
|
|
15
|
+
if (markup.length <= limit) return markup;
|
|
16
|
+
return `${markup.slice(0, limit)}\n<!-- cut at ${kilobytes(limit)} of ${kilobytes(markup.length)}: view "accessibility" reads the whole page as an outline, and plitzi_read a page's elements by ref -->`;
|
|
17
|
+
};
|
|
18
|
+
export { AGENT_HTML_CHARS, agentHtml };
|
|
@@ -131,6 +131,7 @@ var lintDraft = (draft, ops, before) => {
|
|
|
131
131
|
const touchedWarnings = [...structure.warnings, ...meaning.warnings].filter(onTouched);
|
|
132
132
|
const preExisting = before && (candidates.length > 0 || touchedWarnings.length > 0) ? preExistingIn(readingOf(before).all, all) : () => false;
|
|
133
133
|
const toError = (issue) => ({
|
|
134
|
+
code: "bad-value",
|
|
134
135
|
path: issue.elementId ? `element "${issue.elementId}"` : "schema",
|
|
135
136
|
message: preExisting(issue) ? `Pre-existing malformation in element "${issue.elementId ?? ""}": ${said(issue)}` : said(issue),
|
|
136
137
|
hint: [preExisting(issue) ? "This issue already exists in the space (NOT caused by your change), but the save is blocked until you fix it too, in this same batch." : "", fixOf(issue)].filter(Boolean).join(" ")
|