@plitzi/sdk-server 0.32.4 → 0.32.5
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 +9 -0
- package/dist/adapters/jsonAdapters.js +6 -1
- package/dist/core/createServer.js +8 -44
- package/dist/core/health.js +15 -0
- package/dist/core/http/dispatcher.js +29 -0
- package/dist/core/http/securityHeaders.js +15 -0
- package/dist/core/http/stages/authRoutes.js +41 -0
- package/dist/core/http/stages/health.js +12 -0
- package/dist/core/http/stages/middlewares.js +16 -0
- package/dist/core/http/stages/pluginAssets.js +20 -0
- package/dist/core/http/stages/static.js +30 -0
- package/dist/core/server/baseServer.js +29 -0
- package/dist/core/server/mcpServer.js +29 -0
- package/dist/core/server/ssrServer.js +54 -0
- package/dist/core/services/mcp.js +22 -0
- package/dist/core/services/preview.js +37 -0
- package/dist/core/services/registry.js +30 -0
- package/dist/core/services/resolve.js +12 -0
- package/dist/core/services/rsc.js +11 -0
- package/dist/core/services/ssr.js +13 -0
- package/dist/core/transports.js +9 -9
- package/dist/index.js +19 -6
- package/dist/modules/ai/AIEngine.js +4 -4
- package/dist/modules/ai/toolkit.js +58 -0
- package/dist/modules/mcp/constants.js +4 -0
- package/dist/modules/mcp/handler.js +15 -21
- package/dist/modules/mcp/helpers/computeVersion.js +16 -0
- package/dist/modules/mcp/helpers/guide.js +130 -0
- package/dist/modules/mcp/helpers/opResult.js +18 -0
- package/dist/modules/mcp/helpers/space.js +137 -0
- package/dist/modules/mcp/previewClient.js +31 -0
- package/dist/modules/mcp/resources/canonical.js +45 -0
- package/dist/modules/mcp/resources/core.js +14 -0
- package/dist/modules/mcp/resources/envelope.js +14 -0
- package/dist/modules/mcp/resources/primer.js +25 -0
- package/dist/modules/mcp/resources/register.js +142 -0
- package/dist/modules/mcp/resources/router.js +25 -0
- package/dist/modules/mcp/resources/schema.js +33 -0
- package/dist/modules/mcp/resources/style.js +27 -0
- package/dist/modules/mcp/screenshotClient.js +47 -0
- package/dist/modules/mcp/server.js +52 -20
- package/dist/modules/mcp/tools/apply/dispatch.js +83 -0
- package/dist/modules/mcp/tools/apply/index.js +121 -0
- package/dist/modules/mcp/tools/apply/writeResult.js +36 -0
- package/dist/modules/mcp/tools/index.js +20 -148
- package/dist/modules/mcp/tools/operations/index.js +30 -0
- package/dist/modules/mcp/tools/operations/schema/deleteElement.js +25 -0
- package/dist/modules/mcp/tools/operations/schema/deleteFolder.js +30 -0
- package/dist/modules/mcp/tools/operations/schema/deletePage.js +22 -0
- package/dist/modules/mcp/tools/operations/schema/deleteVariable.js +18 -0
- package/dist/modules/mcp/tools/operations/schema/moveElement.js +39 -0
- package/dist/modules/mcp/tools/operations/schema/operations.js +25 -0
- package/dist/modules/mcp/tools/operations/schema/patchElement.js +46 -0
- package/dist/modules/mcp/tools/operations/schema/registry.js +55 -0
- package/dist/modules/mcp/tools/operations/schema/shared.js +27 -0
- package/dist/modules/mcp/tools/operations/schema/translator.js +148 -0
- package/dist/modules/mcp/tools/operations/schema/upsertElement.js +59 -0
- package/dist/modules/mcp/tools/operations/schema/upsertFolder.js +49 -0
- package/dist/modules/mcp/tools/operations/schema/upsertPage.js +64 -0
- package/dist/modules/mcp/tools/operations/schema/upsertVariable.js +42 -0
- package/dist/modules/mcp/tools/operations/schema/write.js +44 -0
- package/dist/modules/mcp/tools/operations/style/cssCatalog.js +132 -0
- package/dist/modules/mcp/tools/operations/style/deleteDefinition.js +20 -0
- package/dist/modules/mcp/tools/operations/style/deleteGlobalStyle.js +20 -0
- package/dist/modules/mcp/tools/operations/style/deleteStyleVariable.js +21 -0
- package/dist/modules/mcp/tools/operations/style/operations.js +21 -0
- package/dist/modules/mcp/tools/operations/style/patchDefinition.js +27 -0
- package/dist/modules/mcp/tools/operations/style/patchGlobalStyle.js +27 -0
- package/dist/modules/mcp/tools/operations/style/shared.js +59 -0
- package/dist/modules/mcp/tools/operations/style/translator.js +77 -0
- package/dist/modules/mcp/tools/operations/style/upsertDefinition.js +23 -0
- package/dist/modules/mcp/tools/operations/style/upsertGlobalStyle.js +23 -0
- package/dist/modules/mcp/tools/operations/style/upsertStyleVariable.js +22 -0
- package/dist/modules/mcp/tools/operations/style/write.js +100 -0
- package/dist/modules/mcp/tools/preview.js +37 -0
- package/dist/modules/mcp/tools/read.js +33 -0
- package/dist/modules/mcp/tools/screenshot.js +83 -0
- package/dist/modules/mcp/tools/search.js +108 -0
- package/dist/modules/mcp/tools/shared/tool.js +26 -0
- package/dist/modules/mcp/tools/shared/validator.js +262 -0
- package/dist/modules/mcp/tools/validate.js +19 -0
- package/dist/modules/ssr/buildBody.js +2 -2
- package/dist/modules/ssr/handler.js +6 -4
- package/dist/modules/ssr/prepareRender.js +5 -5
- package/dist/modules/ssr/preview.js +106 -0
- package/dist/modules/ssr/registerExternalPlugins.js +1 -1
- package/dist/modules/ssr/streamBody.js +3 -3
- package/dist/modules/ssr/template.js +1 -1
- package/dist/plugins/compile.js +1 -1
- package/dist/plugins/copy.js +1 -1
- package/dist/plugins/manager.js +1 -1
- package/dist/server.js +34 -9
- package/dist/src/core/createServer.d.ts +5 -1
- package/dist/src/core/health.d.ts +10 -0
- package/dist/src/core/http/dispatcher.d.ts +7 -0
- package/dist/src/core/http/securityHeaders.d.ts +2 -0
- package/dist/src/core/http/stages/authRoutes.d.ts +4 -0
- package/dist/src/core/http/stages/health.d.ts +2 -0
- package/dist/src/core/http/stages/middlewares.d.ts +2 -0
- package/dist/src/core/http/stages/pluginAssets.d.ts +2 -0
- package/dist/src/core/http/stages/static.d.ts +5 -0
- package/dist/src/core/http/types.d.ts +19 -0
- package/dist/src/core/server/baseServer.d.ts +9 -0
- package/dist/src/core/server/mcpServer.d.ts +2 -0
- package/dist/src/core/server/ssrServer.d.ts +2 -0
- package/dist/src/core/services/mcp.d.ts +3 -0
- package/dist/src/core/services/preview.d.ts +2 -0
- package/dist/src/core/services/registry.d.ts +4 -0
- package/dist/src/core/services/resolve.d.ts +3 -0
- package/dist/src/core/services/rsc.d.ts +2 -0
- package/dist/src/core/services/ssr.d.ts +3 -0
- package/dist/src/core/transports.d.ts +2 -2
- package/dist/src/index.d.ts +12 -3
- package/dist/src/modules/ai/index.d.ts +1 -0
- package/dist/src/modules/ai/toolkit.d.ts +17 -0
- package/dist/src/modules/mcp/constants.d.ts +1 -0
- package/dist/src/modules/mcp/handler.d.ts +6 -3
- package/dist/src/modules/mcp/helpers/computeVersion.d.ts +1 -0
- package/dist/src/modules/mcp/helpers/guide.d.ts +2 -0
- package/dist/src/modules/mcp/helpers/index.d.ts +4 -0
- package/dist/src/modules/mcp/helpers/opResult.d.ts +13 -0
- package/dist/src/modules/mcp/helpers/space.d.ts +49 -0
- package/dist/src/modules/mcp/index.d.ts +12 -5
- package/dist/src/modules/mcp/previewClient.d.ts +13 -0
- package/dist/src/modules/mcp/resources/canonical.d.ts +7 -0
- package/dist/src/modules/mcp/resources/core.d.ts +5 -0
- package/dist/src/modules/mcp/resources/envelope.d.ts +10 -0
- package/dist/src/modules/mcp/resources/index.d.ts +8 -10
- package/dist/src/modules/mcp/resources/primer.d.ts +6 -0
- package/dist/src/modules/mcp/resources/register.d.ts +6 -0
- package/dist/src/modules/mcp/resources/router.d.ts +6 -0
- package/dist/src/modules/mcp/resources/schema.d.ts +5 -0
- package/dist/src/modules/mcp/resources/style.d.ts +5 -0
- package/dist/src/modules/mcp/screenshotClient.d.ts +13 -0
- package/dist/src/modules/mcp/server.d.ts +18 -3
- package/dist/src/modules/mcp/tools/apply/dispatch.d.ts +6 -0
- package/dist/src/modules/mcp/tools/apply/index.d.ts +231 -0
- package/dist/src/modules/mcp/tools/apply/writeResult.d.ts +8 -0
- package/dist/src/modules/mcp/tools/index.d.ts +17 -6
- package/dist/src/modules/mcp/tools/operations/index.d.ts +449 -0
- package/dist/src/modules/mcp/tools/operations/schema/deleteElement.d.ts +10 -0
- package/dist/src/modules/mcp/tools/operations/schema/deleteFolder.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/schema/deletePage.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/schema/deleteVariable.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/schema/index.d.ts +14 -0
- package/dist/src/modules/mcp/tools/operations/schema/moveElement.d.ts +16 -0
- package/dist/src/modules/mcp/tools/operations/schema/operations.d.ts +79 -0
- package/dist/src/modules/mcp/tools/operations/schema/patchElement.d.ts +17 -0
- package/dist/src/modules/mcp/tools/operations/schema/registry.d.ts +22 -0
- package/dist/src/modules/mcp/tools/operations/schema/shared.d.ts +24 -0
- package/dist/src/modules/mcp/tools/operations/schema/translator.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/schema/upsertElement.d.ts +16 -0
- package/dist/src/modules/mcp/tools/operations/schema/upsertFolder.d.ts +12 -0
- package/dist/src/modules/mcp/tools/operations/schema/upsertPage.d.ts +13 -0
- package/dist/src/modules/mcp/tools/operations/schema/upsertVariable.d.ts +16 -0
- package/dist/src/modules/mcp/tools/operations/schema/write.d.ts +12 -0
- package/dist/src/modules/mcp/tools/operations/style/cssCatalog.d.ts +10 -0
- package/dist/src/modules/mcp/tools/operations/style/deleteDefinition.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/style/deleteGlobalStyle.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/style/deleteStyleVariable.d.ts +15 -0
- package/dist/src/modules/mcp/tools/operations/style/index.d.ts +12 -0
- package/dist/src/modules/mcp/tools/operations/style/operations.d.ts +163 -0
- package/dist/src/modules/mcp/tools/operations/style/patchDefinition.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/patchGlobalStyle.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/shared.d.ts +115 -0
- package/dist/src/modules/mcp/tools/operations/style/translator.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/style/upsertDefinition.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/upsertGlobalStyle.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/upsertStyleVariable.d.ts +20 -0
- package/dist/src/modules/mcp/tools/operations/style/write.d.ts +17 -0
- package/dist/src/modules/mcp/tools/preview.d.ts +226 -0
- package/dist/src/modules/mcp/tools/read.d.ts +8 -0
- package/dist/src/modules/mcp/tools/screenshot.d.ts +231 -0
- package/dist/src/modules/mcp/tools/search.d.ts +15 -0
- package/dist/src/modules/mcp/tools/shared/tool.d.ts +50 -0
- package/dist/src/modules/mcp/tools/shared/validator.d.ts +4 -0
- package/dist/src/modules/mcp/tools/validate.d.ts +228 -0
- package/dist/src/modules/mcp/types/aiSchema.d.ts +126 -0
- package/dist/src/modules/mcp/types/index.d.ts +4 -0
- package/dist/src/modules/mcp/types/previewTypes.d.ts +25 -0
- package/dist/src/modules/mcp/types/screenshotTypes.d.ts +29 -0
- package/dist/src/modules/mcp/types/toolTypes.d.ts +138 -0
- package/dist/src/modules/ssr/buildBody.d.ts +2 -2
- package/dist/src/modules/ssr/prepareRender.d.ts +2 -2
- package/dist/src/modules/ssr/preview.d.ts +16 -0
- package/dist/src/modules/ssr/streamBody.d.ts +2 -2
- package/package.json +10 -10
- package/dist/_virtual/_rolldown/runtime.js +0 -13
- package/dist/core/requestHandler.js +0 -126
- package/dist/modules/mcp/helpers.js +0 -75
- package/dist/modules/mcp/resources/glossary/binding.js +0 -73
- package/dist/modules/mcp/resources/glossary/collection.js +0 -76
- package/dist/modules/mcp/resources/glossary/displayMode.js +0 -50
- package/dist/modules/mcp/resources/glossary/element.js +0 -68
- package/dist/modules/mcp/resources/glossary/environment.js +0 -48
- package/dist/modules/mcp/resources/glossary/interaction.js +0 -62
- package/dist/modules/mcp/resources/glossary/page.js +0 -70
- package/dist/modules/mcp/resources/glossary/plugin.js +0 -96
- package/dist/modules/mcp/resources/glossary/resource.js +0 -75
- package/dist/modules/mcp/resources/glossary/schema.js +0 -69
- package/dist/modules/mcp/resources/glossary/schemaVariable.js +0 -60
- package/dist/modules/mcp/resources/glossary/segment.js +0 -59
- package/dist/modules/mcp/resources/glossary/space.js +0 -73
- package/dist/modules/mcp/resources/glossary/style.js +0 -81
- package/dist/modules/mcp/resources/glossary/styleSelector.js +0 -77
- package/dist/modules/mcp/resources/glossary/styleVariable.js +0 -72
- package/dist/modules/mcp/resources/index.js +0 -71
- package/dist/modules/mcp/resources/workflows/data.js +0 -49
- package/dist/modules/mcp/resources/workflows/elements.js +0 -53
- package/dist/modules/mcp/resources/workflows/segments.js +0 -55
- package/dist/modules/mcp/resources/workflows/styles.js +0 -91
- package/dist/modules/mcp/tools/collections/createCollection.js +0 -25
- package/dist/modules/mcp/tools/collections/createCollectionRecord.js +0 -27
- package/dist/modules/mcp/tools/collections/deleteCollection.js +0 -16
- package/dist/modules/mcp/tools/collections/deleteCollectionRecord.js +0 -16
- package/dist/modules/mcp/tools/collections/getCollection.js +0 -21
- package/dist/modules/mcp/tools/collections/getCollectionRecord.js +0 -25
- package/dist/modules/mcp/tools/collections/getCollectionRecords.js +0 -29
- package/dist/modules/mcp/tools/collections/getCollections.js +0 -19
- package/dist/modules/mcp/tools/collections/updateCollection.js +0 -28
- package/dist/modules/mcp/tools/collections/updateCollectionRecord.js +0 -31
- package/dist/modules/mcp/tools/docs/listResources.js +0 -16
- package/dist/modules/mcp/tools/docs/readResource.js +0 -23
- package/dist/modules/mcp/tools/plugins/addPlugin.js +0 -24
- package/dist/modules/mcp/tools/plugins/listPlugins.js +0 -20
- package/dist/modules/mcp/tools/plugins/removePlugin.js +0 -16
- package/dist/modules/mcp/tools/plugins/updatePlugin.js +0 -23
- package/dist/modules/mcp/tools/resources/addResource.js +0 -33
- package/dist/modules/mcp/tools/resources/getResource.js +0 -29
- package/dist/modules/mcp/tools/resources/getResources.js +0 -27
- package/dist/modules/mcp/tools/resources/moveResource.js +0 -30
- package/dist/modules/mcp/tools/resources/removeResource.js +0 -19
- package/dist/modules/mcp/tools/segment/createSegment.js +0 -27
- package/dist/modules/mcp/tools/segment/deleteSegment.js +0 -16
- package/dist/modules/mcp/tools/segment/getSegment.js +0 -19
- package/dist/modules/mcp/tools/segment/getSegments.js +0 -27
- package/dist/modules/mcp/tools/segment/schema/elements/createSegmentElement.js +0 -24
- package/dist/modules/mcp/tools/segment/schema/elements/deleteSegmentElement.js +0 -19
- package/dist/modules/mcp/tools/segment/schema/elements/moveSegmentElement.js +0 -28
- package/dist/modules/mcp/tools/segment/schema/elements/updateSegmentElement.js +0 -23
- package/dist/modules/mcp/tools/segment/schema/variables/createSegmentVariable.js +0 -41
- package/dist/modules/mcp/tools/segment/schema/variables/deleteSegmentVariable.js +0 -19
- package/dist/modules/mcp/tools/segment/schema/variables/updateSegmentVariable.js +0 -41
- package/dist/modules/mcp/tools/segment/style/variables/createSegmentStyleVariable.js +0 -34
- package/dist/modules/mcp/tools/segment/style/variables/deleteSegmentStyleVariable.js +0 -21
- package/dist/modules/mcp/tools/segment/style/variables/updateSegmentStyleVariable.js +0 -34
- package/dist/modules/mcp/tools/segment/updateSegment.js +0 -30
- package/dist/modules/mcp/tools/space/schema/applyPreview.js +0 -33
- package/dist/modules/mcp/tools/space/schema/elements/cloneElement.js +0 -34
- package/dist/modules/mcp/tools/space/schema/elements/createElement.js +0 -50
- package/dist/modules/mcp/tools/space/schema/elements/deleteElement.js +0 -16
- package/dist/modules/mcp/tools/space/schema/elements/getElement.js +0 -17
- package/dist/modules/mcp/tools/space/schema/elements/getElements.js +0 -21
- package/dist/modules/mcp/tools/space/schema/elements/listElements.js +0 -28
- package/dist/modules/mcp/tools/space/schema/elements/moveElement.js +0 -27
- package/dist/modules/mcp/tools/space/schema/elements/updateElement.js +0 -49
- package/dist/modules/mcp/tools/space/schema/getSpaceSettings.js +0 -46
- package/dist/modules/mcp/tools/space/schema/pageFolders/createPageFolder.js +0 -24
- package/dist/modules/mcp/tools/space/schema/pageFolders/deletePageFolder.js +0 -16
- package/dist/modules/mcp/tools/space/schema/pageFolders/getPageFolder.js +0 -17
- package/dist/modules/mcp/tools/space/schema/pageFolders/getPageFolders.js +0 -17
- package/dist/modules/mcp/tools/space/schema/pageFolders/updatePageFolder.js +0 -28
- package/dist/modules/mcp/tools/space/schema/pages/createPage.js +0 -37
- package/dist/modules/mcp/tools/space/schema/pages/deletePage.js +0 -16
- package/dist/modules/mcp/tools/space/schema/pages/getPage.js +0 -28
- package/dist/modules/mcp/tools/space/schema/pages/getPageBySlug.js +0 -17
- package/dist/modules/mcp/tools/space/schema/pages/getPages.js +0 -17
- package/dist/modules/mcp/tools/space/schema/pages/updatePage.js +0 -25
- package/dist/modules/mcp/tools/space/schema/schemas.js +0 -53
- package/dist/modules/mcp/tools/space/schema/updateSpaceSettings.js +0 -23
- package/dist/modules/mcp/tools/space/schema/variables/createVariable.js +0 -38
- package/dist/modules/mcp/tools/space/schema/variables/deleteVariable.js +0 -16
- package/dist/modules/mcp/tools/space/schema/variables/getVariable.js +0 -17
- package/dist/modules/mcp/tools/space/schema/variables/getVariables.js +0 -17
- package/dist/modules/mcp/tools/space/schema/variables/updateVariable.js +0 -38
- package/dist/modules/mcp/tools/space/style/selectors/createStyleSelector.js +0 -37
- package/dist/modules/mcp/tools/space/style/selectors/deleteStyleSelector.js +0 -24
- package/dist/modules/mcp/tools/space/style/selectors/getStyleSelectors.js +0 -20
- package/dist/modules/mcp/tools/space/style/selectors/updateStyleSelector.js +0 -37
- package/dist/modules/mcp/tools/space/style/variables/createStyleVariable.js +0 -33
- package/dist/modules/mcp/tools/space/style/variables/deleteStyleVariable.js +0 -20
- package/dist/modules/mcp/tools/space/style/variables/getStyleVariable.js +0 -19
- package/dist/modules/mcp/tools/space/style/variables/getStyleVariables.js +0 -16
- package/dist/modules/mcp/tools/space/style/variables/updateStyleVariable.js +0 -33
- package/dist/package.js +0 -77
- package/dist/package.json.d.ts +0 -67
- package/dist/src/core/requestHandler.d.ts +0 -5
- package/dist/src/modules/mcp/helpers.d.ts +0 -9
- package/dist/src/modules/mcp/resources/glossary/binding.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/collection.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/displayMode.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/element.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/environment.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/interaction.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/page.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/plugin.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/resource.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/schema.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/schemaVariable.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/segment.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/space.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/style.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/styleSelector.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/styleVariable.d.ts +0 -7
- package/dist/src/modules/mcp/resources/workflows/data.d.ts +0 -7
- package/dist/src/modules/mcp/resources/workflows/elements.d.ts +0 -7
- package/dist/src/modules/mcp/resources/workflows/segments.d.ts +0 -7
- package/dist/src/modules/mcp/resources/workflows/styles.d.ts +0 -7
- package/dist/src/modules/mcp/tools/collections/createCollection.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/createCollectionRecord.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/deleteCollection.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/deleteCollectionRecord.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/getCollection.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/getCollectionRecord.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/getCollectionRecords.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/getCollections.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/index.d.ts +0 -10
- package/dist/src/modules/mcp/tools/collections/updateCollection.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/updateCollectionRecord.d.ts +0 -3
- package/dist/src/modules/mcp/tools/docs/index.d.ts +0 -2
- package/dist/src/modules/mcp/tools/docs/listResources.d.ts +0 -3
- package/dist/src/modules/mcp/tools/docs/readResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/plugins/addPlugin.d.ts +0 -3
- package/dist/src/modules/mcp/tools/plugins/index.d.ts +0 -5
- package/dist/src/modules/mcp/tools/plugins/listPlugins.d.ts +0 -3
- package/dist/src/modules/mcp/tools/plugins/removePlugin.d.ts +0 -3
- package/dist/src/modules/mcp/tools/plugins/updatePlugin.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/addResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/getResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/getResources.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/index.d.ts +0 -6
- package/dist/src/modules/mcp/tools/resources/moveResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/removeResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/resources.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/segment/createSegment.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/deleteSegment.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/getSegment.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/getSegments.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/index.d.ts +0 -8
- package/dist/src/modules/mcp/tools/segment/schema/elements/createSegmentElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/elements/deleteSegmentElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/elements/index.d.ts +0 -5
- package/dist/src/modules/mcp/tools/segment/schema/elements/moveSegmentElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/elements/segmentElements.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/segment/schema/elements/updateSegmentElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/index.d.ts +0 -2
- package/dist/src/modules/mcp/tools/segment/schema/variables/createSegmentVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/variables/deleteSegmentVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/variables/index.d.ts +0 -4
- package/dist/src/modules/mcp/tools/segment/schema/variables/segmentVariables.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/segment/schema/variables/updateSegmentVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/segment.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/segment/style/index.d.ts +0 -1
- package/dist/src/modules/mcp/tools/segment/style/variables/createSegmentStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/style/variables/deleteSegmentStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/style/variables/index.d.ts +0 -4
- package/dist/src/modules/mcp/tools/segment/style/variables/segmentStyleVariables.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/segment/style/variables/updateSegmentStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/updateSegment.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/index.d.ts +0 -2
- package/dist/src/modules/mcp/tools/space/schema/applyPreview.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/cloneElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/createElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/deleteElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/elements.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/schema/elements/getElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/getElements.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/index.d.ts +0 -9
- package/dist/src/modules/mcp/tools/space/schema/elements/listElements.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/moveElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/updateElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/getSpaceSettings.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/index.d.ts +0 -8
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/createPageFolder.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/deletePageFolder.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/getPageFolder.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/getPageFolders.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/index.d.ts +0 -6
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/pageFolders.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/updatePageFolder.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/createPage.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/deletePage.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/getPage.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/getPageBySlug.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/getPages.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/index.d.ts +0 -7
- package/dist/src/modules/mcp/tools/space/schema/pages/pages.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/schema/pages/updatePage.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/schemas.d.ts +0 -66
- package/dist/src/modules/mcp/tools/space/schema/updateSpaceSettings.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/createVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/deleteVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/getVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/getVariables.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/index.d.ts +0 -6
- package/dist/src/modules/mcp/tools/space/schema/variables/updateVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/variables.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/space.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/style/index.d.ts +0 -2
- package/dist/src/modules/mcp/tools/space/style/selectors/createStyleSelector.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/selectors/deleteStyleSelector.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/selectors/getStyleSelectors.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/selectors/index.d.ts +0 -5
- package/dist/src/modules/mcp/tools/space/style/selectors/styleSelectors.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/style/selectors/updateStyleSelector.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/createStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/deleteStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/getStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/getStyleVariables.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/index.d.ts +0 -6
- package/dist/src/modules/mcp/tools/space/style/variables/styleVariables.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/style/variables/updateStyleVariable.d.ts +0 -3
- /package/dist/src/{modules/mcp/helpers.test.d.ts → core/server/mcpServer.test.d.ts} +0 -0
- /package/dist/src/modules/{mcp/tools/collections/collections.test.d.ts → ai/toolkit.test.d.ts} +0 -0
- /package/dist/src/modules/mcp/{tools/plugins/plugins.test.d.ts → mcp.test.d.ts} +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { empty } from "../../../helpers/opResult.js";
|
|
2
|
+
import { defUri, defsUri, guardKind, writeStyleItem } from "./write.js";
|
|
3
|
+
import { upsertCssShape } from "./shared.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/modules/mcp/tools/operations/style/upsertDefinition.ts
|
|
6
|
+
var upsertDefinitionOp = z.object({
|
|
7
|
+
type: z.literal("upsertDefinition"),
|
|
8
|
+
ref: z.string().describe("Class name you choose (kebab-case), or an existing class ref to fully replace"),
|
|
9
|
+
...upsertCssShape
|
|
10
|
+
}).describe("Create a reusable style class (CSS), or fully replace it when ref exists. Apply it by attaching ref to an element via its style.base. Use patchDefinition to change only some CSS.");
|
|
11
|
+
var upsertDefinition = (space, env, op) => {
|
|
12
|
+
const { type, ref, slots, ...base } = op;
|
|
13
|
+
const guard = guardKind(space.style, ref, "class");
|
|
14
|
+
if (guard) return guard;
|
|
15
|
+
writeStyleItem(space.style, ref, base, slots, "class", void 0);
|
|
16
|
+
return {
|
|
17
|
+
...empty(),
|
|
18
|
+
updated: 1,
|
|
19
|
+
staleResources: [defUri(env, ref), defsUri(env)]
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { upsertDefinition, upsertDefinitionOp };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { empty } from "../../../helpers/opResult.js";
|
|
2
|
+
import { globalUri, globalsUri, guardKind, writeStyleItem } from "./write.js";
|
|
3
|
+
import { upsertCssShape } from "./shared.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/modules/mcp/tools/operations/style/upsertGlobalStyle.ts
|
|
6
|
+
var upsertGlobalStyleOp = z.object({
|
|
7
|
+
type: z.literal("upsertGlobalStyle"),
|
|
8
|
+
componentType: z.string().describe("Element type to style site-wide (e.g. \"button\"); affects ALL of that type"),
|
|
9
|
+
...upsertCssShape
|
|
10
|
+
}).describe("Create or fully replace the site-wide style for an element TYPE — its CSS applies to every element of that type. To style one element only, use upsertDefinition + attach it. Use patchGlobalStyle for a partial change.");
|
|
11
|
+
var upsertGlobalStyle = (space, env, op) => {
|
|
12
|
+
const { type, componentType, slots, ...base } = op;
|
|
13
|
+
const guard = guardKind(space.style, componentType, "element");
|
|
14
|
+
if (guard) return guard;
|
|
15
|
+
writeStyleItem(space.style, componentType, base, slots, "element", componentType);
|
|
16
|
+
return {
|
|
17
|
+
...empty(),
|
|
18
|
+
updated: 1,
|
|
19
|
+
staleResources: [globalUri(env, componentType), globalsUri(env)]
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { upsertGlobalStyle, upsertGlobalStyleOp };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { empty } from "../../../helpers/opResult.js";
|
|
2
|
+
import { styleVarUri, styleVarsUri } from "./write.js";
|
|
3
|
+
import { styleCategory, themeValue } from "./shared.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/modules/mcp/tools/operations/style/upsertStyleVariable.ts
|
|
6
|
+
var upsertStyleVariableOp = z.object({
|
|
7
|
+
type: z.literal("upsertStyleVariable"),
|
|
8
|
+
category: styleCategory,
|
|
9
|
+
name: z.string().describe("Token name without the -- prefix; referenced in CSS as var(--name)"),
|
|
10
|
+
value: themeValue
|
|
11
|
+
}).describe("Create or update a design token (referenced in CSS as var(--name); value may differ per light/dark).");
|
|
12
|
+
var upsertStyleVariable = (space, env, op) => {
|
|
13
|
+
const group = space.style.variables[op.category] ??= {};
|
|
14
|
+
group[op.name] = op.value;
|
|
15
|
+
return {
|
|
16
|
+
...empty(),
|
|
17
|
+
updated: 1,
|
|
18
|
+
staleResources: [styleVarUri(env, op.category), styleVarsUri(env)]
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { upsertStyleVariable, upsertStyleVariableOp };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { fail } from "../../../helpers/opResult.js";
|
|
2
|
+
import { expandShorthand } from "./cssCatalog.js";
|
|
3
|
+
import processSelector from "@plitzi/sdk-style/helpers/processSelector";
|
|
4
|
+
//#region src/modules/mcp/tools/operations/style/write.ts
|
|
5
|
+
var MODES = [
|
|
6
|
+
"desktop",
|
|
7
|
+
"tablet",
|
|
8
|
+
"mobile"
|
|
9
|
+
];
|
|
10
|
+
var defUri = (env, ref) => `plitzi://definitions/${env}/${ref}`;
|
|
11
|
+
var defsUri = (env) => `plitzi://definitions/${env}`;
|
|
12
|
+
var globalUri = (env, componentType) => `plitzi://global-styles/${env}/${componentType}`;
|
|
13
|
+
var globalsUri = (env) => `plitzi://global-styles/${env}`;
|
|
14
|
+
var styleVarUri = (env, category) => `plitzi://style-variables/${env}/${category}`;
|
|
15
|
+
var styleVarsUri = (env) => `plitzi://style-variables/${env}`;
|
|
16
|
+
var describeKind = (item) => item.type === "element" ? `a global style for every "${item.componentType}" element` : item.type === "class" ? "a reusable class definition" : "an id rule";
|
|
17
|
+
var guardKind = (style, ref, want) => {
|
|
18
|
+
const clash = MODES.map((mode) => style.platform[mode][ref]).find((item) => item !== void 0 && item.type !== want);
|
|
19
|
+
if (!clash) return null;
|
|
20
|
+
const wantIsClass = want === "class";
|
|
21
|
+
return fail(wantIsClass ? "ref" : "componentType", `"${ref}" is already ${describeKind(clash)}; it cannot be edited as ${wantIsClass ? "a class definition" : "a global element style"}`, wantIsClass ? "To restyle every element of a type on purpose, use upsertGlobalStyle/patchGlobalStyle with its componentType. Otherwise pick a different class name." : "That name is a class definition — edit it with upsertDefinition/patchDefinition, or choose a different componentType.");
|
|
22
|
+
};
|
|
23
|
+
var slotToBlocks = (slot) => {
|
|
24
|
+
const perMode = {};
|
|
25
|
+
for (const mode of MODES) {
|
|
26
|
+
const block = {};
|
|
27
|
+
const baseCss = slot[mode];
|
|
28
|
+
if (baseCss && Object.keys(baseCss).length > 0) block.default = expandShorthand(baseCss);
|
|
29
|
+
for (const [state, dm] of Object.entries(slot.states ?? {})) if (dm[mode]) (block.states ??= {})[state] = expandShorthand(dm[mode]);
|
|
30
|
+
for (const [name, dm] of Object.entries(slot.variants ?? {})) if (dm[mode]) (block.variants ??= {})[name] = { default: expandShorthand(dm[mode]) };
|
|
31
|
+
if (Object.keys(block).length > 0) perMode[mode] = block;
|
|
32
|
+
}
|
|
33
|
+
return perMode;
|
|
34
|
+
};
|
|
35
|
+
var writeStyleItem = (style, ref, base, slots, itemType, componentType) => {
|
|
36
|
+
for (const mode of MODES) {
|
|
37
|
+
const attributes = {};
|
|
38
|
+
const baseBlocks = slotToBlocks(base);
|
|
39
|
+
if (baseBlocks[mode]) attributes.base = baseBlocks[mode];
|
|
40
|
+
for (const [slotName, slotDef] of Object.entries(slots ?? {})) {
|
|
41
|
+
const blocks = slotToBlocks(slotDef);
|
|
42
|
+
if (blocks[mode]) attributes[slotName] = blocks[mode];
|
|
43
|
+
}
|
|
44
|
+
if (Object.keys(attributes).length === 0) Reflect.deleteProperty(style.platform[mode], ref);
|
|
45
|
+
else {
|
|
46
|
+
const styleItem = {
|
|
47
|
+
name: ref,
|
|
48
|
+
type: itemType,
|
|
49
|
+
attributes,
|
|
50
|
+
cache: ""
|
|
51
|
+
};
|
|
52
|
+
if (componentType !== void 0) styleItem.componentType = componentType;
|
|
53
|
+
styleItem.cache = processSelector(styleItem);
|
|
54
|
+
style.platform[mode][ref] = styleItem;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var mergeCss = (base, patch) => {
|
|
59
|
+
const merged = { ...base };
|
|
60
|
+
for (const [key, value] of Object.entries(patch ?? {})) if (value === null) Reflect.deleteProperty(merged, key);
|
|
61
|
+
else merged[key] = value;
|
|
62
|
+
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
63
|
+
};
|
|
64
|
+
var mergeDisplayMode = (base, patch) => {
|
|
65
|
+
const result = {};
|
|
66
|
+
for (const mode of MODES) {
|
|
67
|
+
const css = mergeCss(base?.[mode], patch?.[mode]);
|
|
68
|
+
if (css) result[mode] = css;
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
};
|
|
72
|
+
var mergeNamedModes = (base, patch) => {
|
|
73
|
+
const names = /* @__PURE__ */ new Set([...Object.keys(base ?? {}), ...Object.keys(patch ?? {})]);
|
|
74
|
+
const result = {};
|
|
75
|
+
for (const name of names) {
|
|
76
|
+
const dm = mergeDisplayMode(base?.[name], patch?.[name]);
|
|
77
|
+
if (Object.keys(dm).length > 0) result[name] = dm;
|
|
78
|
+
}
|
|
79
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
80
|
+
};
|
|
81
|
+
var mergeSlot = (base, patch) => {
|
|
82
|
+
const merged = mergeDisplayMode(base, patch);
|
|
83
|
+
const states = mergeNamedModes(base?.states, patch.states);
|
|
84
|
+
if (states) merged.states = states;
|
|
85
|
+
const variants = mergeNamedModes(base?.variants, patch.variants);
|
|
86
|
+
if (variants) merged.variants = variants;
|
|
87
|
+
return merged;
|
|
88
|
+
};
|
|
89
|
+
var mergePatch = (existing, basePatch, slotsPatch) => {
|
|
90
|
+
const base = mergeSlot(existing, basePatch);
|
|
91
|
+
const slotNames = /* @__PURE__ */ new Set([...Object.keys(existing.slots ?? {}), ...Object.keys(slotsPatch ?? {})]);
|
|
92
|
+
const slots = {};
|
|
93
|
+
for (const name of slotNames) slots[name] = mergeSlot(existing.slots?.[name], slotsPatch?.[name] ?? {});
|
|
94
|
+
return {
|
|
95
|
+
base,
|
|
96
|
+
slots: Object.keys(slots).length > 0 ? slots : void 0
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
//#endregion
|
|
100
|
+
export { MODES, defUri, defsUri, globalUri, globalsUri, guardKind, mergePatch, styleVarUri, styleVarsUri, writeStyleItem };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { operation } from "./operations/index.js";
|
|
2
|
+
import { defineTool } from "./shared/tool.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/modules/mcp/tools/preview.ts
|
|
5
|
+
var previewShape = {
|
|
6
|
+
pageRef: z.string().optional().describe("Page ref or id to preview; defaults to the space default page"),
|
|
7
|
+
operations: z.array(operation).max(100).optional().describe("Unsaved edits to apply to a throwaway clone before rendering, so you can preview a change WITHOUT persisting it (same op vocabulary as plitzi_apply). Omit to preview the current saved state.")
|
|
8
|
+
};
|
|
9
|
+
var previewTool = defineTool({
|
|
10
|
+
name: "plitzi_preview",
|
|
11
|
+
title: "Preview (HTML)",
|
|
12
|
+
description: "Render a page to a full HTML document to inspect the structure of your edits. Pass unsaved `operations` to preview a change before committing (nothing is persisted). Returns the HTML plus the page path and stateVersion. For a real rendered IMAGE that reveals visual issues like overflow, use plitzi_screenshot.",
|
|
13
|
+
inputShape: previewShape,
|
|
14
|
+
access: "read",
|
|
15
|
+
run: async (input, ctx) => {
|
|
16
|
+
if (!ctx.preview || ctx.spaceId === void 0) return {
|
|
17
|
+
error: "PREVIEW_UNAVAILABLE",
|
|
18
|
+
message: "Visual preview is not enabled on this server.",
|
|
19
|
+
hint: "Preview needs the SSR render service; it is unavailable in MCP-only mode."
|
|
20
|
+
};
|
|
21
|
+
const result = await ctx.preview.render({
|
|
22
|
+
spaceId: ctx.spaceId,
|
|
23
|
+
env: ctx.env,
|
|
24
|
+
pageRef: input.pageRef,
|
|
25
|
+
operations: input.operations
|
|
26
|
+
});
|
|
27
|
+
if (!result.ok) return result;
|
|
28
|
+
return {
|
|
29
|
+
pageRef: input.pageRef ?? "default",
|
|
30
|
+
pagePath: result.pagePath,
|
|
31
|
+
stateVersion: result.stateVersion,
|
|
32
|
+
html: result.html
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
//#endregion
|
|
37
|
+
export { previewShape, previewTool };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { resourceErrorMessage } from "../resources/canonical.js";
|
|
2
|
+
import { readResource } from "../resources/router.js";
|
|
3
|
+
import { defineTool } from "./shared/tool.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/modules/mcp/tools/read.ts
|
|
6
|
+
var readShape = { uris: z.array(z.string()).min(1).max(50).describe("Resource URIs to read in one batch (max 50). Use the ready-made uris from search / write responses.") };
|
|
7
|
+
var read = (input, space, env) => {
|
|
8
|
+
return { results: input.uris.map((uri) => {
|
|
9
|
+
const found = readResource(space, env, uri);
|
|
10
|
+
if (found) return {
|
|
11
|
+
uri,
|
|
12
|
+
stateVersion: found.stateVersion,
|
|
13
|
+
data: found.data
|
|
14
|
+
};
|
|
15
|
+
const parsed = JSON.parse(resourceErrorMessage(env, uri));
|
|
16
|
+
return {
|
|
17
|
+
uri,
|
|
18
|
+
error: parsed.error,
|
|
19
|
+
message: parsed.message,
|
|
20
|
+
hint: parsed.hint
|
|
21
|
+
};
|
|
22
|
+
}) };
|
|
23
|
+
};
|
|
24
|
+
var readTool = defineTool({
|
|
25
|
+
name: "plitzi_read",
|
|
26
|
+
title: "Batch read",
|
|
27
|
+
description: "Read MANY resources at once by URI — the batch alternative to opening resources one by one. Pass an array of URIs (pages, elements, definitions, variables), e.g. the ready-made uris from plitzi_search or a write response, and get them all back in a single call instead of one read per URI. Each result is { uri, stateVersion, data } or a teachable error, so one bad URI never fails the batch.",
|
|
28
|
+
inputShape: readShape,
|
|
29
|
+
access: "read",
|
|
30
|
+
run: (input, ctx) => read(input, ctx.space, ctx.env)
|
|
31
|
+
});
|
|
32
|
+
//#endregion
|
|
33
|
+
export { read, readShape, readTool };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { operation } from "./operations/index.js";
|
|
2
|
+
import { defineTool, imageResult } from "./shared/tool.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/modules/mcp/tools/screenshot.ts
|
|
5
|
+
var VIEWPORTS = {
|
|
6
|
+
desktop: {
|
|
7
|
+
label: "desktop",
|
|
8
|
+
width: 1440,
|
|
9
|
+
height: 900
|
|
10
|
+
},
|
|
11
|
+
mobile: {
|
|
12
|
+
label: "mobile",
|
|
13
|
+
width: 390,
|
|
14
|
+
height: 844
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var resolveViewports = (choice) => {
|
|
18
|
+
if (choice === "both") return [VIEWPORTS.desktop, VIEWPORTS.mobile];
|
|
19
|
+
if (choice === "mobile") return [VIEWPORTS.mobile];
|
|
20
|
+
return [VIEWPORTS.desktop];
|
|
21
|
+
};
|
|
22
|
+
var screenshotShape = {
|
|
23
|
+
pageRef: z.string().optional().describe("Page ref or id to capture; defaults to the space default page"),
|
|
24
|
+
operations: z.array(operation).max(100).optional().describe("Unsaved edits to apply before rendering, so you can screenshot a proposed change WITHOUT persisting it (same op vocabulary as plitzi_apply). Omit to capture the current saved state."),
|
|
25
|
+
viewport: z.enum([
|
|
26
|
+
"desktop",
|
|
27
|
+
"mobile",
|
|
28
|
+
"both"
|
|
29
|
+
]).optional().describe("Which viewport(s) to capture. \"both\" catches responsive issues (e.g. overflow at one width). Default desktop.")
|
|
30
|
+
};
|
|
31
|
+
var screenshotTool = defineTool({
|
|
32
|
+
name: "plitzi_screenshot",
|
|
33
|
+
title: "Screenshot",
|
|
34
|
+
description: "Render a page to a real PNG image so you can SEE the visual result of your edits — overflow, misalignment and broken layout that data alone never reveals. Pass unsaved `operations` to screenshot a proposed change before committing, and viewport \"both\" to compare desktop and mobile. Returns the image(s).",
|
|
35
|
+
inputShape: screenshotShape,
|
|
36
|
+
access: "read",
|
|
37
|
+
requires: "screenshot",
|
|
38
|
+
run: async (input, ctx) => {
|
|
39
|
+
if (!ctx.preview || ctx.spaceId === void 0) return {
|
|
40
|
+
error: "PREVIEW_UNAVAILABLE",
|
|
41
|
+
message: "Visual preview is not enabled on this server.",
|
|
42
|
+
hint: "Preview needs the SSR render service; it is unavailable in MCP-only mode."
|
|
43
|
+
};
|
|
44
|
+
const pv = await ctx.preview.render({
|
|
45
|
+
spaceId: ctx.spaceId,
|
|
46
|
+
env: ctx.env,
|
|
47
|
+
pageRef: input.pageRef,
|
|
48
|
+
operations: input.operations
|
|
49
|
+
});
|
|
50
|
+
if (!pv.ok) return pv;
|
|
51
|
+
const viewports = resolveViewports(input.viewport);
|
|
52
|
+
if (!ctx.screenshot) return {
|
|
53
|
+
warning: "SCREENSHOT_DISABLED",
|
|
54
|
+
message: "The screenshot service is not configured; returning the HTML preview instead.",
|
|
55
|
+
pageRef: input.pageRef ?? "default",
|
|
56
|
+
pagePath: pv.pagePath,
|
|
57
|
+
stateVersion: pv.stateVersion,
|
|
58
|
+
html: pv.html
|
|
59
|
+
};
|
|
60
|
+
const shot = await ctx.screenshot.capture({
|
|
61
|
+
pagePath: pv.pagePath,
|
|
62
|
+
token: pv.token,
|
|
63
|
+
viewports
|
|
64
|
+
});
|
|
65
|
+
if (!shot.ok) return {
|
|
66
|
+
warning: "SCREENSHOT_UNAVAILABLE",
|
|
67
|
+
message: `The screenshot service failed (${shot.message}); returning the HTML preview instead.`,
|
|
68
|
+
hint: "The dedicated browser service is down or unreachable. Inspect the HTML, or retry later.",
|
|
69
|
+
pageRef: input.pageRef ?? "default",
|
|
70
|
+
pagePath: pv.pagePath,
|
|
71
|
+
stateVersion: pv.stateVersion,
|
|
72
|
+
html: pv.html
|
|
73
|
+
};
|
|
74
|
+
return imageResult(shot.images, {
|
|
75
|
+
pageRef: input.pageRef ?? "default",
|
|
76
|
+
pagePath: pv.pagePath,
|
|
77
|
+
stateVersion: pv.stateVersion,
|
|
78
|
+
viewports: viewports.map((v) => v.label)
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
//#endregion
|
|
83
|
+
export { screenshotShape, screenshotTool };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { computeVersion } from "../helpers/computeVersion.js";
|
|
2
|
+
import { elementRefOf, getPageElements, isPageElement, pageRefOf, pageRefOfElement } from "../helpers/space.js";
|
|
3
|
+
import { definitionRefs, definitionToAI } from "./operations/style/translator.js";
|
|
4
|
+
import { elementDetailToAI, pageSkeletonToAI } from "./operations/schema/translator.js";
|
|
5
|
+
import { defineTool } from "./shared/tool.js";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
//#region src/modules/mcp/tools/search.ts
|
|
8
|
+
var searchShape = {
|
|
9
|
+
query: z.string().describe("Case-insensitive match on label, type and attribute values"),
|
|
10
|
+
filters: z.object({
|
|
11
|
+
type: z.string().optional(),
|
|
12
|
+
pageRef: z.string().optional()
|
|
13
|
+
}).optional(),
|
|
14
|
+
include: z.literal("detail").optional().describe("Set to \"detail\" to inline each hit's full props/style so an edit needs no follow-up read"),
|
|
15
|
+
limit: z.number().int().min(1).max(100).optional().describe("Max element hits to return (default 50). Response echoes total and, if more remain, nextOffset."),
|
|
16
|
+
offset: z.number().int().min(0).optional().describe("Element hits to skip (default 0). Page by re-calling with offset = nextOffset until it is absent.")
|
|
17
|
+
};
|
|
18
|
+
var labelOf = (el) => (typeof el.attributes.name === "string" ? el.attributes.name : void 0) ?? el.definition.label;
|
|
19
|
+
var breadcrumb = (schema, el) => {
|
|
20
|
+
const chain = [];
|
|
21
|
+
let current = el;
|
|
22
|
+
const guard = /* @__PURE__ */ new Set();
|
|
23
|
+
while (current && !guard.has(current.id)) {
|
|
24
|
+
guard.add(current.id);
|
|
25
|
+
chain.push(labelOf(current));
|
|
26
|
+
current = current.definition.parentId ? schema.flat[current.definition.parentId] : void 0;
|
|
27
|
+
}
|
|
28
|
+
return chain.reverse();
|
|
29
|
+
};
|
|
30
|
+
var search = (input, space, env) => {
|
|
31
|
+
const query = input.query.toLowerCase();
|
|
32
|
+
const results = [];
|
|
33
|
+
for (const el of Object.values(space.schema.flat)) {
|
|
34
|
+
if (isPageElement(space.schema, el)) continue;
|
|
35
|
+
if (input.filters?.type && el.definition.type !== input.filters.type) continue;
|
|
36
|
+
const pageRef = pageRefOfElement(space.schema, el);
|
|
37
|
+
if (input.filters?.pageRef && pageRef !== input.filters.pageRef) continue;
|
|
38
|
+
const matches = [];
|
|
39
|
+
if (el.definition.label.toLowerCase().includes(query)) matches.push(`label: ${el.definition.label}`);
|
|
40
|
+
if (el.definition.type.toLowerCase().includes(query)) matches.push(`type: ${el.definition.type}`);
|
|
41
|
+
for (const [key, value] of Object.entries(el.attributes)) if (String(value).toLowerCase().includes(query)) matches.push(`${key}: ${String(value).slice(0, 100)}`);
|
|
42
|
+
if (matches.length === 0) continue;
|
|
43
|
+
const ref = elementRefOf(el);
|
|
44
|
+
const detail = elementDetailToAI(space.schema, el, space.style);
|
|
45
|
+
results.push({
|
|
46
|
+
pageRef,
|
|
47
|
+
ref,
|
|
48
|
+
uri: `plitzi://schema/${env}/elements/${ref}`,
|
|
49
|
+
pageUri: `plitzi://schema/${env}/pages/${pageRef}`,
|
|
50
|
+
stateVersion: computeVersion(detail),
|
|
51
|
+
parentRef: detail.parentRef,
|
|
52
|
+
path: breadcrumb(space.schema, el),
|
|
53
|
+
label: el.definition.label,
|
|
54
|
+
type: el.definition.type,
|
|
55
|
+
matches,
|
|
56
|
+
detail: input.include === "detail" ? detail : void 0
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const definitions = [];
|
|
60
|
+
for (const ref of definitionRefs(space.style)) {
|
|
61
|
+
if (ref.toLowerCase().includes(query)) {
|
|
62
|
+
const def = definitionToAI(space.style, ref);
|
|
63
|
+
if (def) definitions.push(def);
|
|
64
|
+
}
|
|
65
|
+
if (definitions.length >= 50) break;
|
|
66
|
+
}
|
|
67
|
+
const pages = [];
|
|
68
|
+
for (const page of getPageElements(space.schema)) {
|
|
69
|
+
const label = labelOf(page);
|
|
70
|
+
const slug = typeof page.attributes.slug === "string" ? page.attributes.slug : "";
|
|
71
|
+
const matches = [];
|
|
72
|
+
if (label.toLowerCase().includes(query)) matches.push(`label: ${label}`);
|
|
73
|
+
if (slug && slug.toLowerCase().includes(query)) matches.push(`slug: ${slug}`);
|
|
74
|
+
if (matches.length === 0) continue;
|
|
75
|
+
const ref = pageRefOf(page);
|
|
76
|
+
pages.push({
|
|
77
|
+
ref,
|
|
78
|
+
uri: `plitzi://schema/${env}/pages/${ref}`,
|
|
79
|
+
stateVersion: computeVersion(pageSkeletonToAI(space.schema, page)),
|
|
80
|
+
label,
|
|
81
|
+
slug,
|
|
82
|
+
matches
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const offset = input.offset ?? 0;
|
|
86
|
+
const limit = input.limit ?? 50;
|
|
87
|
+
const total = results.length;
|
|
88
|
+
const nextOffset = offset + limit < total ? offset + limit : void 0;
|
|
89
|
+
return {
|
|
90
|
+
results: results.slice(offset, offset + limit),
|
|
91
|
+
total,
|
|
92
|
+
offset,
|
|
93
|
+
limit,
|
|
94
|
+
nextOffset,
|
|
95
|
+
definitions: definitions.length > 0 ? definitions : void 0,
|
|
96
|
+
pages: pages.length > 0 ? pages : void 0
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
var searchTool = defineTool({
|
|
100
|
+
name: "plitzi_search",
|
|
101
|
+
title: "Search",
|
|
102
|
+
description: "Find elements by label, type or attribute value across all pages. Each hit returns the element uri, its stateVersion (edit with optimistic concurrency, no read needed) and its tree path. Pass include: \"detail\" to inline the full props/style of each hit plus resolvedStyle (the CSS of its classes). Also returns any style definitions matching the query (with full CSS) under `definitions`, and matching pages under `pages`. Element hits are paginated: it returns at most `limit` (default 50) starting at `offset`, plus `total` and — while more remain — `nextOffset` to fetch the next page.",
|
|
103
|
+
inputShape: searchShape,
|
|
104
|
+
access: "read",
|
|
105
|
+
run: (input, ctx) => search(input, ctx.space, ctx.env)
|
|
106
|
+
});
|
|
107
|
+
//#endregion
|
|
108
|
+
export { search, searchShape, searchTool };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/modules/mcp/tools/shared/tool.ts
|
|
3
|
+
/** Build the MCP CallToolResult for an image-returning tool: a text meta block followed by one image block per
|
|
4
|
+
* PNG, so a vision-capable agent (or MCP client) sees the render directly. */
|
|
5
|
+
var imageResult = (images, meta) => ({ content: [{
|
|
6
|
+
type: "text",
|
|
7
|
+
text: JSON.stringify(meta)
|
|
8
|
+
}, ...images.map((img) => ({
|
|
9
|
+
type: "image",
|
|
10
|
+
data: img.data,
|
|
11
|
+
mimeType: img.mimeType
|
|
12
|
+
}))] });
|
|
13
|
+
/** Author a tool: give it its metadata, its input shape and a typed `run`. The returned descriptor parses the
|
|
14
|
+
* raw args against the shape before handing them to `run`, so `run` is fully typed and no cast is needed.
|
|
15
|
+
* Adding a tool is: call defineTool in its own file and append it to the `tools` registry. */
|
|
16
|
+
var defineTool = (spec) => ({
|
|
17
|
+
name: spec.name,
|
|
18
|
+
title: spec.title,
|
|
19
|
+
description: spec.description,
|
|
20
|
+
inputShape: spec.inputShape,
|
|
21
|
+
access: spec.access,
|
|
22
|
+
requires: spec.requires,
|
|
23
|
+
execute: (args, ctx) => spec.run(z.object(spec.inputShape).parse(args), ctx)
|
|
24
|
+
});
|
|
25
|
+
//#endregion
|
|
26
|
+
export { defineTool, imageResult };
|