@plitzi/sdk-mcp 0.39.3 → 0.39.6
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 +42 -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/catalogs/pluginCatalog.d.ts +8 -0
- package/dist/modules/mcp/catalogs/pluginCatalog.js +35 -1
- package/dist/modules/mcp/helpers/guide/reference.d.ts +1 -1
- package/dist/modules/mcp/helpers/guide/reference.js +16 -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 +10 -3
- 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/index.js +5 -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/releases.d.ts +3 -0
- package/dist/modules/mcp/tools/releases.js +60 -0
- 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 +21 -1
- 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/dist/server.d.ts +1 -1
- package/dist/server.js +2 -2
- package/package.json +10 -10
|
@@ -2,14 +2,33 @@ import { computeVersion } from "../modules/mcp/helpers/computeVersion.js";
|
|
|
2
2
|
import { findPageByRef, getPageElements } from "../modules/mcp/helpers/space.js";
|
|
3
3
|
import { draftBatch } from "../modules/mcp/tools/shared/draftBatch.js";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
|
+
import { closest } from "@plitzi/sdk-authoring";
|
|
5
6
|
import { buildBody } from "@plitzi/sdk-server/ssr";
|
|
7
|
+
import { getPageFullPath, getSlugParams } from "@plitzi/sdk-shared/navigation";
|
|
6
8
|
// src/preview/createPreview.ts
|
|
7
|
-
|
|
9
|
+
/** A route parameter, as a slug spells it: `:spaceId` or `{{spaceId}}`. */
|
|
10
|
+
var ROUTE_PARAM = /:([A-Za-z0-9_-]+)|{{\s*([A-Za-z0-9_-]+)\s*}}/g;
|
|
11
|
+
/**
|
|
12
|
+
* The address of the page asked for — its folders' slugs before its own, as a link to it resolves, its parameters
|
|
13
|
+
* filled — or why there is none. A page the space does not have is refused, never drawn as its home, and a page whose
|
|
14
|
+
* path takes a parameter not given is refused naming it, never opened at its pattern (the space's 404).
|
|
15
|
+
*/
|
|
16
|
+
var resolvePage = (schema, pageRef, routeParams = {}) => {
|
|
8
17
|
const pages = getPageElements(schema);
|
|
9
18
|
const page = pageRef ? findPageByRef(schema, pageRef) : pages.find((p) => p.attributes.default) ?? pages[0];
|
|
10
|
-
|
|
11
|
-
|
|
19
|
+
if (!page) {
|
|
20
|
+
const nearest = pageRef ? closest(pageRef, pages.map((p) => p.id)) : void 0;
|
|
21
|
+
return { refused: pageRef ? `The space has no page "${pageRef}"${nearest ? ` — did you mean "${nearest}"?` : ""}` : "The space has no page to draw" };
|
|
22
|
+
}
|
|
23
|
+
const pattern = getPageFullPath(schema.flat, schema.pageFolders, page.id, true);
|
|
24
|
+
const missing = getSlugParams(pattern).filter((name) => !routeParams[name]);
|
|
25
|
+
if (missing.length > 0) return { refused: `"${page.id}" is at ${pattern}: give routeParams its ${missing.join(", ")} — { ${missing.map((name) => `"${name}": "…"`).join(", ")} }` };
|
|
26
|
+
return {
|
|
27
|
+
path: pattern.replace(ROUTE_PARAM, (_, colon, braces) => encodeURIComponent(routeParams[colon ?? braces ?? ""] ?? "")),
|
|
28
|
+
signedInOnly: page.attributes.accessLevel === "authenticated"
|
|
29
|
+
};
|
|
12
30
|
};
|
|
31
|
+
var isStringRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.values(value).every((entry) => typeof entry === "string");
|
|
13
32
|
var syntheticRequest = (pagePath) => ({
|
|
14
33
|
method: "GET",
|
|
15
34
|
path: pagePath,
|
|
@@ -35,7 +54,7 @@ var createPreview = async (body, config, renderFn, pluginManager, caches) => {
|
|
|
35
54
|
const offlineData = await config.adapters.getOfflineData(body.spaceId, env, revision);
|
|
36
55
|
if (!offlineData) return {
|
|
37
56
|
ok: false,
|
|
38
|
-
error: "
|
|
57
|
+
error: "missing",
|
|
39
58
|
message: `No offline data for space ${body.spaceId} (${env}${revision ? ` revision ${revision}` : ""}).`
|
|
40
59
|
};
|
|
41
60
|
let draftOffline = offlineData;
|
|
@@ -48,7 +67,7 @@ var createPreview = async (body, config, renderFn, pluginManager, caches) => {
|
|
|
48
67
|
}, env, body.operations);
|
|
49
68
|
if (!batch.ok) return {
|
|
50
69
|
ok: false,
|
|
51
|
-
error: "
|
|
70
|
+
error: "bad-value",
|
|
52
71
|
message: "The operations were refused, as plitzi_apply would refuse them.",
|
|
53
72
|
errors: batch.errors
|
|
54
73
|
};
|
|
@@ -58,7 +77,18 @@ var createPreview = async (body, config, renderFn, pluginManager, caches) => {
|
|
|
58
77
|
style: batch.draft.style
|
|
59
78
|
};
|
|
60
79
|
}
|
|
61
|
-
|
|
80
|
+
if (body.routeParams !== void 0 && !isStringRecord(body.routeParams)) return {
|
|
81
|
+
ok: false,
|
|
82
|
+
error: "bad-value",
|
|
83
|
+
message: "routeParams is an object of strings: { \"spaceId\": \"42\" }"
|
|
84
|
+
};
|
|
85
|
+
const resolved = resolvePage(draftOffline.schema, body.pageRef, body.routeParams);
|
|
86
|
+
if ("refused" in resolved) return {
|
|
87
|
+
ok: false,
|
|
88
|
+
error: "missing",
|
|
89
|
+
message: resolved.refused
|
|
90
|
+
};
|
|
91
|
+
const pagePath = resolved.path;
|
|
62
92
|
let html;
|
|
63
93
|
if (body.includeHtml !== false) ({body: html} = await buildBody(syntheticRequest(pagePath), config, body.spaceId, env, revision, renderFn, pluginManager, caches.offlineData, void 0, draftOffline));
|
|
64
94
|
const reusable = body.mode === "session" || body.mode === "tests";
|
|
@@ -80,7 +110,8 @@ var createPreview = async (body, config, renderFn, pluginManager, caches) => {
|
|
|
80
110
|
pagePath,
|
|
81
111
|
html: html ?? "",
|
|
82
112
|
stateVersion: computeVersion(draftOffline),
|
|
83
|
-
...token ? { expiresInMs: ttlMs } : {}
|
|
113
|
+
...token ? { expiresInMs: ttlMs } : {},
|
|
114
|
+
...resolved.signedInOnly ? { signedInOnly: true } : {}
|
|
84
115
|
};
|
|
85
116
|
};
|
|
86
117
|
export { createPreview };
|
package/dist/server.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { createServer } from './createServer';
|
|
|
8
8
|
export { buildMCPPipeline } from './pipeline';
|
|
9
9
|
export { createMcpServer, handleMcp, serveMcp, readMcpBody } from './modules/mcp/handler';
|
|
10
10
|
export { createHttpPreviewClient } from './modules/mcp/previewClient';
|
|
11
|
-
export { pluginCatalog, stringDeclarations } from './modules/mcp/catalogs/pluginCatalog';
|
|
11
|
+
export { pluginCatalog, pluginStylesheets, stringDeclarations } from './modules/mcp/catalogs/pluginCatalog';
|
|
12
12
|
export { createHttpScreenshotClient } from './modules/mcp/screenshotClient';
|
|
13
13
|
export { createLocalScreenshotClient, resolveLocalBrowser } from './modules/mcp/localScreenshotClient';
|
|
14
14
|
export type { LocalScreenshotClientConfig } from './modules/mcp/localScreenshotClient';
|
package/dist/server.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createServer } from "./createServer.js";
|
|
|
3
3
|
import { buildMCPPipeline } from "./pipeline.js";
|
|
4
4
|
import { handleMcp, readMcpBody, serveMcp } from "./modules/mcp/handler.js";
|
|
5
5
|
import { createHttpPreviewClient } from "./modules/mcp/previewClient.js";
|
|
6
|
-
import { pluginCatalog, stringDeclarations } from "./modules/mcp/catalogs/pluginCatalog.js";
|
|
6
|
+
import { pluginCatalog, pluginStylesheets, stringDeclarations } from "./modules/mcp/catalogs/pluginCatalog.js";
|
|
7
7
|
import { createHttpScreenshotClient } from "./modules/mcp/screenshotClient.js";
|
|
8
8
|
import { createLocalScreenshotClient, resolveLocalBrowser } from "./modules/mcp/localScreenshotClient.js";
|
|
9
|
-
export { buildMCPPipeline, createHttpPreviewClient, createHttpScreenshotClient, createLocalScreenshotClient, createMcpServer, createServer, handleMcp, pluginCatalog, readMcpBody, resolveLocalBrowser, serveMcp, stringDeclarations };
|
|
9
|
+
export { buildMCPPipeline, createHttpPreviewClient, createHttpScreenshotClient, createLocalScreenshotClient, createMcpServer, createServer, handleMcp, pluginCatalog, pluginStylesheets, readMcpBody, resolveLocalBrowser, serveMcp, stringDeclarations };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-mcp",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.6",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@modelcontextprotocol/ext-apps": "^1.7.5",
|
|
49
49
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
50
|
-
"@plitzi/plitzi-sdk": "0.39.
|
|
51
|
-
"@plitzi/sdk-authoring": "0.39.
|
|
52
|
-
"@plitzi/sdk-kernel": "0.39.
|
|
53
|
-
"@plitzi/sdk-schema": "0.39.
|
|
54
|
-
"@plitzi/sdk-server": "0.39.
|
|
55
|
-
"@plitzi/sdk-shared": "0.39.
|
|
56
|
-
"@plitzi/sdk-style": "0.39.
|
|
50
|
+
"@plitzi/plitzi-sdk": "0.39.6",
|
|
51
|
+
"@plitzi/sdk-authoring": "0.39.6",
|
|
52
|
+
"@plitzi/sdk-kernel": "0.39.6",
|
|
53
|
+
"@plitzi/sdk-schema": "0.39.6",
|
|
54
|
+
"@plitzi/sdk-server": "0.39.6",
|
|
55
|
+
"@plitzi/sdk-shared": "0.39.6",
|
|
56
|
+
"@plitzi/sdk-style": "0.39.6",
|
|
57
57
|
"ejs": "^7.0.2",
|
|
58
58
|
"esbuild": "^0.28.2",
|
|
59
59
|
"zod": "^4.6.7"
|
|
@@ -71,12 +71,12 @@
|
|
|
71
71
|
"@vitest/coverage-v8": "^5.1.0",
|
|
72
72
|
"eslint": "^9.39.5",
|
|
73
73
|
"eslint-plugin-import": "^2.32.0",
|
|
74
|
-
"jsdom": "^31.0.
|
|
74
|
+
"jsdom": "^31.0.1",
|
|
75
75
|
"react": "^19.3.1",
|
|
76
76
|
"react-dom": "^19.3.1",
|
|
77
77
|
"tsx": "^4.23.15",
|
|
78
78
|
"typescript": "^6.0.3",
|
|
79
|
-
"vite": "^8.3.
|
|
79
|
+
"vite": "^8.3.8",
|
|
80
80
|
"vite-plugin-dts": "^5.1.2",
|
|
81
81
|
"vitest": "^5.1.0"
|
|
82
82
|
},
|