@plitzi/sdk-mcp 0.38.12 → 0.38.14
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 +166 -0
- package/README.md +19 -0
- package/dist/modules/mcp/helpers/guide.js +4 -0
- package/dist/modules/mcp/resources/renderGuide.d.ts +2 -0
- package/dist/modules/mcp/resources/renderGuide.js +2 -1
- package/dist/modules/mcp/server.js +1 -1
- package/dist/modules/mcp/tools/apply/index.d.ts +4 -0
- package/dist/modules/mcp/tools/operations/index.d.ts +16 -0
- package/dist/modules/mcp/tools/operations/schema/operations.d.ts +4 -0
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +4 -0
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +6 -2
- package/dist/modules/mcp/tools/operations/schema/translator.js +2 -1
- package/dist/modules/mcp/tools/render.d.ts +8 -35
- package/dist/modules/mcp/tools/render.js +4 -56
- package/dist/modules/mcp/tools/renderWidget.d.ts +1467 -0
- package/dist/modules/mcp/tools/renderWidget.js +67 -0
- package/dist/modules/mcp/tools/shared/lintDraft.js +1 -0
- package/dist/modules/mcp/types/aiSchema.d.ts +3 -1
- package/dist/render.d.ts +10 -0
- package/dist/render.js +3 -0
- package/package.json +12 -7
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { emptySpace } from "../helpers/space.js";
|
|
2
|
+
import { proxifyResources } from "../proxy/rewrite.js";
|
|
3
|
+
import { documentOperations } from "./operations/index.js";
|
|
4
|
+
import { draftBatch } from "./shared/draftBatch.js";
|
|
5
|
+
import { interactionReport } from "./shared/interactionReport.js";
|
|
6
|
+
import { generateCache } from "@plitzi/sdk-style/StyleHelper";
|
|
7
|
+
//#region src/modules/mcp/tools/renderWidget.ts
|
|
8
|
+
/**
|
|
9
|
+
* A widget built from an agent's operations, with no space and no backend: the engine behind `plitzi_render`, apart
|
|
10
|
+
* from the MCP tool — so a project's own agent can draw the same widgets in its own pages (`@plitzi/sdk-mcp/render`).
|
|
11
|
+
*/
|
|
12
|
+
var HOST_PAGE_REF = "render";
|
|
13
|
+
var seedSpace = (base) => {
|
|
14
|
+
const space = emptySpace();
|
|
15
|
+
if (base) space.style = {
|
|
16
|
+
...structuredClone(base),
|
|
17
|
+
cache: ""
|
|
18
|
+
};
|
|
19
|
+
space.schema.definition.name = "Widget";
|
|
20
|
+
space.schema.flat[HOST_PAGE_REF] = {
|
|
21
|
+
id: HOST_PAGE_REF,
|
|
22
|
+
attributes: {
|
|
23
|
+
slug: "",
|
|
24
|
+
name: "Render",
|
|
25
|
+
default: true
|
|
26
|
+
},
|
|
27
|
+
definition: {
|
|
28
|
+
rootId: HOST_PAGE_REF,
|
|
29
|
+
label: "Page",
|
|
30
|
+
type: "page",
|
|
31
|
+
items: [],
|
|
32
|
+
styleSelectors: { base: "" }
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
space.schema.pages = [HOST_PAGE_REF];
|
|
36
|
+
return space;
|
|
37
|
+
};
|
|
38
|
+
var noWarnings = (warnings) => warnings.length > 0 ? warnings : void 0;
|
|
39
|
+
/** The input as a tool declares it, for a project registering the render as a tool of its own MCP server. */
|
|
40
|
+
var renderWidgetShape = { operations: documentOperations };
|
|
41
|
+
var render = (input, options = {}) => {
|
|
42
|
+
const result = draftBatch(seedSpace(options.base), "main", input.operations, "widget");
|
|
43
|
+
if (!result.ok) return {
|
|
44
|
+
rendered: false,
|
|
45
|
+
errors: result.errors,
|
|
46
|
+
warnings: noWarnings(result.warnings)
|
|
47
|
+
};
|
|
48
|
+
const { ops, draft: space } = result;
|
|
49
|
+
const behaviour = interactionReport(space);
|
|
50
|
+
const warnings = [...result.warnings, ...behaviour.warnings];
|
|
51
|
+
if (options.proxy) warnings.push(...proxifyResources(space, options.proxy));
|
|
52
|
+
space.style.cache = generateCache(space.style);
|
|
53
|
+
return {
|
|
54
|
+
rendered: true,
|
|
55
|
+
operations: ops,
|
|
56
|
+
...behaviour.flows ? { interactions: behaviour.flows } : {},
|
|
57
|
+
rootRef: HOST_PAGE_REF,
|
|
58
|
+
elementCount: Object.keys(space.schema.flat).length - 1,
|
|
59
|
+
offlineData: {
|
|
60
|
+
schema: space.schema,
|
|
61
|
+
style: space.style
|
|
62
|
+
},
|
|
63
|
+
warnings: noWarnings(warnings)
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
//#endregion
|
|
67
|
+
export { HOST_PAGE_REF, render, renderWidgetShape };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NotificationsSpec, CssProps } from '@plitzi/sdk-authoring';
|
|
1
|
+
import { DocumentScroll, NotificationsSpec, CssProps } from '@plitzi/sdk-authoring';
|
|
2
2
|
import { ElementRuntime, Environment, WhileRunning } from '@plitzi/sdk-shared';
|
|
3
3
|
export type Env = Environment;
|
|
4
4
|
/** CSS declarations for one selector state. Keys are kebab-case CSS properties (see plitzi://css-properties).
|
|
@@ -101,6 +101,8 @@ export interface AIPageSkeleton {
|
|
|
101
101
|
/** Whether the page is served by the published SDK runtime. A disabled page (`false`) is not routable/accessible
|
|
102
102
|
* to end users, but stays fully editable here. Defaults to true. */
|
|
103
103
|
enabled: boolean;
|
|
104
|
+
/** How the document moves while the page is on it (`upsertPage`'s `documentScroll`). Absent, it scrolls as any page. */
|
|
105
|
+
documentScroll?: DocumentScroll;
|
|
104
106
|
/** Route params bound by the slug (e.g. ":spaceId" → ["spaceId"]). Valid as {{name}} references on this page,
|
|
105
107
|
* alongside the space-level plitzi://schema-variables. */
|
|
106
108
|
routeParams: string[];
|
package/dist/render.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The widget render of `plitzi_render`, on its own: operations in, a self-contained `offlineData` out — no server, no
|
|
2
|
+
* space, no OAuth.
|
|
3
|
+
*
|
|
4
|
+
* Import it as `@plitzi/sdk-mcp/render` in a project whose own agent draws UI in its own pages: register `render` as
|
|
5
|
+
* a tool of the project's MCP server with `renderWidgetShape` as its input and `renderGuideText` for the agent to read,
|
|
6
|
+
* hand it `base` — the style of the project's space — so the widget looks like the page around it, and draw the
|
|
7
|
+
* answer with the `plitziSdk` element (its `offlineData`). */
|
|
8
|
+
export { HOST_PAGE_REF as RENDER_ROOT_REF, render, renderWidgetShape } from './modules/mcp/tools/renderWidget';
|
|
9
|
+
export { renderGuideText } from './modules/mcp/resources/renderGuide';
|
|
10
|
+
export type { RenderOptions, RenderResponse, RenderWidgetInput } from './modules/mcp/tools/renderWidget';
|
package/dist/render.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-mcp",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.14",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
"types": "./dist/server.d.ts",
|
|
20
20
|
"import": "./dist/server.js",
|
|
21
21
|
"default": "./dist/server.js"
|
|
22
|
+
},
|
|
23
|
+
"./render": {
|
|
24
|
+
"types": "./dist/render.d.ts",
|
|
25
|
+
"import": "./dist/render.js",
|
|
26
|
+
"default": "./dist/render.js"
|
|
22
27
|
}
|
|
23
28
|
},
|
|
24
29
|
"repository": {
|
|
@@ -30,12 +35,12 @@
|
|
|
30
35
|
"dependencies": {
|
|
31
36
|
"@modelcontextprotocol/ext-apps": "^1.7.5",
|
|
32
37
|
"@modelcontextprotocol/sdk": "^1.32.0",
|
|
33
|
-
"@plitzi/plitzi-sdk": "0.38.
|
|
34
|
-
"@plitzi/sdk-authoring": "0.38.
|
|
35
|
-
"@plitzi/sdk-schema": "0.38.
|
|
36
|
-
"@plitzi/sdk-server": "0.38.
|
|
37
|
-
"@plitzi/sdk-shared": "0.38.
|
|
38
|
-
"@plitzi/sdk-style": "0.38.
|
|
38
|
+
"@plitzi/plitzi-sdk": "0.38.14",
|
|
39
|
+
"@plitzi/sdk-authoring": "0.38.14",
|
|
40
|
+
"@plitzi/sdk-schema": "0.38.14",
|
|
41
|
+
"@plitzi/sdk-server": "0.38.14",
|
|
42
|
+
"@plitzi/sdk-shared": "0.38.14",
|
|
43
|
+
"@plitzi/sdk-style": "0.38.14",
|
|
39
44
|
"ejs": "^6.0.1",
|
|
40
45
|
"esbuild": "^0.28.2",
|
|
41
46
|
"zod": "^4.6.5"
|