@perkyzz/emvb 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -4
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/package.json +5 -2
- package/src/admin/access/role.ts +9 -3
- package/src/admin/agents-api.ts +39 -0
- package/src/admin/api.ts +17 -7
- package/src/admin/content-api.ts +7 -51
- package/src/admin/content-item.ts +22 -0
- package/src/admin/design-api.ts +30 -0
- package/src/admin/editor/A11yCopilot.tsx +1 -1
- package/src/admin/editor/CommandPalette.tsx +43 -2
- package/src/admin/editor/Editor.tsx +133 -332
- package/src/admin/editor/EditorOverlay.tsx +3 -1
- package/src/admin/editor/PerfMeter.tsx +1 -1
- package/src/admin/editor/ShortcutsDialog.tsx +4 -1
- package/src/admin/editor/Timeline.tsx +124 -9
- package/src/admin/editor/canvas/CanvasFrame.tsx +51 -368
- package/src/admin/editor/canvas/DeviceBar.tsx +4 -1
- package/src/admin/editor/canvas/SelectionOverlay.tsx +86 -46
- package/src/admin/editor/canvas/canvas-scale.ts +20 -0
- package/src/admin/editor/canvas/drop-line.ts +24 -0
- package/src/admin/editor/canvas/use-canvas-dnd.ts +207 -0
- package/src/admin/editor/canvas/use-canvas-session.ts +216 -0
- package/src/admin/editor/collection-previews.ts +28 -5
- package/src/admin/editor/editor-chrome.tsx +346 -0
- package/src/admin/editor/editor-commands.ts +360 -0
- package/src/admin/editor/editor-css.ts +4 -0
- package/src/admin/editor/element-chrome.ts +89 -0
- package/src/admin/editor/feature-css.ts +37 -18
- package/src/admin/editor/host.ts +33 -0
- package/src/admin/editor/icons/IconLibraryDialog.tsx +64 -218
- package/src/admin/editor/icons/library.ts +29 -19
- package/src/admin/editor/icons/use-icon-library.ts +315 -0
- package/src/admin/editor/palette-items.ts +36 -5
- package/src/admin/editor/palette.ts +9 -4
- package/src/admin/editor/panels/AddPanel.tsx +2 -67
- package/src/admin/editor/panels/ColorControl.tsx +21 -18
- package/src/admin/editor/panels/ElementPanel.tsx +40 -99
- package/src/admin/editor/panels/LayersPanel.tsx +34 -62
- package/src/admin/editor/panels/SettingsPanel.tsx +1 -0
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +16 -10
- package/src/admin/editor/panels/TokenScales.tsx +4 -2
- package/src/admin/editor/panels/VariableSection.tsx +1 -10
- package/src/admin/editor/panels/color-space.ts +12 -1
- package/src/admin/editor/panels/inline-error.tsx +11 -0
- package/src/admin/editor/panels/settings/AdvancedFields.tsx +143 -1
- package/src/admin/editor/panels/settings/AudienceEditor.tsx +115 -7
- package/src/admin/editor/panels/settings/DraftTextField.tsx +42 -9
- package/src/admin/editor/panels/settings/FieldControl.tsx +6 -0
- package/src/admin/editor/panels/settings/FormBindControl.tsx +8 -4
- package/src/admin/editor/panels/settings/IconPicker.tsx +21 -1
- package/src/admin/editor/panels/settings/ImageSourcesField.tsx +111 -0
- package/src/admin/editor/panels/settings/ItemList.tsx +34 -1
- package/src/admin/editor/panels/settings/MediaPicker.tsx +2 -3
- package/src/admin/editor/panels/settings/QueryStyleRows.tsx +178 -0
- package/src/admin/editor/panels/settings/StyleRow.tsx +14 -2
- package/src/admin/editor/panels/settings/advanced-rules.ts +3 -0
- package/src/admin/editor/panels/settings/form-names.ts +7 -11
- package/src/admin/editor/panels/settings/length-units.ts +15 -4
- package/src/admin/editor/panels/settings/link-rules.ts +19 -0
- package/src/admin/editor/panels/settings/number-input.ts +11 -0
- package/src/admin/editor/panels/settings/query-style.ts +65 -0
- package/src/admin/editor/panels/settings/style-sections.ts +5 -1
- package/src/admin/editor/panels/style-target.ts +105 -0
- package/src/admin/editor/panels/variable-values.ts +4 -2
- package/src/admin/editor/remote-change.ts +67 -0
- package/src/admin/editor/section-templates.ts +43 -21
- package/src/admin/editor/shortcuts.ts +4 -0
- package/src/admin/editor/store.ts +10 -1
- package/src/admin/editor/useClipboardActions.ts +1 -1
- package/src/admin/editor/useEditorCommands.ts +61 -13
- package/src/admin/editor/useEditorData.ts +7 -1
- package/src/admin/editor/useEditorShortcuts.ts +23 -15
- package/src/admin/editor/useNodeActions.ts +6 -1
- package/src/admin/forms-api.ts +17 -6
- package/src/admin/icon-uploads-api.ts +18 -0
- package/src/admin/index.tsx +3 -1
- package/src/admin/media-api.ts +20 -0
- package/src/admin/pages/AgentsPage.tsx +274 -0
- package/src/admin/theme-api.ts +5 -18
- package/src/admin/ui.ts +28 -0
- package/src/astro/content-port.ts +24 -0
- package/src/astro/floats/runtime.ts +10 -0
- package/src/astro/forms/EmVBFormsClient.astro +11 -0
- package/src/astro/forms/EmVBFormsRuntime.astro +6 -7
- package/src/astro/forms/client.ts +1 -0
- package/src/astro/forms-definitions.ts +24 -11
- package/src/astro/index.ts +1 -0
- package/src/astro/popups/runtime.ts +15 -0
- package/src/astro/render-session.ts +85 -0
- package/src/astro/request-data.ts +20 -8
- package/src/astro/resolve-theme.ts +166 -76
- package/src/astro/resolve.ts +57 -16
- package/src/astro/tabs/runtime.ts +60 -1
- package/src/astro/theme-posts.ts +16 -5
- package/src/astro/visitor.ts +67 -5
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +202 -26
- package/src/core/arrange.ts +71 -38
- package/src/core/audience/rules.ts +22 -2
- package/src/core/canvas-styles.ts +24 -0
- package/src/core/clipboard.ts +11 -32
- package/src/core/css/generate.ts +18 -1
- package/src/core/css/print.ts +12 -0
- package/src/core/css/scope.ts +3 -3
- package/src/core/css-keywords.ts +83 -0
- package/src/core/data/bindings.ts +4 -6
- package/src/core/design/classes.ts +13 -15
- package/src/core/design/diff.ts +55 -0
- package/src/core/design/merge.ts +127 -0
- package/src/core/design/variables.ts +25 -21
- package/src/core/elements/dynamic-elements.ts +30 -0
- package/src/core/elements/form-elements.ts +20 -3
- package/src/core/elements/index.ts +211 -7
- package/src/core/forms/binding.ts +4 -13
- package/src/core/index.ts +10 -0
- package/src/core/local-style.ts +27 -0
- package/src/core/migrate/index.ts +9 -4
- package/src/core/nesting.ts +4 -23
- package/src/core/perf/scripts.ts +9 -6
- package/src/core/record.ts +3 -0
- package/src/core/render/context.ts +2 -0
- package/src/core/render/dynamic-post.ts +22 -7
- package/src/core/render/form.ts +145 -15
- package/src/core/render/index.ts +195 -14
- package/src/core/render/pagination.ts +21 -2
- package/src/core/render/vnode.ts +12 -2
- package/src/core/sanitize/css.ts +90 -77
- package/src/core/sanitize/embed-url.ts +7 -1
- package/src/core/sanitize/href.ts +13 -1
- package/src/core/sanitize/svg.ts +8 -3
- package/src/core/sanitize/url.ts +10 -1
- package/src/core/schema/descriptors.ts +4 -1
- package/src/core/schema/design.ts +5 -7
- package/src/core/schema/layout.ts +160 -181
- package/src/core/schema/style.ts +53 -63
- package/src/core/share/link.ts +72 -29
- package/src/core/tabs/presence.ts +7 -17
- package/src/core/theme/dynamic.ts +205 -39
- package/src/core/theme/float.ts +1 -1
- package/src/core/tree-ops.ts +57 -0
- package/src/index.ts +14 -2
- package/src/mcp/errors.ts +44 -0
- package/src/mcp/index.ts +4 -0
- package/src/mcp/ports.ts +78 -0
- package/src/mcp/prompts.ts +76 -0
- package/src/mcp/publish.ts +60 -0
- package/src/mcp/queue.ts +19 -0
- package/src/mcp/rate-limit.ts +80 -0
- package/src/mcp/read.ts +419 -0
- package/src/mcp/refs.ts +84 -0
- package/src/mcp/settings.ts +18 -0
- package/src/mcp/tools.ts +265 -0
- package/src/mcp/write.ts +582 -0
- package/src/server/agent-settings.ts +134 -0
- package/src/server/design-routes.ts +75 -18
- package/src/server/icon-routes.ts +72 -16
- package/src/server/mcp-routes.ts +265 -0
- package/src/server/plugin.ts +40 -4
- package/src/admin/editor/icons/sets/fontawesome.json +0 -1
- package/src/admin/editor/icons/sets/lucide.json +0 -1
- package/src/admin/editor/icons/sets/remix.json +0 -1
- package/src/admin/editor/icons/sets/tabler.json +0 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { McpToolError } from "./errors.ts";
|
|
3
|
+
import type { EmvbPorts } from "./ports.ts";
|
|
4
|
+
import { queued } from "./queue.ts";
|
|
5
|
+
|
|
6
|
+
const off = (what: string) =>
|
|
7
|
+
new McpToolError(
|
|
8
|
+
"PUBLISH_DISABLED",
|
|
9
|
+
`Agents may not publish ${what} on this site. Leave the draft for a person to review, or ask an admin to allow it in Pages VisualBuilder → AI agents.`,
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export const PublishPageInput = z.strictObject({
|
|
13
|
+
pageId: z.string().min(1).max(128),
|
|
14
|
+
/** Required: an agent can't publish a draft it hasn't read (plan § 3). */
|
|
15
|
+
expectedRev: z.string().min(1).max(256),
|
|
16
|
+
confirm: z.literal(true),
|
|
17
|
+
});
|
|
18
|
+
export const PublishPageOutput = z.object({
|
|
19
|
+
pageId: z.string(),
|
|
20
|
+
rev: z.string(),
|
|
21
|
+
summary: z.string(),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/** D-055: publishes one page only when the admin allowed agent publishing. */
|
|
25
|
+
export async function publishPage(ports: EmvbPorts, input: z.infer<typeof PublishPageInput>) {
|
|
26
|
+
if (!(await ports.settings()).publishPages) throw off("pages");
|
|
27
|
+
return queued(`page:${input.pageId}`, async () => {
|
|
28
|
+
const published = await ports.publishPage(input.pageId, input.expectedRev);
|
|
29
|
+
const summary = `Published page ${input.pageId}`;
|
|
30
|
+
await ports.log({
|
|
31
|
+
target: "page",
|
|
32
|
+
tool: "publish_page",
|
|
33
|
+
pageId: input.pageId,
|
|
34
|
+
rev: published.rev,
|
|
35
|
+
summary,
|
|
36
|
+
});
|
|
37
|
+
return { pageId: input.pageId, rev: published.rev, summary };
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const PublishSiteStylesInput = z.strictObject({
|
|
42
|
+
/** The `publishedRevision` from get_site_styles (null when nothing was ever published). */
|
|
43
|
+
expectedPublishedRevision: z.string().max(256).nullable(),
|
|
44
|
+
confirm: z.literal(true),
|
|
45
|
+
});
|
|
46
|
+
export const PublishSiteStylesOutput = z.object({ revision: z.string(), summary: z.string() });
|
|
47
|
+
|
|
48
|
+
/** D-055: publishes the style draft only when the admin allowed it. Pages are not republished. */
|
|
49
|
+
export async function publishSiteStyles(
|
|
50
|
+
ports: EmvbPorts,
|
|
51
|
+
input: z.infer<typeof PublishSiteStylesInput>,
|
|
52
|
+
) {
|
|
53
|
+
if (!(await ports.settings()).publishStyles) throw off("site styles");
|
|
54
|
+
return queued("styles", async () => {
|
|
55
|
+
const published = await ports.publishDesign(input.expectedPublishedRevision);
|
|
56
|
+
const summary = "Published the site styles";
|
|
57
|
+
await ports.log({ target: "styles", tool: "publish_site_styles", summary });
|
|
58
|
+
return { revision: published.revision, summary };
|
|
59
|
+
});
|
|
60
|
+
}
|
package/src/mcp/queue.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One write at a time per key in this isolate (D-058), like the editor's save queue: a write
|
|
3
|
+
* reads the latest `_rev` only after the previous write to the same page has finished.
|
|
4
|
+
*/
|
|
5
|
+
const tails = new Map<string, Promise<unknown>>();
|
|
6
|
+
|
|
7
|
+
export function queued<T>(key: string, work: () => Promise<T>): Promise<T> {
|
|
8
|
+
const previous = tails.get(key) ?? Promise.resolve();
|
|
9
|
+
const next = previous.then(work, work);
|
|
10
|
+
const settled = next.then(
|
|
11
|
+
() => undefined,
|
|
12
|
+
() => undefined,
|
|
13
|
+
);
|
|
14
|
+
tails.set(key, settled);
|
|
15
|
+
void settled.then(() => {
|
|
16
|
+
if (tails.get(key) === settled) tails.delete(key);
|
|
17
|
+
});
|
|
18
|
+
return next;
|
|
19
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { McpToolError } from "./errors.ts";
|
|
2
|
+
|
|
3
|
+
/** What a tool call counts against: reads, draft writes or publishes (W-478). */
|
|
4
|
+
export type RateClass = "read" | "write" | "publish";
|
|
5
|
+
|
|
6
|
+
/** Per token: 300 reads and 60 writes a minute, 10 publishes an hour. */
|
|
7
|
+
export const RATE_LIMITS: Record<RateClass, { limit: number; windowMs: number; per: string }> = {
|
|
8
|
+
read: { limit: 300, windowMs: 60_000, per: "a minute" },
|
|
9
|
+
write: { limit: 60, windowMs: 60_000, per: "a minute" },
|
|
10
|
+
publish: { limit: 10, windowMs: 3_600_000, per: "an hour" },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const rateClassOf = (def: { readOnly: boolean; publish?: string }): RateClass =>
|
|
14
|
+
def.publish ? "publish" : def.readOnly ? "read" : "write";
|
|
15
|
+
|
|
16
|
+
/** The part of EmDash's plugin KV the limiter needs. It lives in the site database, so it holds
|
|
17
|
+
* across Node processes and Cloudflare isolates alike. */
|
|
18
|
+
export interface RateStore {
|
|
19
|
+
getVersioned<T>(key: string): Promise<{ value: T; revision: string } | null>;
|
|
20
|
+
compareAndSet(
|
|
21
|
+
key: string,
|
|
22
|
+
expectedRevision: string | null,
|
|
23
|
+
value: unknown,
|
|
24
|
+
): Promise<{ applied: boolean }>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type Window = { w: number; n: number };
|
|
28
|
+
|
|
29
|
+
const NOUNS: Record<RateClass, string> = { read: "reads", write: "changes", publish: "publishes" };
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Counts one call for `who` in a fixed window and refuses it with RATE_LIMITED once the window is
|
|
33
|
+
* full. Compare-and-set keeps parallel calls from slipping through on a stale count.
|
|
34
|
+
*/
|
|
35
|
+
export async function hitRateLimit(
|
|
36
|
+
store: RateStore,
|
|
37
|
+
who: string,
|
|
38
|
+
cls: RateClass,
|
|
39
|
+
now: () => number = Date.now,
|
|
40
|
+
): Promise<void> {
|
|
41
|
+
const { limit, windowMs, per } = RATE_LIMITS[cls];
|
|
42
|
+
const key = `ratelimit:${cls}:${who}`;
|
|
43
|
+
for (let attempt = 0; attempt < 100; attempt++) {
|
|
44
|
+
const at = now();
|
|
45
|
+
const w = Math.floor(at / windowMs) * windowMs;
|
|
46
|
+
// oxlint-disable-next-line no-await-in-loop -- compare-and-set retries in turn
|
|
47
|
+
const stored = await store.getVersioned<Window>(key);
|
|
48
|
+
const current = stored && stored.value?.w === w ? stored.value.n : 0;
|
|
49
|
+
if (current >= limit) {
|
|
50
|
+
const retryAfterSeconds = Math.max(1, Math.ceil((w + windowMs - at) / 1000));
|
|
51
|
+
throw new McpToolError(
|
|
52
|
+
"RATE_LIMITED",
|
|
53
|
+
`Too many ${NOUNS[cls]}: this token may make ${limit} ${per}. Try again in ${retryAfterSeconds} seconds.`,
|
|
54
|
+
{ retryAfterSeconds, limit, per },
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
// oxlint-disable-next-line no-await-in-loop -- compare-and-set retries in turn
|
|
58
|
+
const write = await store.compareAndSet(key, stored?.revision ?? null, { w, n: current + 1 });
|
|
59
|
+
if (write.applied) return;
|
|
60
|
+
}
|
|
61
|
+
throw new McpToolError(
|
|
62
|
+
"RATE_LIMITED",
|
|
63
|
+
"Too many calls at once from this token. Try again in 1 second.",
|
|
64
|
+
{ retryAfterSeconds: 1 },
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** A short, non-reversible id for the caller's token, so no token is ever stored (W-478). */
|
|
69
|
+
export async function callerKey(request: Request | undefined, userId: string | null) {
|
|
70
|
+
const auth = request?.headers.get("authorization") ?? "";
|
|
71
|
+
const token = /^Bearer\s+(.+)$/i.exec(auth)?.[1]?.trim();
|
|
72
|
+
if (token) {
|
|
73
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(token));
|
|
74
|
+
return `t:${[...new Uint8Array(digest)]
|
|
75
|
+
.slice(0, 12)
|
|
76
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
77
|
+
.join("")}`;
|
|
78
|
+
}
|
|
79
|
+
return userId ? `u:${userId}` : "anonymous";
|
|
80
|
+
}
|
package/src/mcp/read.ts
ADDED
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
auditPage,
|
|
4
|
+
BUNDLED_ICON_IDS,
|
|
5
|
+
byteLength,
|
|
6
|
+
defaultElement,
|
|
7
|
+
ELEMENT_DESCRIPTORS,
|
|
8
|
+
findNode,
|
|
9
|
+
isParentNode,
|
|
10
|
+
LAYOUT_SCHEMA_VERSION,
|
|
11
|
+
SECTION_RECIPES,
|
|
12
|
+
siteTokens,
|
|
13
|
+
validateLayout,
|
|
14
|
+
type DesignSystem,
|
|
15
|
+
type ElementType,
|
|
16
|
+
type Layout,
|
|
17
|
+
type LayoutNode,
|
|
18
|
+
} from "../core/index.ts";
|
|
19
|
+
import { parentChildRefusal } from "../core/arrange.ts";
|
|
20
|
+
import { KNOWN_NODE_SCHEMAS } from "../core/schema/layout.ts";
|
|
21
|
+
import { nodeChildren } from "../core/tree-ops.ts";
|
|
22
|
+
import { McpToolError } from "./errors.ts";
|
|
23
|
+
import type { EmvbPorts, PageRecord } from "./ports.ts";
|
|
24
|
+
|
|
25
|
+
/** A stored layout the tools can work on, or a NOT_FOUND / INVALID_LAYOUT error the agent can read. */
|
|
26
|
+
async function loadPage(
|
|
27
|
+
ports: EmvbPorts,
|
|
28
|
+
pageId: string,
|
|
29
|
+
): Promise<{
|
|
30
|
+
page: PageRecord;
|
|
31
|
+
layout: Layout;
|
|
32
|
+
}> {
|
|
33
|
+
const page = await ports.getPage(pageId);
|
|
34
|
+
if (!page)
|
|
35
|
+
throw new McpToolError("NOT_FOUND", `No EmVB page with id ${pageId}. Call list_pages.`);
|
|
36
|
+
const result = validateLayout(page.layout);
|
|
37
|
+
if (!result.ok) {
|
|
38
|
+
throw new McpToolError(
|
|
39
|
+
"INVALID_LAYOUT",
|
|
40
|
+
"The stored layout of this page can't be read. Open it in the editor to repair it.",
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return { page, layout: result.layout };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type OutlineNode = { id: string; type: string; label?: string; children?: OutlineNode[] };
|
|
47
|
+
|
|
48
|
+
/** The tree without props or styles: cheap orientation for an agent (plan § 3 get_layout). */
|
|
49
|
+
function outlineOf(node: LayoutNode): OutlineNode {
|
|
50
|
+
const kids = nodeChildren(node);
|
|
51
|
+
const text = summaryText(node);
|
|
52
|
+
return {
|
|
53
|
+
id: node.id,
|
|
54
|
+
type: node.type,
|
|
55
|
+
...(node.label || text ? { label: node.label ?? text } : {}),
|
|
56
|
+
...(kids.length > 0 ? { children: kids.map(outlineOf) } : {}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function summaryText(node: LayoutNode): string | undefined {
|
|
61
|
+
const props = (node as { props?: Record<string, unknown> }).props ?? {};
|
|
62
|
+
const text = typeof props["text"] === "string" ? props["text"] : undefined;
|
|
63
|
+
if (!text) return undefined;
|
|
64
|
+
return text.length > 60 ? `${text.slice(0, 57)}…` : text;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function stats(layout: Layout) {
|
|
68
|
+
let nodes = 0;
|
|
69
|
+
let depth = 0;
|
|
70
|
+
const walk = (node: LayoutNode, d: number) => {
|
|
71
|
+
nodes += 1;
|
|
72
|
+
depth = Math.max(depth, d);
|
|
73
|
+
for (const child of nodeChildren(node)) walk(child, d + 1);
|
|
74
|
+
};
|
|
75
|
+
walk(layout.root, 1);
|
|
76
|
+
return { nodes, depth, bytes: byteLength(layout) };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ---------------------------------------------------------------- list_pages
|
|
80
|
+
|
|
81
|
+
export const ListPagesInput = z.strictObject({
|
|
82
|
+
cursor: z.string().max(512).optional(),
|
|
83
|
+
limit: z.number().int().min(1).max(50).optional(),
|
|
84
|
+
});
|
|
85
|
+
export const ListPagesOutput = z.object({
|
|
86
|
+
pages: z.array(
|
|
87
|
+
z.object({
|
|
88
|
+
id: z.string(),
|
|
89
|
+
title: z.string(),
|
|
90
|
+
slug: z.string(),
|
|
91
|
+
status: z.string(),
|
|
92
|
+
hasDraft: z.boolean(),
|
|
93
|
+
updatedAt: z.string(),
|
|
94
|
+
}),
|
|
95
|
+
),
|
|
96
|
+
nextCursor: z.string().optional(),
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
export async function listPages(ports: EmvbPorts, input: z.infer<typeof ListPagesInput>) {
|
|
100
|
+
const result = await ports.listPages({
|
|
101
|
+
limit: input.limit ?? 20,
|
|
102
|
+
...(input.cursor ? { cursor: input.cursor } : {}),
|
|
103
|
+
});
|
|
104
|
+
return { pages: result.pages, ...(result.nextCursor ? { nextCursor: result.nextCursor } : {}) };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ---------------------------------------------------------------- get_layout
|
|
108
|
+
|
|
109
|
+
export const GetLayoutInput = z.strictObject({
|
|
110
|
+
pageId: z.string().min(1).max(128),
|
|
111
|
+
format: z.enum(["full", "outline"]).optional(),
|
|
112
|
+
nodeId: z.string().min(1).max(64).optional(),
|
|
113
|
+
});
|
|
114
|
+
export const GetLayoutOutput = z.object({
|
|
115
|
+
pageId: z.string(),
|
|
116
|
+
rev: z.string(),
|
|
117
|
+
schemaVersion: z.number(),
|
|
118
|
+
title: z.string(),
|
|
119
|
+
slug: z.string(),
|
|
120
|
+
layout: z.unknown().optional(),
|
|
121
|
+
outline: z.unknown().optional(),
|
|
122
|
+
stats: z.object({ nodes: z.number(), depth: z.number(), bytes: z.number() }),
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
export async function getLayout(ports: EmvbPorts, input: z.infer<typeof GetLayoutInput>) {
|
|
126
|
+
const { page, layout } = await loadPage(ports, input.pageId);
|
|
127
|
+
const node = input.nodeId ? findNode(layout, input.nodeId) : layout.root;
|
|
128
|
+
if (!node)
|
|
129
|
+
throw new McpToolError("NOT_FOUND", `No element with id ${input.nodeId} on this page.`);
|
|
130
|
+
const base = {
|
|
131
|
+
pageId: page.id,
|
|
132
|
+
rev: page.rev,
|
|
133
|
+
schemaVersion: LAYOUT_SCHEMA_VERSION,
|
|
134
|
+
title: page.title,
|
|
135
|
+
slug: page.slug,
|
|
136
|
+
stats: stats(layout),
|
|
137
|
+
};
|
|
138
|
+
if (input.format === "outline") return { ...base, outline: outlineOf(node) };
|
|
139
|
+
return { ...base, layout: input.nodeId ? node : layout };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// ---------------------------------------------------------------- list_element_types
|
|
143
|
+
|
|
144
|
+
const SCHEMAS = new Map(
|
|
145
|
+
KNOWN_NODE_SCHEMAS.map((schema) => [
|
|
146
|
+
(schema.shape.type as unknown as { value: string }).value,
|
|
147
|
+
schema.shape.props,
|
|
148
|
+
]),
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
const sample = (type: string): LayoutNode =>
|
|
152
|
+
Object.assign({}, defaultElement(type as ElementType, "sample"), { id: "sample" }) as LayoutNode;
|
|
153
|
+
|
|
154
|
+
/** Which parent types accept `type`, by the same rule drag-and-drop and save use (W-354). */
|
|
155
|
+
function allowedParents(type: string): string[] {
|
|
156
|
+
const child = sample(type);
|
|
157
|
+
return ELEMENT_DESCRIPTORS.map((d) => d.type).filter((parentType) => {
|
|
158
|
+
const parent = sample(parentType);
|
|
159
|
+
if (!isParentNode(parent)) return false;
|
|
160
|
+
return parentChildRefusal(parent, child, parentType === "form") === undefined;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export const ListElementTypesInput = z.strictObject({ type: z.string().max(64).optional() });
|
|
165
|
+
export const ListElementTypesOutput = z.object({
|
|
166
|
+
elements: z.array(
|
|
167
|
+
z.object({
|
|
168
|
+
type: z.string(),
|
|
169
|
+
name: z.string(),
|
|
170
|
+
group: z.string(),
|
|
171
|
+
container: z.boolean(),
|
|
172
|
+
allowedParents: z.array(z.string()),
|
|
173
|
+
props: z.unknown(),
|
|
174
|
+
example: z.unknown(),
|
|
175
|
+
notes: z.string().optional(),
|
|
176
|
+
}),
|
|
177
|
+
),
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* W-474: what an agent can't learn from the props schema alone, found in the live skill run.
|
|
182
|
+
* Icon ids, where form and loop ids come from, and which types belong together.
|
|
183
|
+
*/
|
|
184
|
+
const ELEMENT_NOTES: Record<string, string> = {
|
|
185
|
+
icon: `iconId is one of the bundled icons: ${BUNDLED_ICON_IDS.join(", ")}. Colour it with style.color; size is in px. Set decorative: true next to a text label, or give it a title.`,
|
|
186
|
+
button: `iconId takes the same bundled icon ids as the icon element (${BUNDLED_ICON_IDS.slice(0, 6).join(", ")}, …). Style buttons with a site class (see get_site_styles classes) rather than per-button styles.`,
|
|
187
|
+
form: "formId is the id of a form made in the EmDash admin under Forms; there is no tool to list or create forms, so ask the person for it. An unbound form (empty formId) shows only in the editor, not on the live page. Each field's field prop must match a field name in that form; add a submit last.",
|
|
188
|
+
loop: "A collection Loop needs collection (a collection slug such as posts); ask the person which one if unsure. The children are the item template (post-title, post-image, post-excerpt, post-link, post-date), plus an optional loop-empty shown when there are no entries.",
|
|
189
|
+
tabs: "Holds only tab-panel children; each tab-panel's label is its tab. Put content inside the panels.",
|
|
190
|
+
accordion:
|
|
191
|
+
"Holds only accordion-item children; summary is the visible question, the children are the answer. Set open: true on at most one item.",
|
|
192
|
+
"layout-section":
|
|
193
|
+
"Use one per page band. props.contentWidth caps the inner width (for example 1200 px) while the background spans the screen.",
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export function listElementTypes(input: z.infer<typeof ListElementTypesInput>) {
|
|
197
|
+
const descriptors = input.type
|
|
198
|
+
? ELEMENT_DESCRIPTORS.filter((d) => d.type === input.type)
|
|
199
|
+
: ELEMENT_DESCRIPTORS;
|
|
200
|
+
if (input.type && descriptors.length === 0) {
|
|
201
|
+
throw new McpToolError("NOT_FOUND", `Unknown element type ${input.type}.`);
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
elements: descriptors.map((d) => {
|
|
205
|
+
const props = SCHEMAS.get(d.type);
|
|
206
|
+
const example = sample(d.type);
|
|
207
|
+
const entry: Record<string, unknown> = {
|
|
208
|
+
type: d.type,
|
|
209
|
+
name: d.name,
|
|
210
|
+
group: d.group,
|
|
211
|
+
container: isParentNode(example),
|
|
212
|
+
allowedParents: allowedParents(d.type),
|
|
213
|
+
props: props ? z.toJSONSchema(props, { unrepresentable: "any" }) : {},
|
|
214
|
+
example: { type: example.type, props: (example as { props?: unknown }).props ?? {} },
|
|
215
|
+
};
|
|
216
|
+
if (ELEMENT_NOTES[d.type]) entry["notes"] = ELEMENT_NOTES[d.type];
|
|
217
|
+
return entry;
|
|
218
|
+
}),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// ---------------------------------------------------------------- get_site_styles
|
|
223
|
+
|
|
224
|
+
export const GetSiteStylesInput = z.strictObject({});
|
|
225
|
+
export const GetSiteStylesOutput = z.object({
|
|
226
|
+
revision: z.string().nullable(),
|
|
227
|
+
publishedRevision: z.string().nullable(),
|
|
228
|
+
unpublished: z.boolean(),
|
|
229
|
+
design: z.unknown(),
|
|
230
|
+
tokens: z.unknown(),
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
export async function getSiteStyles(ports: EmvbPorts) {
|
|
234
|
+
const state = await ports.getDesign();
|
|
235
|
+
return { ...state, tokens: siteTokens(state.design) };
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// ---------------------------------------------------------------- list_section_recipes
|
|
239
|
+
|
|
240
|
+
export const ListRecipesInput = z.strictObject({});
|
|
241
|
+
export const ListRecipesOutput = z.object({
|
|
242
|
+
recipes: z.array(z.object({ id: z.string(), name: z.string(), description: z.string() })),
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
export const listSectionRecipes = () => ({
|
|
246
|
+
recipes: SECTION_RECIPES.map((r) => ({ id: r.id, name: r.name, description: r.description })),
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
// ---------------------------------------------------------------- describe_page
|
|
250
|
+
|
|
251
|
+
const TEXT_TYPES = new Set(["heading", "text", "label", "link", "button", "list"]);
|
|
252
|
+
|
|
253
|
+
function textOf(node: LayoutNode): string {
|
|
254
|
+
const props = (node as { props?: Record<string, unknown> }).props ?? {};
|
|
255
|
+
if (Array.isArray(props["items"])) return props["items"].join(" · ");
|
|
256
|
+
return typeof props["text"] === "string" ? props["text"] : "";
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function collect(node: LayoutNode, out: { text: string[]; headings: string[]; media: number }) {
|
|
260
|
+
if (node.type === "heading") {
|
|
261
|
+
const level = (node as { props: { level: number } }).props.level;
|
|
262
|
+
out.headings.push(`H${level} ${textOf(node)}`);
|
|
263
|
+
}
|
|
264
|
+
if (TEXT_TYPES.has(node.type)) out.text.push(textOf(node));
|
|
265
|
+
if (node.type === "image" || node.type === "video") out.media += 1;
|
|
266
|
+
for (const child of nodeChildren(node)) collect(child, out);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export const DescribePageInput = z.strictObject({ pageId: z.string().min(1).max(128) });
|
|
270
|
+
export const DescribePageOutput = z.object({
|
|
271
|
+
pageId: z.string(),
|
|
272
|
+
title: z.string(),
|
|
273
|
+
summary: z.string(),
|
|
274
|
+
sections: z.array(
|
|
275
|
+
z.object({
|
|
276
|
+
id: z.string(),
|
|
277
|
+
type: z.string(),
|
|
278
|
+
label: z.string().optional(),
|
|
279
|
+
headings: z.array(z.string()),
|
|
280
|
+
excerpt: z.string(),
|
|
281
|
+
media: z.number(),
|
|
282
|
+
}),
|
|
283
|
+
),
|
|
284
|
+
headingOutline: z.array(z.string()),
|
|
285
|
+
wordCount: z.number(),
|
|
286
|
+
images: z
|
|
287
|
+
.array(z.object({ id: z.string(), alt: z.string(), src: z.string(), decorative: z.boolean() }))
|
|
288
|
+
.optional(),
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
/** W-474: a review needs the alt texts next to what the images are, which only get_layout had. */
|
|
292
|
+
function imagesOf(root: LayoutNode) {
|
|
293
|
+
const found: { id: string; alt: string; src: string; decorative: boolean }[] = [];
|
|
294
|
+
const walk = (node: LayoutNode) => {
|
|
295
|
+
if (node.type === "image" && found.length < 50) {
|
|
296
|
+
const props = node.props as { alt?: unknown; src?: unknown; decorative?: unknown };
|
|
297
|
+
found.push({
|
|
298
|
+
id: node.id,
|
|
299
|
+
alt: typeof props.alt === "string" ? clip(props.alt, 300) : "",
|
|
300
|
+
src: typeof props.src === "string" ? clip(props.src, 300) : "",
|
|
301
|
+
decorative: props.decorative === true,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
for (const child of nodeChildren(node)) walk(child);
|
|
305
|
+
};
|
|
306
|
+
walk(root);
|
|
307
|
+
return found;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const clip = (text: string, max: number) =>
|
|
311
|
+
text.length > max ? `${text.slice(0, max - 1)}…` : text;
|
|
312
|
+
|
|
313
|
+
export async function describePage(ports: EmvbPorts, input: z.infer<typeof DescribePageInput>) {
|
|
314
|
+
const { page, layout } = await loadPage(ports, input.pageId);
|
|
315
|
+
const top = nodeChildren(layout.root);
|
|
316
|
+
const all = { text: [] as string[], headings: [] as string[], media: 0 };
|
|
317
|
+
collect(layout.root, all);
|
|
318
|
+
const sections = top.map((node) => {
|
|
319
|
+
const part = { text: [] as string[], headings: [] as string[], media: 0 };
|
|
320
|
+
collect(node, part);
|
|
321
|
+
const section: {
|
|
322
|
+
id: string;
|
|
323
|
+
type: string;
|
|
324
|
+
label?: string;
|
|
325
|
+
headings: string[];
|
|
326
|
+
excerpt: string;
|
|
327
|
+
media: number;
|
|
328
|
+
} = {
|
|
329
|
+
id: node.id,
|
|
330
|
+
type: node.type,
|
|
331
|
+
headings: part.headings,
|
|
332
|
+
excerpt: clip(part.text.join(" "), 240),
|
|
333
|
+
media: part.media,
|
|
334
|
+
};
|
|
335
|
+
if (node.label) section.label = node.label;
|
|
336
|
+
return section;
|
|
337
|
+
});
|
|
338
|
+
const wordCount = all.text.join(" ").split(/\s+/).filter(Boolean).length;
|
|
339
|
+
const summary = clip(
|
|
340
|
+
`"${page.title}" (/${page.slug}, ${page.status}${page.hasDraft ? ", unpublished changes" : ""}): ` +
|
|
341
|
+
`${sections.length} top-level section${sections.length === 1 ? "" : "s"}, ` +
|
|
342
|
+
`${all.headings.length} heading${all.headings.length === 1 ? "" : "s"}, ${all.media} image or video, ` +
|
|
343
|
+
`${wordCount} words.`,
|
|
344
|
+
1200,
|
|
345
|
+
);
|
|
346
|
+
return {
|
|
347
|
+
pageId: page.id,
|
|
348
|
+
title: page.title,
|
|
349
|
+
summary,
|
|
350
|
+
sections,
|
|
351
|
+
headingOutline: all.headings,
|
|
352
|
+
wordCount,
|
|
353
|
+
images: imagesOf(layout.root),
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// ---------------------------------------------------------------- get_accessibility_findings
|
|
358
|
+
|
|
359
|
+
export const A11yInput = z.strictObject({ pageId: z.string().min(1).max(128) });
|
|
360
|
+
export const A11yOutput = z.object({
|
|
361
|
+
pageId: z.string(),
|
|
362
|
+
score: z.number(),
|
|
363
|
+
findings: z.array(
|
|
364
|
+
z.object({
|
|
365
|
+
rule: z.string(),
|
|
366
|
+
severity: z.enum(["error", "warning"]),
|
|
367
|
+
nodeId: z.string(),
|
|
368
|
+
message: z.string(),
|
|
369
|
+
fix: z.unknown().optional(),
|
|
370
|
+
}),
|
|
371
|
+
),
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
export async function accessibilityFindings(ports: EmvbPorts, input: z.infer<typeof A11yInput>) {
|
|
375
|
+
const { page, layout } = await loadPage(ports, input.pageId);
|
|
376
|
+
const { design } = await ports.getDesign();
|
|
377
|
+
const report = auditPage(layout, design as DesignSystem);
|
|
378
|
+
return {
|
|
379
|
+
pageId: page.id,
|
|
380
|
+
score: report.score,
|
|
381
|
+
findings: report.issues.map((issue) => {
|
|
382
|
+
const finding: {
|
|
383
|
+
rule: string;
|
|
384
|
+
severity: "error" | "warning";
|
|
385
|
+
nodeId: string;
|
|
386
|
+
message: string;
|
|
387
|
+
fix?: unknown;
|
|
388
|
+
} = {
|
|
389
|
+
rule: issue.rule,
|
|
390
|
+
severity: issue.severity,
|
|
391
|
+
nodeId: issue.nodeId,
|
|
392
|
+
message: issue.message,
|
|
393
|
+
};
|
|
394
|
+
if (issue.fix) finding.fix = issue.fix;
|
|
395
|
+
return finding;
|
|
396
|
+
}),
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// ---------------------------------------------------------------- list_versions
|
|
401
|
+
|
|
402
|
+
export const ListVersionsInput = z.strictObject({
|
|
403
|
+
pageId: z.string().min(1).max(128),
|
|
404
|
+
limit: z.number().int().min(1).max(50).optional(),
|
|
405
|
+
});
|
|
406
|
+
export const ListVersionsOutput = z.object({
|
|
407
|
+
versions: z.array(
|
|
408
|
+
z.object({ revisionId: z.string(), at: z.string(), authorId: z.string().nullable() }),
|
|
409
|
+
),
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
export async function listVersions(ports: EmvbPorts, input: z.infer<typeof ListVersionsInput>) {
|
|
413
|
+
const page = await ports.getPage(input.pageId);
|
|
414
|
+
if (!page) throw new McpToolError("NOT_FOUND", `No EmVB page with id ${input.pageId}.`);
|
|
415
|
+
const revisions = await ports.listRevisions(input.pageId, input.limit ?? 20);
|
|
416
|
+
return {
|
|
417
|
+
versions: revisions.map((r) => ({ revisionId: r.id, at: r.createdAt, authorId: r.authorId })),
|
|
418
|
+
};
|
|
419
|
+
}
|
package/src/mcp/refs.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { DesignSystem } from "../core/index.ts";
|
|
2
|
+
import { McpToolError } from "./errors.ts";
|
|
3
|
+
|
|
4
|
+
type From = "color" | "font" | "fontSize" | "spacing";
|
|
5
|
+
|
|
6
|
+
const KINDS: [keyof DesignSystem["variables"], From][] = [
|
|
7
|
+
["colors", "color"],
|
|
8
|
+
["fonts", "font"],
|
|
9
|
+
["fontSizes", "fontSize"],
|
|
10
|
+
["spacings", "spacing"],
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
const isRecord = (v: unknown): v is Record<string, unknown> =>
|
|
14
|
+
typeof v === "object" && v !== null && !Array.isArray(v);
|
|
15
|
+
|
|
16
|
+
const isRef = (v: Record<string, unknown>) =>
|
|
17
|
+
typeof v["var"] === "string" && Object.keys(v).every((k) => k === "var" || k === "from");
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Live MCP test (W-474): agents wrote `{ "var": "display" }` for a font and the style was
|
|
21
|
+
* silently dropped, because only colours may leave out `from`. This fills in `from` from the
|
|
22
|
+
* variable's kind and refuses ids that don't exist, so a typo can't fall back without a word.
|
|
23
|
+
* Class names in `classes` are checked the same way.
|
|
24
|
+
*/
|
|
25
|
+
export function resolveDesignRefs<T>(value: T, design: DesignSystem): T {
|
|
26
|
+
const kinds = new Map<string, From[]>();
|
|
27
|
+
for (const [key, from] of KINDS) {
|
|
28
|
+
for (const v of design.variables[key] ?? [])
|
|
29
|
+
kinds.set(v.id, [...(kinds.get(v.id) ?? []), from]);
|
|
30
|
+
}
|
|
31
|
+
const classIds = new Set((design.classes ?? []).map((c) => c.id));
|
|
32
|
+
const unknown = new Set<string>();
|
|
33
|
+
const unknownClasses = new Set<string>();
|
|
34
|
+
const ambiguous = new Set<string>();
|
|
35
|
+
const walk = (v: unknown, key?: string): unknown => {
|
|
36
|
+
if (Array.isArray(v)) {
|
|
37
|
+
if (key === "classes") {
|
|
38
|
+
for (const c of v) if (typeof c === "string" && !classIds.has(c)) unknownClasses.add(c);
|
|
39
|
+
return v;
|
|
40
|
+
}
|
|
41
|
+
return v.map((x) => walk(x));
|
|
42
|
+
}
|
|
43
|
+
if (!isRecord(v)) return v;
|
|
44
|
+
if (isRef(v)) {
|
|
45
|
+
const id = v["var"] as string;
|
|
46
|
+
const found = kinds.get(id);
|
|
47
|
+
if (!found) {
|
|
48
|
+
unknown.add(id);
|
|
49
|
+
return v;
|
|
50
|
+
}
|
|
51
|
+
const given = v["from"] as From | undefined;
|
|
52
|
+
const from =
|
|
53
|
+
given && found.includes(given) ? given : found.length === 1 ? found[0] : undefined;
|
|
54
|
+
if (!from) {
|
|
55
|
+
ambiguous.add(id);
|
|
56
|
+
return v;
|
|
57
|
+
}
|
|
58
|
+
return from === "color" ? { var: id } : { var: id, from };
|
|
59
|
+
}
|
|
60
|
+
return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, walk(x, k)]));
|
|
61
|
+
};
|
|
62
|
+
const out = walk(value) as T;
|
|
63
|
+
const problems: string[] = [];
|
|
64
|
+
if (unknown.size > 0) {
|
|
65
|
+
const list = KINDS.map(
|
|
66
|
+
([key]) => `${key}: ${(design.variables[key] ?? []).map((x) => x.id).join(", ") || "none"}`,
|
|
67
|
+
).join("; ");
|
|
68
|
+
problems.push(
|
|
69
|
+
`Unknown variable ${[...unknown].map((id) => `"${id}"`).join(", ")}. Variables are ${list}.`,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
if (ambiguous.size > 0) {
|
|
73
|
+
problems.push(
|
|
74
|
+
`${[...ambiguous].map((id) => `"${id}"`).join(", ")} names more than one kind of variable; add "from" ("color", "font", "fontSize" or "spacing").`,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
if (unknownClasses.size > 0) {
|
|
78
|
+
problems.push(
|
|
79
|
+
`Unknown class ${[...unknownClasses].map((id) => `"${id}"`).join(", ")}. Classes are ${[...classIds].join(", ") || "none"}; add one with update_site_styles first.`,
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
if (problems.length > 0) throw new McpToolError("INVALID_INPUT", problems.join(" "));
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
/** Site-owner settings for AI agents (plan § 4, D-055). Only admins change them; no tool does. */
|
|
4
|
+
export const AgentSettings = z.object({
|
|
5
|
+
/** Master switch "Let AI agents edit EmVB pages" (off by default). */
|
|
6
|
+
mcpEnabled: z.boolean(),
|
|
7
|
+
/** Agents may publish pages (`publish_page`). */
|
|
8
|
+
publishPages: z.boolean(),
|
|
9
|
+
/** Agents may publish the site styles (`publish_site_styles`). */
|
|
10
|
+
publishStyles: z.boolean(),
|
|
11
|
+
});
|
|
12
|
+
export type AgentSettings = z.infer<typeof AgentSettings>;
|
|
13
|
+
|
|
14
|
+
export const DEFAULT_AGENT_SETTINGS: AgentSettings = {
|
|
15
|
+
mcpEnabled: false,
|
|
16
|
+
publishPages: false,
|
|
17
|
+
publishStyles: false,
|
|
18
|
+
};
|