@plitzi/sdk-server 0.30.19 → 0.31.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/CHANGELOG.md +12 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/helpers/cache/TtlCache.js +2 -0
- package/dist/index.js +6 -1
- package/dist/modules/ai/AIEngine.js +120 -0
- package/dist/modules/mcp/handler.js +35 -16
- package/dist/modules/mcp/helpers.js +75 -0
- package/dist/modules/mcp/resources/glossary/binding.js +73 -0
- package/dist/modules/mcp/resources/glossary/collection.js +76 -0
- package/dist/modules/mcp/resources/glossary/displayMode.js +50 -0
- package/dist/modules/mcp/resources/glossary/element.js +68 -0
- package/dist/modules/mcp/resources/glossary/environment.js +48 -0
- package/dist/modules/mcp/resources/glossary/interaction.js +62 -0
- package/dist/modules/mcp/resources/glossary/page.js +70 -0
- package/dist/modules/mcp/resources/glossary/plugin.js +96 -0
- package/dist/modules/mcp/resources/glossary/resource.js +75 -0
- package/dist/modules/mcp/resources/glossary/schema.js +69 -0
- package/dist/modules/mcp/resources/glossary/schemaVariable.js +60 -0
- package/dist/modules/mcp/resources/glossary/segment.js +59 -0
- package/dist/modules/mcp/resources/glossary/space.js +73 -0
- package/dist/modules/mcp/resources/glossary/style.js +81 -0
- package/dist/modules/mcp/resources/glossary/styleSelector.js +77 -0
- package/dist/modules/mcp/resources/glossary/styleVariable.js +72 -0
- package/dist/modules/mcp/resources/index.js +71 -0
- package/dist/modules/mcp/resources/workflows/data.js +49 -0
- package/dist/modules/mcp/resources/workflows/elements.js +53 -0
- package/dist/modules/mcp/resources/workflows/segments.js +55 -0
- package/dist/modules/mcp/resources/workflows/styles.js +91 -0
- package/dist/modules/mcp/server.js +23 -113
- package/dist/modules/mcp/tools/collections/createCollection.js +25 -0
- package/dist/modules/mcp/tools/collections/createCollectionRecord.js +27 -0
- package/dist/modules/mcp/tools/collections/deleteCollection.js +16 -0
- package/dist/modules/mcp/tools/collections/deleteCollectionRecord.js +16 -0
- package/dist/modules/mcp/tools/collections/getCollection.js +21 -0
- package/dist/modules/mcp/tools/collections/getCollectionRecord.js +25 -0
- package/dist/modules/mcp/tools/collections/getCollectionRecords.js +29 -0
- package/dist/modules/mcp/tools/collections/getCollections.js +19 -0
- package/dist/modules/mcp/tools/collections/updateCollection.js +28 -0
- package/dist/modules/mcp/tools/collections/updateCollectionRecord.js +31 -0
- package/dist/modules/mcp/tools/docs/listResources.js +16 -0
- package/dist/modules/mcp/tools/docs/readResource.js +23 -0
- package/dist/modules/mcp/tools/index.js +150 -0
- package/dist/modules/mcp/tools/plugins/addPlugin.js +24 -0
- package/dist/modules/mcp/tools/plugins/listPlugins.js +20 -0
- package/dist/modules/mcp/tools/plugins/removePlugin.js +16 -0
- package/dist/modules/mcp/tools/plugins/updatePlugin.js +23 -0
- package/dist/modules/mcp/tools/resources/addResource.js +33 -0
- package/dist/modules/mcp/tools/resources/getResource.js +29 -0
- package/dist/modules/mcp/tools/resources/getResources.js +27 -0
- package/dist/modules/mcp/tools/resources/moveResource.js +30 -0
- package/dist/modules/mcp/tools/resources/removeResource.js +19 -0
- package/dist/modules/mcp/tools/segment/createSegment.js +27 -0
- package/dist/modules/mcp/tools/segment/deleteSegment.js +16 -0
- package/dist/modules/mcp/tools/segment/getSegment.js +19 -0
- package/dist/modules/mcp/tools/segment/getSegments.js +27 -0
- package/dist/modules/mcp/tools/segment/schema/elements/createSegmentElement.js +24 -0
- package/dist/modules/mcp/tools/segment/schema/elements/deleteSegmentElement.js +19 -0
- package/dist/modules/mcp/tools/segment/schema/elements/moveSegmentElement.js +28 -0
- package/dist/modules/mcp/tools/segment/schema/elements/updateSegmentElement.js +23 -0
- package/dist/modules/mcp/tools/segment/schema/variables/createSegmentVariable.js +41 -0
- package/dist/modules/mcp/tools/segment/schema/variables/deleteSegmentVariable.js +19 -0
- package/dist/modules/mcp/tools/segment/schema/variables/updateSegmentVariable.js +41 -0
- package/dist/modules/mcp/tools/segment/style/variables/createSegmentStyleVariable.js +34 -0
- package/dist/modules/mcp/tools/segment/style/variables/deleteSegmentStyleVariable.js +21 -0
- package/dist/modules/mcp/tools/segment/style/variables/updateSegmentStyleVariable.js +34 -0
- package/dist/modules/mcp/tools/segment/updateSegment.js +30 -0
- package/dist/modules/mcp/tools/space/schema/applyPreview.js +33 -0
- package/dist/modules/mcp/tools/space/schema/elements/cloneElement.js +34 -0
- package/dist/modules/mcp/tools/space/schema/elements/createElement.js +50 -0
- package/dist/modules/mcp/tools/space/schema/elements/deleteElement.js +16 -0
- package/dist/modules/mcp/tools/space/schema/elements/getElement.js +17 -0
- package/dist/modules/mcp/tools/space/schema/elements/getElements.js +21 -0
- package/dist/modules/mcp/tools/space/schema/elements/listElements.js +28 -0
- package/dist/modules/mcp/tools/space/schema/elements/moveElement.js +27 -0
- package/dist/modules/mcp/tools/space/schema/elements/updateElement.js +49 -0
- package/dist/modules/mcp/tools/space/schema/getSpaceSettings.js +46 -0
- package/dist/modules/mcp/tools/space/schema/pageFolders/createPageFolder.js +24 -0
- package/dist/modules/mcp/tools/space/schema/pageFolders/deletePageFolder.js +16 -0
- package/dist/modules/mcp/tools/space/schema/pageFolders/getPageFolder.js +17 -0
- package/dist/modules/mcp/tools/space/schema/pageFolders/getPageFolders.js +17 -0
- package/dist/modules/mcp/tools/space/schema/pageFolders/updatePageFolder.js +28 -0
- package/dist/modules/mcp/tools/space/schema/pages/createPage.js +37 -0
- package/dist/modules/mcp/tools/space/schema/pages/deletePage.js +16 -0
- package/dist/modules/mcp/tools/space/schema/pages/getPage.js +28 -0
- package/dist/modules/mcp/tools/space/schema/pages/getPageBySlug.js +17 -0
- package/dist/modules/mcp/tools/space/schema/pages/getPages.js +17 -0
- package/dist/modules/mcp/tools/space/schema/pages/updatePage.js +25 -0
- package/dist/modules/mcp/tools/space/schema/schemas.js +53 -0
- package/dist/modules/mcp/tools/space/schema/updateSpaceSettings.js +23 -0
- package/dist/modules/mcp/tools/space/schema/variables/createVariable.js +38 -0
- package/dist/modules/mcp/tools/space/schema/variables/deleteVariable.js +16 -0
- package/dist/modules/mcp/tools/space/schema/variables/getVariable.js +17 -0
- package/dist/modules/mcp/tools/space/schema/variables/getVariables.js +17 -0
- package/dist/modules/mcp/tools/space/schema/variables/updateVariable.js +38 -0
- package/dist/modules/mcp/tools/space/style/selectors/createStyleSelector.js +37 -0
- package/dist/modules/mcp/tools/space/style/selectors/deleteStyleSelector.js +24 -0
- package/dist/modules/mcp/tools/space/style/selectors/getStyleSelectors.js +20 -0
- package/dist/modules/mcp/tools/space/style/selectors/updateStyleSelector.js +37 -0
- package/dist/modules/mcp/tools/space/style/variables/createStyleVariable.js +33 -0
- package/dist/modules/mcp/tools/space/style/variables/deleteStyleVariable.js +20 -0
- package/dist/modules/mcp/tools/space/style/variables/getStyleVariable.js +19 -0
- package/dist/modules/mcp/tools/space/style/variables/getStyleVariables.js +16 -0
- package/dist/modules/mcp/tools/space/style/variables/updateStyleVariable.js +33 -0
- package/dist/package.js +62 -0
- package/dist/package.json.d.ts +67 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/modules/ai/AIEngine.d.ts +20 -0
- package/dist/src/modules/ai/index.d.ts +3 -0
- package/dist/src/modules/mcp/handler.d.ts +5 -2
- package/dist/src/modules/mcp/helpers.d.ts +9 -0
- package/dist/src/modules/mcp/helpers.test.d.ts +1 -0
- package/dist/src/modules/mcp/index.d.ts +5 -0
- package/dist/src/modules/mcp/resources/glossary/binding.d.ts +7 -0
- package/dist/src/modules/mcp/resources/glossary/collection.d.ts +7 -0
- package/dist/src/modules/mcp/resources/glossary/displayMode.d.ts +7 -0
- package/dist/src/modules/mcp/resources/glossary/element.d.ts +7 -0
- package/dist/src/modules/mcp/resources/glossary/environment.d.ts +7 -0
- package/dist/src/modules/mcp/resources/glossary/interaction.d.ts +7 -0
- package/dist/src/modules/mcp/resources/glossary/page.d.ts +7 -0
- package/dist/src/modules/mcp/resources/glossary/plugin.d.ts +7 -0
- package/dist/src/modules/mcp/resources/glossary/resource.d.ts +7 -0
- package/dist/src/modules/mcp/resources/glossary/schema.d.ts +7 -0
- package/dist/src/modules/mcp/resources/glossary/schemaVariable.d.ts +7 -0
- package/dist/src/modules/mcp/resources/glossary/segment.d.ts +7 -0
- package/dist/src/modules/mcp/resources/glossary/space.d.ts +7 -0
- package/dist/src/modules/mcp/resources/glossary/style.d.ts +7 -0
- package/dist/src/modules/mcp/resources/glossary/styleSelector.d.ts +7 -0
- package/dist/src/modules/mcp/resources/glossary/styleVariable.d.ts +7 -0
- package/dist/src/modules/mcp/resources/index.d.ts +10 -0
- package/dist/src/modules/mcp/resources/workflows/data.d.ts +7 -0
- package/dist/src/modules/mcp/resources/workflows/elements.d.ts +7 -0
- package/dist/src/modules/mcp/resources/workflows/segments.d.ts +7 -0
- package/dist/src/modules/mcp/resources/workflows/styles.d.ts +7 -0
- package/dist/src/modules/mcp/server.d.ts +4 -3
- package/dist/src/modules/mcp/tools/collections/collections.test.d.ts +1 -0
- package/dist/src/modules/mcp/tools/collections/createCollection.d.ts +3 -0
- package/dist/src/modules/mcp/tools/collections/createCollectionRecord.d.ts +3 -0
- package/dist/src/modules/mcp/tools/collections/deleteCollection.d.ts +3 -0
- package/dist/src/modules/mcp/tools/collections/deleteCollectionRecord.d.ts +3 -0
- package/dist/src/modules/mcp/tools/collections/getCollection.d.ts +3 -0
- package/dist/src/modules/mcp/tools/collections/getCollectionRecord.d.ts +3 -0
- package/dist/src/modules/mcp/tools/collections/getCollectionRecords.d.ts +3 -0
- package/dist/src/modules/mcp/tools/collections/getCollections.d.ts +3 -0
- package/dist/src/modules/mcp/tools/collections/index.d.ts +10 -0
- package/dist/src/modules/mcp/tools/collections/updateCollection.d.ts +3 -0
- package/dist/src/modules/mcp/tools/collections/updateCollectionRecord.d.ts +3 -0
- package/dist/src/modules/mcp/tools/docs/index.d.ts +2 -0
- package/dist/src/modules/mcp/tools/docs/listResources.d.ts +3 -0
- package/dist/src/modules/mcp/tools/docs/readResource.d.ts +3 -0
- package/dist/src/modules/mcp/tools/index.d.ts +6 -0
- package/dist/src/modules/mcp/tools/plugins/addPlugin.d.ts +3 -0
- package/dist/src/modules/mcp/tools/plugins/index.d.ts +5 -0
- package/dist/src/modules/mcp/tools/plugins/listPlugins.d.ts +3 -0
- package/dist/src/modules/mcp/tools/plugins/plugins.test.d.ts +1 -0
- package/dist/src/modules/mcp/tools/plugins/removePlugin.d.ts +3 -0
- package/dist/src/modules/mcp/tools/plugins/updatePlugin.d.ts +3 -0
- package/dist/src/modules/mcp/tools/resources/addResource.d.ts +3 -0
- package/dist/src/modules/mcp/tools/resources/getResource.d.ts +3 -0
- package/dist/src/modules/mcp/tools/resources/getResources.d.ts +3 -0
- package/dist/src/modules/mcp/tools/resources/index.d.ts +6 -0
- package/dist/src/modules/mcp/tools/resources/moveResource.d.ts +3 -0
- package/dist/src/modules/mcp/tools/resources/removeResource.d.ts +3 -0
- package/dist/src/modules/mcp/tools/resources/resources.test.d.ts +1 -0
- package/dist/src/modules/mcp/tools/segment/createSegment.d.ts +3 -0
- package/dist/src/modules/mcp/tools/segment/deleteSegment.d.ts +3 -0
- package/dist/src/modules/mcp/tools/segment/getSegment.d.ts +3 -0
- package/dist/src/modules/mcp/tools/segment/getSegments.d.ts +3 -0
- package/dist/src/modules/mcp/tools/segment/index.d.ts +8 -0
- package/dist/src/modules/mcp/tools/segment/schema/elements/createSegmentElement.d.ts +3 -0
- package/dist/src/modules/mcp/tools/segment/schema/elements/deleteSegmentElement.d.ts +3 -0
- package/dist/src/modules/mcp/tools/segment/schema/elements/index.d.ts +5 -0
- package/dist/src/modules/mcp/tools/segment/schema/elements/moveSegmentElement.d.ts +3 -0
- package/dist/src/modules/mcp/tools/segment/schema/elements/segmentElements.test.d.ts +1 -0
- package/dist/src/modules/mcp/tools/segment/schema/elements/updateSegmentElement.d.ts +3 -0
- package/dist/src/modules/mcp/tools/segment/schema/index.d.ts +2 -0
- package/dist/src/modules/mcp/tools/segment/schema/variables/createSegmentVariable.d.ts +3 -0
- package/dist/src/modules/mcp/tools/segment/schema/variables/deleteSegmentVariable.d.ts +3 -0
- package/dist/src/modules/mcp/tools/segment/schema/variables/index.d.ts +4 -0
- package/dist/src/modules/mcp/tools/segment/schema/variables/segmentVariables.test.d.ts +1 -0
- package/dist/src/modules/mcp/tools/segment/schema/variables/updateSegmentVariable.d.ts +3 -0
- package/dist/src/modules/mcp/tools/segment/segment.test.d.ts +1 -0
- package/dist/src/modules/mcp/tools/segment/style/index.d.ts +1 -0
- package/dist/src/modules/mcp/tools/segment/style/variables/createSegmentStyleVariable.d.ts +3 -0
- package/dist/src/modules/mcp/tools/segment/style/variables/deleteSegmentStyleVariable.d.ts +3 -0
- package/dist/src/modules/mcp/tools/segment/style/variables/index.d.ts +4 -0
- package/dist/src/modules/mcp/tools/segment/style/variables/segmentStyleVariables.test.d.ts +1 -0
- package/dist/src/modules/mcp/tools/segment/style/variables/updateSegmentStyleVariable.d.ts +3 -0
- package/dist/src/modules/mcp/tools/segment/updateSegment.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/index.d.ts +2 -0
- package/dist/src/modules/mcp/tools/space/schema/applyPreview.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/elements/cloneElement.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/elements/createElement.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/elements/deleteElement.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/elements/elements.test.d.ts +1 -0
- package/dist/src/modules/mcp/tools/space/schema/elements/getElement.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/elements/getElements.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/elements/index.d.ts +9 -0
- package/dist/src/modules/mcp/tools/space/schema/elements/listElements.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/elements/moveElement.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/elements/updateElement.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/getSpaceSettings.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/index.d.ts +8 -0
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/createPageFolder.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/deletePageFolder.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/getPageFolder.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/getPageFolders.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/index.d.ts +6 -0
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/pageFolders.test.d.ts +1 -0
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/updatePageFolder.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/pages/createPage.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/pages/deletePage.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/pages/getPage.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/pages/getPageBySlug.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/pages/getPages.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/pages/index.d.ts +7 -0
- package/dist/src/modules/mcp/tools/space/schema/pages/pages.test.d.ts +1 -0
- package/dist/src/modules/mcp/tools/space/schema/pages/updatePage.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/schemas.d.ts +66 -0
- package/dist/src/modules/mcp/tools/space/schema/updateSpaceSettings.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/variables/createVariable.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/variables/deleteVariable.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/variables/getVariable.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/variables/getVariables.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/variables/index.d.ts +6 -0
- package/dist/src/modules/mcp/tools/space/schema/variables/updateVariable.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/schema/variables/variables.test.d.ts +1 -0
- package/dist/src/modules/mcp/tools/space/space.test.d.ts +1 -0
- package/dist/src/modules/mcp/tools/space/style/index.d.ts +2 -0
- package/dist/src/modules/mcp/tools/space/style/selectors/createStyleSelector.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/style/selectors/deleteStyleSelector.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/style/selectors/getStyleSelectors.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/style/selectors/index.d.ts +5 -0
- package/dist/src/modules/mcp/tools/space/style/selectors/styleSelectors.test.d.ts +1 -0
- package/dist/src/modules/mcp/tools/space/style/selectors/updateStyleSelector.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/style/variables/createStyleVariable.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/style/variables/deleteStyleVariable.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/style/variables/getStyleVariable.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/style/variables/getStyleVariables.d.ts +3 -0
- package/dist/src/modules/mcp/tools/space/style/variables/index.d.ts +6 -0
- package/dist/src/modules/mcp/tools/space/style/variables/styleVariables.test.d.ts +1 -0
- package/dist/src/modules/mcp/tools/space/style/variables/updateStyleVariable.d.ts +3 -0
- package/package.json +18 -14
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { DEFAULT_TTL_MS } from "./defaults.js";
|
|
2
2
|
//#region src/helpers/cache/TtlCache.ts
|
|
3
3
|
var TtlCache = class {
|
|
4
|
+
ttlMs;
|
|
5
|
+
maxSize;
|
|
4
6
|
store = /* @__PURE__ */ new Map();
|
|
5
7
|
sweepTimer;
|
|
6
8
|
constructor(ttlMs = DEFAULT_TTL_MS.html, maxSize = 500, sweepIntervalMs = ttlMs) {
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { bindTools, getAllowedModes, isToolActive, resolveToolHandler, toolResponseErr, toolResponseOk, zodToJsonSchema } from "./modules/mcp/helpers.js";
|
|
2
|
+
import { tools_exports } from "./modules/mcp/tools/index.js";
|
|
3
|
+
import { createMcpServer } from "./modules/mcp/server.js";
|
|
4
|
+
import AIEngine from "./modules/ai/AIEngine.js";
|
|
5
|
+
import { handleMcp, readMcpBody } from "./modules/mcp/handler.js";
|
|
1
6
|
import { createSSRServer } from "./core/createServer.js";
|
|
2
7
|
import { createJsonAdapters } from "./adapters/jsonAdapters.js";
|
|
3
|
-
export { createJsonAdapters, createSSRServer };
|
|
8
|
+
export { AIEngine, bindTools, createJsonAdapters, createMcpServer, createSSRServer, getAllowedModes, handleMcp, isToolActive, readMcpBody, resolveToolHandler, toolResponseErr, toolResponseOk, tools_exports as tools, zodToJsonSchema };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { toolResponseErr } from "../mcp/helpers.js";
|
|
2
|
+
//#region src/modules/ai/AIEngine.ts
|
|
3
|
+
var AIEngine = class {
|
|
4
|
+
mode;
|
|
5
|
+
callbacks;
|
|
6
|
+
toolsAvailables = /* @__PURE__ */ new Map();
|
|
7
|
+
toolsAvailablesMap = /* @__PURE__ */ new Map();
|
|
8
|
+
ctx;
|
|
9
|
+
constructor(mode, callbacks, ctx) {
|
|
10
|
+
this.mode = mode;
|
|
11
|
+
this.callbacks = callbacks;
|
|
12
|
+
this.ctx = {
|
|
13
|
+
...ctx,
|
|
14
|
+
mode: mode || "plan"
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
readResource = (name, uri) => {
|
|
18
|
+
this.callbacks.onResourceRead?.(name, uri);
|
|
19
|
+
};
|
|
20
|
+
setToolsAvailables = (tools) => {
|
|
21
|
+
this.toolsAvailables = new Map(tools.map((t) => [t.name, t]));
|
|
22
|
+
this.toolsAvailablesMap = new Map(tools.map((t) => [t.name, t.definition.allowedModes]));
|
|
23
|
+
};
|
|
24
|
+
can = (name) => {
|
|
25
|
+
if (!this.mode || !this.toolsAvailablesMap.has(name)) return false;
|
|
26
|
+
const allowedModes = this.toolsAvailablesMap.get(name);
|
|
27
|
+
return !allowedModes || allowedModes.includes(this.mode);
|
|
28
|
+
};
|
|
29
|
+
before = async (name, args) => {
|
|
30
|
+
this.callbacks.onBeforeTool?.(name, args);
|
|
31
|
+
if (!this.toolsAvailables.has(name)) {
|
|
32
|
+
this.callbacks.onLog?.("error", `tool rejected: '${name}' has no definition — possible security violation`);
|
|
33
|
+
await this.after(name, args, toolResponseErr(`Tool '${name}' is not defined and cannot be executed`));
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (!this.can(name)) {
|
|
37
|
+
this.callbacks.onLog?.("info", `tool blocked: '${name}' is not permitted in ${this.mode} mode`);
|
|
38
|
+
await this.after(name, args, toolResponseErr(`Tool '${name}' is not permitted in ${this.mode} mode`));
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
};
|
|
43
|
+
after = (name, args, result) => {
|
|
44
|
+
let resultParsed;
|
|
45
|
+
if (result.data !== void 0) resultParsed = result.data;
|
|
46
|
+
else try {
|
|
47
|
+
resultParsed = JSON.parse(result.content[0]?.text ?? "");
|
|
48
|
+
} catch {}
|
|
49
|
+
if (result.isError) this.callbacks.onToolError?.({
|
|
50
|
+
name,
|
|
51
|
+
args,
|
|
52
|
+
result: resultParsed ?? { error: result.content[0]?.text ?? "Tool failed" }
|
|
53
|
+
});
|
|
54
|
+
else this.callbacks.onToolSuccess?.({
|
|
55
|
+
name,
|
|
56
|
+
args,
|
|
57
|
+
result: resultParsed
|
|
58
|
+
});
|
|
59
|
+
return Promise.resolve();
|
|
60
|
+
};
|
|
61
|
+
validateToolInput = (name, args) => {
|
|
62
|
+
const tool = this.toolsAvailables.get(name);
|
|
63
|
+
if (!tool || !tool.mcpDefinition.inputSchema) return {
|
|
64
|
+
success: true,
|
|
65
|
+
data: args
|
|
66
|
+
};
|
|
67
|
+
const parsed = tool.mcpDefinition.inputSchema.safeParse(args);
|
|
68
|
+
if (!parsed.success) return {
|
|
69
|
+
success: false,
|
|
70
|
+
error: parsed.error.message
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
success: true,
|
|
74
|
+
data: parsed.data
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
validateToolOutput = (name, result) => {
|
|
78
|
+
const tool = this.toolsAvailables.get(name);
|
|
79
|
+
if (!tool || !tool.mcpDefinition.outputSchema || result.isError) return;
|
|
80
|
+
if (result.data === void 0) return;
|
|
81
|
+
const parsed = tool.mcpDefinition.outputSchema.safeParse(result.data);
|
|
82
|
+
if (!parsed.success) return parsed.error.message;
|
|
83
|
+
};
|
|
84
|
+
runPipeline = async (name, args, handler) => {
|
|
85
|
+
const parsedArgs = this.validateToolInput(name, args);
|
|
86
|
+
if (!parsedArgs.success) {
|
|
87
|
+
this.callbacks.onLog?.("error", `tool validation error: ${name} error=${parsedArgs.error}`);
|
|
88
|
+
const err = toolResponseErr(parsedArgs.error);
|
|
89
|
+
await this.after(name, args, err);
|
|
90
|
+
return err;
|
|
91
|
+
}
|
|
92
|
+
const t0 = Date.now();
|
|
93
|
+
const result = await handler(parsedArgs.data, this.ctx);
|
|
94
|
+
this.callbacks.onLog?.("debug", `tool done: ${name} ms=${Date.now() - t0} result=${JSON.stringify(result).slice(0, 200)}`);
|
|
95
|
+
const outputError = this.validateToolOutput(name, result);
|
|
96
|
+
if (outputError) this.callbacks.onLog?.("info", `tool output schema drift: ${name} — ${outputError}`);
|
|
97
|
+
const tool = this.toolsAvailables.get(name);
|
|
98
|
+
if (!result.isError && tool?.mcpDefinition.outputSchema && result.data !== void 0 && result.data !== null) result.structuredContent = typeof result.data === "object" && !Array.isArray(result.data) ? result.data : { data: result.data };
|
|
99
|
+
if (result.isError) this.callbacks.onLog?.("error", `tool failed: ${name} error=${result.content[0]?.text ?? "unknown"}`);
|
|
100
|
+
await this.after(name, args, result);
|
|
101
|
+
return result;
|
|
102
|
+
};
|
|
103
|
+
execute = (name, handlerFn) => async (args) => {
|
|
104
|
+
if (!await this.before(name, args)) return toolResponseErr(`Tool '${name}' execution was blocked`);
|
|
105
|
+
const handler = handlerFn ?? this.toolsAvailables.get(name)?.handler;
|
|
106
|
+
if (!handler) {
|
|
107
|
+
this.callbacks.onLog?.("error", `no handler registered for tool: ${name}`);
|
|
108
|
+
const err = toolResponseErr(`Tool '${name}' has no handler`);
|
|
109
|
+
await this.after(name, args, err);
|
|
110
|
+
return err;
|
|
111
|
+
}
|
|
112
|
+
this.callbacks.onLog?.("debug", `tool exec: ${name} args=${JSON.stringify(args).slice(0, 200)}`);
|
|
113
|
+
return this.runPipeline(name, args, handler);
|
|
114
|
+
};
|
|
115
|
+
executePrompt = (_name, handlerFn) => async (args) => {
|
|
116
|
+
return handlerFn(args, this.ctx);
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
//#endregion
|
|
120
|
+
export { AIEngine as default };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createMcpServer } from "./server.js";
|
|
2
|
+
import AIEngine from "../ai/AIEngine.js";
|
|
2
3
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
3
4
|
//#region src/modules/mcp/handler.ts
|
|
4
|
-
var
|
|
5
|
+
var readMcpBody = (req) => new Promise((resolve, reject) => {
|
|
5
6
|
let raw = "";
|
|
6
7
|
req.on("data", (chunk) => {
|
|
7
8
|
raw += chunk.toString();
|
|
@@ -15,20 +16,38 @@ var readBody = (req) => new Promise((resolve, reject) => {
|
|
|
15
16
|
});
|
|
16
17
|
req.on("error", reject);
|
|
17
18
|
});
|
|
18
|
-
var handleMcp = async (req, res, config) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
var handleMcp = async (req, res, config, server, transport, context) => {
|
|
20
|
+
if (!server) {
|
|
21
|
+
const ctx = context ?? {
|
|
22
|
+
userId: 0,
|
|
23
|
+
spaceId: 0,
|
|
24
|
+
environment: "main",
|
|
25
|
+
mode: "plan"
|
|
26
|
+
};
|
|
27
|
+
const engine = new AIEngine(ctx.mode, {}, ctx);
|
|
28
|
+
server = createMcpServer(config.adapters, engine, config.tools, config.prompts);
|
|
29
|
+
}
|
|
30
|
+
if (!transport) transport = new StreamableHTTPServerTransport({
|
|
31
|
+
sessionIdGenerator: void 0,
|
|
32
|
+
enableJsonResponse: true
|
|
33
|
+
});
|
|
34
|
+
await server.connect(transport);
|
|
35
|
+
try {
|
|
36
|
+
if (req.method === "POST") {
|
|
37
|
+
let body;
|
|
38
|
+
if (req.body !== void 0) body = req.body;
|
|
39
|
+
else try {
|
|
40
|
+
body = await readMcpBody(req);
|
|
41
|
+
} catch {
|
|
42
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
43
|
+
res.end(JSON.stringify({ error: "Invalid JSON body" }));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
await transport.handleRequest(req, res, body);
|
|
47
|
+
} else await transport.handleRequest(req, res);
|
|
48
|
+
} finally {
|
|
49
|
+
await transport.close();
|
|
50
|
+
}
|
|
32
51
|
};
|
|
33
52
|
//#endregion
|
|
34
|
-
export { handleMcp };
|
|
53
|
+
export { handleMcp, readMcpBody };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/modules/mcp/helpers.ts
|
|
3
|
+
var zodToJsonSchema = (schema) => {
|
|
4
|
+
if (schema instanceof z.ZodObject) {
|
|
5
|
+
const properties = {};
|
|
6
|
+
const required = [];
|
|
7
|
+
for (const [key, value] of Object.entries(schema.shape)) {
|
|
8
|
+
properties[key] = zodToJsonSchema(value);
|
|
9
|
+
if (value instanceof z.ZodString || value instanceof z.ZodNumber || value instanceof z.ZodBoolean) {
|
|
10
|
+
if (!value.isOptional()) required.push(key);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties,
|
|
16
|
+
required: required.length > 0 ? required : []
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (schema instanceof z.ZodString) return { type: "string" };
|
|
20
|
+
if (schema instanceof z.ZodNumber) return { type: "number" };
|
|
21
|
+
if (schema instanceof z.ZodBoolean) return { type: "boolean" };
|
|
22
|
+
if (schema instanceof z.ZodEnum) return {
|
|
23
|
+
type: "string",
|
|
24
|
+
enum: schema.options
|
|
25
|
+
};
|
|
26
|
+
if (schema instanceof z.ZodOptional) return zodToJsonSchema(schema._def.innerType);
|
|
27
|
+
if (schema instanceof z.ZodUnion) return { oneOf: schema.options.map((opt) => zodToJsonSchema(opt)) };
|
|
28
|
+
if (schema instanceof z.ZodArray) return {
|
|
29
|
+
type: "array",
|
|
30
|
+
items: zodToJsonSchema(schema.element)
|
|
31
|
+
};
|
|
32
|
+
if (schema instanceof z.ZodRecord) return {
|
|
33
|
+
type: "object",
|
|
34
|
+
additionalProperties: zodToJsonSchema(schema.valueType)
|
|
35
|
+
};
|
|
36
|
+
return {};
|
|
37
|
+
};
|
|
38
|
+
var getAllowedModes = (operationType) => {
|
|
39
|
+
return operationType === "write" ? ["build"] : ["plan", "build"];
|
|
40
|
+
};
|
|
41
|
+
var toolResponseOk = (data, agentMessage) => {
|
|
42
|
+
return {
|
|
43
|
+
content: [{
|
|
44
|
+
type: "text",
|
|
45
|
+
text: agentMessage ?? JSON.stringify(data ?? null, null, 2)
|
|
46
|
+
}],
|
|
47
|
+
data
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
var toolResponseErr = (error) => ({
|
|
51
|
+
content: [{
|
|
52
|
+
type: "text",
|
|
53
|
+
text: error instanceof Error ? error.message : error
|
|
54
|
+
}],
|
|
55
|
+
isError: true
|
|
56
|
+
});
|
|
57
|
+
var isToolActive = (tool, adapters) => Boolean(tool.handler || tool.adapterName && adapters[tool.adapterName]);
|
|
58
|
+
var resolveToolHandler = (tool, adapters) => {
|
|
59
|
+
if (tool.handler) return tool.handler;
|
|
60
|
+
if (tool.adapterName) return adapterWrapper(tool.adapterName, adapters[tool.adapterName]);
|
|
61
|
+
};
|
|
62
|
+
var bindTools = (tools, adapters) => tools.filter((tool) => isToolActive(tool, adapters)).map((tool) => ({
|
|
63
|
+
...tool,
|
|
64
|
+
handler: resolveToolHandler(tool, adapters)
|
|
65
|
+
}));
|
|
66
|
+
var adapterWrapper = (adapterName, handler) => {
|
|
67
|
+
return async (args, ctx) => {
|
|
68
|
+
if (!handler) return toolResponseErr(`Adapter ${adapterName} not found`);
|
|
69
|
+
const result = await handler(args, ctx);
|
|
70
|
+
if ("error" in result) return toolResponseErr(result.error);
|
|
71
|
+
return toolResponseOk(result.data);
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
//#endregion
|
|
75
|
+
export { bindTools, getAllowedModes, isToolActive, resolveToolHandler, toolResponseErr, toolResponseOk, zodToJsonSchema };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//#region src/modules/mcp/resources/glossary/binding.ts
|
|
2
|
+
var bindingResource = {
|
|
3
|
+
uri: "plitzi://docs/binding",
|
|
4
|
+
name: "Plitzi Docs: Binding",
|
|
5
|
+
description: "Data bindings in Plitzi — connections that dynamically drive element attributes, style, or state from data sources.",
|
|
6
|
+
mimeType: "text/markdown",
|
|
7
|
+
content: `# Binding
|
|
8
|
+
|
|
9
|
+
A **Binding** connects a data source to an element property. At runtime, the bound value replaces the element's static attribute, style, or initial state. Bindings enable dynamic content — data from collections, variables, navigation params, or other elements can drive what is displayed or how it looks.
|
|
10
|
+
|
|
11
|
+
## TypeScript Shape
|
|
12
|
+
|
|
13
|
+
\`\`\`typescript
|
|
14
|
+
type BindingCategory = 'attributes' | 'style' | 'initialState';
|
|
15
|
+
|
|
16
|
+
type ElementBinding = {
|
|
17
|
+
id: string;
|
|
18
|
+
source: string; // Data source ID / reference
|
|
19
|
+
fromPath?: string; // Path within the source data (e.g. 'user.name')
|
|
20
|
+
transformers?: BindingTransformer[]; // Optional value transforms
|
|
21
|
+
when?: RuleGroup; // Conditional activation rule
|
|
22
|
+
enabled?: boolean;
|
|
23
|
+
toPath: string; // Target attribute/style/state path to overwrite
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type BindingTransformer = {
|
|
27
|
+
type: 'utility' | 'unknown';
|
|
28
|
+
action: string; // Transform function name
|
|
29
|
+
params: { valueType: string; value: string };
|
|
30
|
+
};
|
|
31
|
+
\`\`\`
|
|
32
|
+
|
|
33
|
+
## Binding Categories
|
|
34
|
+
|
|
35
|
+
Bindings are grouped by what they target inside an element:
|
|
36
|
+
|
|
37
|
+
| Category | What it overwrites |
|
|
38
|
+
|---|---|
|
|
39
|
+
| \`attributes\` | Fields in \`element.attributes\` (e.g. \`text\`, \`src\`, \`href\`) |
|
|
40
|
+
| \`style\` | Style-related data (e.g. active style variant) |
|
|
41
|
+
| \`initialState\` | Initial runtime state values |
|
|
42
|
+
|
|
43
|
+
## Key Properties
|
|
44
|
+
|
|
45
|
+
- **\`source\`** — identifies the data source (a collection ID, a schema variable name, a navigation param key, etc.).
|
|
46
|
+
- **\`fromPath\`** — dot-notation path into the source data to extract the bound value (e.g. \`'record.title'\`).
|
|
47
|
+
- **\`toPath\`** — dot-notation path of the target property to set on the element (e.g. \`'text'\`, \`'src'\`).
|
|
48
|
+
- **\`transformers\`** — optional chain of value transforms applied before writing to \`toPath\`.
|
|
49
|
+
- **\`when\`** — a \`RuleGroup\` condition; the binding only applies when the condition evaluates to true.
|
|
50
|
+
|
|
51
|
+
## Where Bindings Are Stored
|
|
52
|
+
|
|
53
|
+
Bindings live inside \`element.definition.bindings\`:
|
|
54
|
+
|
|
55
|
+
\`\`\`typescript
|
|
56
|
+
element.definition.bindings = {
|
|
57
|
+
attributes: [
|
|
58
|
+
{ id: '...', source: 'collection-posts', fromPath: 'title', toPath: 'text', ... }
|
|
59
|
+
],
|
|
60
|
+
style: [...],
|
|
61
|
+
initialState: [...]
|
|
62
|
+
}
|
|
63
|
+
\`\`\`
|
|
64
|
+
|
|
65
|
+
## Relationships
|
|
66
|
+
|
|
67
|
+
- Bindings reference **Schema Variables** (source by variable name) or external data sources.
|
|
68
|
+
- Bindings are part of **Element** definitions.
|
|
69
|
+
- **Interactions** complement bindings by handling user-triggered events (click, change).
|
|
70
|
+
`
|
|
71
|
+
};
|
|
72
|
+
//#endregion
|
|
73
|
+
export { bindingResource };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//#region src/modules/mcp/resources/glossary/collection.ts
|
|
2
|
+
var collectionResource = {
|
|
3
|
+
uri: "plitzi://docs/collection",
|
|
4
|
+
name: "Plitzi Docs: Collection",
|
|
5
|
+
description: "A CMS-style data store in Plitzi — a typed set of records with configurable fields.",
|
|
6
|
+
mimeType: "text/markdown",
|
|
7
|
+
content: `# Collection
|
|
8
|
+
|
|
9
|
+
A **Collection** is a CMS-style data store inside a Plitzi space. It has a defined field schema and holds typed records. Collections are used to manage dynamic content (blog posts, product listings, team members, etc.) that elements can bind to via data sources.
|
|
10
|
+
|
|
11
|
+
## TypeScript Shape
|
|
12
|
+
|
|
13
|
+
\`\`\`typescript
|
|
14
|
+
type Collection = {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string; // Singular name (e.g. 'Post')
|
|
17
|
+
namePlural: string; // Plural name (e.g. 'Posts')
|
|
18
|
+
description: string;
|
|
19
|
+
privacy: 'public' | 'private';
|
|
20
|
+
fields: Record<string, CollectionField>; // Field schema keyed by field ID
|
|
21
|
+
records: CollectionRecord[];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type CollectionField = {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string; // Human-readable label
|
|
27
|
+
machineName: string; // Programmatic key used in record values
|
|
28
|
+
type:
|
|
29
|
+
| 'text' | 'richText' | 'image' | 'multiImage'
|
|
30
|
+
| 'video' | 'link' | 'email' | 'phone'
|
|
31
|
+
| 'number' | 'date' | 'switch' | 'color'
|
|
32
|
+
| 'option' | 'file';
|
|
33
|
+
params: {
|
|
34
|
+
primary: boolean; // Whether this is the display/title field
|
|
35
|
+
required: boolean;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
type CollectionRecord = {
|
|
40
|
+
id: string;
|
|
41
|
+
values: Record<string, string | number | boolean>; // Keyed by field machineName
|
|
42
|
+
status: 'draft' | 'published' | 'archived';
|
|
43
|
+
createdAt: number;
|
|
44
|
+
updatedAt: number;
|
|
45
|
+
publishedAt?: number;
|
|
46
|
+
};
|
|
47
|
+
\`\`\`
|
|
48
|
+
|
|
49
|
+
## Key Properties
|
|
50
|
+
|
|
51
|
+
- **\`fields\`** — the schema of the collection. Each field has a \`machineName\` which is the key used in \`record.values\`.
|
|
52
|
+
- **\`CollectionField.type\`** — determines the data type and editor widget. Use \`richText\` for HTML content, \`image\` for single image uploads.
|
|
53
|
+
- **\`CollectionField.params.primary\`** — marks the main display field (title/name). Used in lists and pickers.
|
|
54
|
+
- **\`CollectionRecord.values\`** — the actual record data, keyed by \`field.machineName\`.
|
|
55
|
+
- **\`CollectionRecord.status\`** — content lifecycle. Only \`published\` records are visible in production.
|
|
56
|
+
|
|
57
|
+
## Relationships
|
|
58
|
+
|
|
59
|
+
- Elements can bind to collection data via **Bindings** (data source type \`collection\`).
|
|
60
|
+
- Collections belong to a **Space** and are available across all environments.
|
|
61
|
+
|
|
62
|
+
## Common Operations
|
|
63
|
+
|
|
64
|
+
- \`get_collections\` — list all collections in the space.
|
|
65
|
+
- \`get_collection\` — get a collection with its field schema.
|
|
66
|
+
- \`create_collection\` — define a new content type.
|
|
67
|
+
- \`update_collection\` — rename or modify a collection.
|
|
68
|
+
- \`delete_collection\` — remove collection and all records.
|
|
69
|
+
- \`get_collection_records\` — fetch records (optionally filtered by status).
|
|
70
|
+
- \`create_collection_record\` — add a new record.
|
|
71
|
+
- \`update_collection_record\` — edit an existing record.
|
|
72
|
+
- \`delete_collection_record\` — remove a record.
|
|
73
|
+
`
|
|
74
|
+
};
|
|
75
|
+
//#endregion
|
|
76
|
+
export { collectionResource };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/modules/mcp/resources/glossary/displayMode.ts
|
|
2
|
+
var displayModeResource = {
|
|
3
|
+
uri: "plitzi://docs/display-mode",
|
|
4
|
+
name: "Plitzi Docs: Display Mode",
|
|
5
|
+
description: "Responsive breakpoints in Plitzi — desktop, tablet, and mobile style layers.",
|
|
6
|
+
mimeType: "text/markdown",
|
|
7
|
+
content: `# Display Mode
|
|
8
|
+
|
|
9
|
+
A **Display Mode** represents a responsive breakpoint in the Plitzi style system. Styles are defined per display mode, allowing different visual rules at each screen size.
|
|
10
|
+
|
|
11
|
+
## Type
|
|
12
|
+
|
|
13
|
+
\`\`\`typescript
|
|
14
|
+
type DisplayMode = 'desktop' | 'tablet' | 'mobile';
|
|
15
|
+
\`\`\`
|
|
16
|
+
|
|
17
|
+
## Structure in Style
|
|
18
|
+
|
|
19
|
+
The \`Style.platform\` object holds one style layer per display mode:
|
|
20
|
+
|
|
21
|
+
\`\`\`typescript
|
|
22
|
+
style.platform = {
|
|
23
|
+
desktop: Record<string, StyleItem>, // Base styles (widest breakpoint)
|
|
24
|
+
tablet: Record<string, StyleItem>, // Overrides for tablet-width screens
|
|
25
|
+
mobile: Record<string, StyleItem> // Overrides for mobile-width screens
|
|
26
|
+
};
|
|
27
|
+
\`\`\`
|
|
28
|
+
|
|
29
|
+
Each mode contains the same set of CSS selectors (keyed by selector string). A selector defined only in \`desktop\` inherits its rules at all sizes unless overridden in \`tablet\` or \`mobile\`.
|
|
30
|
+
|
|
31
|
+
## Cascade Direction
|
|
32
|
+
|
|
33
|
+
- **Desktop-first** (default, \`style.mode === 'desktop-first'\`): \`desktop\` is the base. \`tablet\` overrides at medium widths. \`mobile\` overrides at narrow widths.
|
|
34
|
+
- **Mobile-first** (\`style.mode === 'mobile-first'\`): \`mobile\` is the base. \`tablet\` and \`desktop\` add styles as the viewport widens.
|
|
35
|
+
|
|
36
|
+
## In MCP Operations
|
|
37
|
+
|
|
38
|
+
MCP style tools that modify selectors accept a \`displayMode\` parameter:
|
|
39
|
+
|
|
40
|
+
\`\`\`typescript
|
|
41
|
+
createStyleSelector({ displayMode: 'mobile', selector: '.hero', ... })
|
|
42
|
+
updateStyleSelector({ displayMode: 'tablet', selector: '.hero', ... })
|
|
43
|
+
deleteStyleSelector({ displayMode: 'desktop', selector: '.hero' })
|
|
44
|
+
\`\`\`
|
|
45
|
+
|
|
46
|
+
Omitting \`displayMode\` typically defaults to \`desktop\`.
|
|
47
|
+
`
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { displayModeResource };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//#region src/modules/mcp/resources/glossary/element.ts
|
|
2
|
+
var elementResource = {
|
|
3
|
+
uri: "plitzi://docs/element",
|
|
4
|
+
name: "Plitzi Docs: Element",
|
|
5
|
+
description: "A single UI component instance in a Plitzi page — the building block of every schema.",
|
|
6
|
+
mimeType: "text/markdown",
|
|
7
|
+
content: `# Element
|
|
8
|
+
|
|
9
|
+
An \`Element\` is a single instance of a UI component in a Plitzi page. Every visual item — pages, containers, text blocks, forms, images — is an element. The entire page tree is stored as a flat dictionary of elements keyed by ID.
|
|
10
|
+
|
|
11
|
+
## TypeScript Shape
|
|
12
|
+
|
|
13
|
+
\`\`\`typescript
|
|
14
|
+
type Element<TAttributes = Record<string, unknown>> = {
|
|
15
|
+
id: string;
|
|
16
|
+
attributes: TAttributes & { subType?: string }; // Component-specific configuration
|
|
17
|
+
definition: ElementDefinition;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type ElementDefinition = {
|
|
21
|
+
rootId: string; // ID of the page/root element this belongs to
|
|
22
|
+
label: string; // Human-readable name shown in the builder
|
|
23
|
+
type: string; // Element type identifier (e.g. 'container', 'text', 'image')
|
|
24
|
+
parentId?: string; // ID of the parent element (undefined = root)
|
|
25
|
+
items?: string[]; // Ordered array of child element IDs
|
|
26
|
+
styleSelectors: {
|
|
27
|
+
base: string; // Always present — the primary CSS class
|
|
28
|
+
[key: string]: string; // Additional sub-selectors (e.g. 'header', 'body', 'icon')
|
|
29
|
+
};
|
|
30
|
+
bindings?: Partial<Record<'attributes' | 'style' | 'initialState', ElementBinding[]>>;
|
|
31
|
+
interactions?: Record<string, ElementInteraction>;
|
|
32
|
+
initialState?: {
|
|
33
|
+
styleVariant?: Record<string, Record<string, string | string[]>>;
|
|
34
|
+
styleSelectors?: ElementDefinition['styleSelectors'];
|
|
35
|
+
visibility?: boolean;
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
};
|
|
38
|
+
runtime?: 'server' | 'client' | 'shared'; // RSC render target
|
|
39
|
+
loadStrategy?: 'eager' | 'lazy' | 'visible'; // When to load/render
|
|
40
|
+
};
|
|
41
|
+
\`\`\`
|
|
42
|
+
|
|
43
|
+
## Key Properties
|
|
44
|
+
|
|
45
|
+
- **\`id\`** — unique identifier, used as the key in \`schema.flat\`.
|
|
46
|
+
- **\`attributes\`** — component-specific data (text content, URLs, settings). Shape varies by plugin type. \`subType\` selects a variant within the same plugin.
|
|
47
|
+
- **\`definition.type\`** — element type identifier that determines which component renders this element. Get valid values from \`get_builder_context\` (\`elementDefaults\` keys) or from the \`type\` field of existing elements in \`get_schema\`. This is NOT the plugin name from \`list_plugins\`.
|
|
48
|
+
- **\`definition.parentId\`** — parent element ID. Elements without \`parentId\` are root elements (pages).
|
|
49
|
+
- **\`definition.items\`** — ordered child IDs. Walk the tree by following \`items\` recursively.
|
|
50
|
+
- **\`definition.styleSelectors\`** — maps named selector slots to actual CSS class strings from the \`Style\`. \`base\` is always present.
|
|
51
|
+
- **\`definition.bindings\`** — data bindings that dynamically overwrite \`attributes\`, \`style\`, or \`initialState\` fields at runtime.
|
|
52
|
+
- **\`definition.interactions\`** — event handlers (onClick, onChange, etc.) mapping to configured actions.
|
|
53
|
+
- **\`definition.rootId\`** — always points to the page element this element belongs to.
|
|
54
|
+
|
|
55
|
+
## Relationships
|
|
56
|
+
|
|
57
|
+
- All elements live in \`schema.flat[id]\`.
|
|
58
|
+
- Parent–child links: \`definition.parentId\` (up) and \`definition.items\` (down).
|
|
59
|
+
- Style data for each element is found in \`style.platform[displayMode][styleSelector]\`.
|
|
60
|
+
- **Segment** elements have their own \`schema.flat\` but follow the same structure.
|
|
61
|
+
|
|
62
|
+
## Page Elements
|
|
63
|
+
|
|
64
|
+
A page is an element whose type corresponds to a page plugin. Its ID appears in \`schema.pages\`. Pages are the top-level roots; they have no \`parentId\` and their \`rootId\` points to themselves.
|
|
65
|
+
`
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
export { elementResource };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//#region src/modules/mcp/resources/glossary/environment.ts
|
|
2
|
+
var environmentResource = {
|
|
3
|
+
uri: "plitzi://docs/environment",
|
|
4
|
+
name: "Plitzi Docs: Environment",
|
|
5
|
+
description: "Deployment environments in Plitzi — main (working copy), development, staging, and production.",
|
|
6
|
+
mimeType: "text/markdown",
|
|
7
|
+
content: `# Environment
|
|
8
|
+
|
|
9
|
+
An **Environment** in Plitzi is a named version of a space's schema, style, and segments. Each environment can be published independently to its own domain.
|
|
10
|
+
|
|
11
|
+
## Type
|
|
12
|
+
|
|
13
|
+
\`\`\`typescript
|
|
14
|
+
type Environment = 'production' | 'staging' | 'development' | 'main';
|
|
15
|
+
\`\`\`
|
|
16
|
+
|
|
17
|
+
## Environments
|
|
18
|
+
|
|
19
|
+
| Environment | Purpose |
|
|
20
|
+
|---|---|
|
|
21
|
+
| \`main\` | The live editing/working copy. Always present. All builder changes apply here. |
|
|
22
|
+
| \`development\` | Internal preview environment. Used for QA before staging. |
|
|
23
|
+
| \`staging\` | Pre-production review. Shown to stakeholders before going live. |
|
|
24
|
+
| \`production\` | The public-facing live site. Published from \`main\` when changes are ready. |
|
|
25
|
+
|
|
26
|
+
## Key Behaviors
|
|
27
|
+
|
|
28
|
+
- **All builder operations target \`main\`** unless explicitly scoped to another environment.
|
|
29
|
+
- Publishing copies the \`main\` schema/style to the target environment (e.g. \`production\`).
|
|
30
|
+
- Each environment can have a different domain and CDN deployment.
|
|
31
|
+
- Segments are also versioned per environment.
|
|
32
|
+
|
|
33
|
+
## In API and Tools
|
|
34
|
+
|
|
35
|
+
Most MCP tools accept an \`environment\` parameter (defaults to \`main\`) that scopes the read/write operation:
|
|
36
|
+
|
|
37
|
+
\`\`\`typescript
|
|
38
|
+
// Example: get schema for the staging environment
|
|
39
|
+
getSchema({ environment: 'staging' })
|
|
40
|
+
\`\`\`
|
|
41
|
+
|
|
42
|
+
## AI Context
|
|
43
|
+
|
|
44
|
+
The \`AiContext.environment\` field tells the AI agent which environment the current session is operating in. This affects which schema/style data is read and which changes are applied.
|
|
45
|
+
`
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { environmentResource };
|