@plitzi/sdk-server 0.32.4 → 0.32.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -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/helpers/buildServerInfo.js +3 -9
- package/dist/index.js +20 -6
- package/dist/modules/ai/AIEngine.js +4 -4
- package/dist/modules/ai/toolkit.js +58 -0
- package/dist/modules/mcp/catalogs/builtinCallbacks.js +204 -0
- package/dist/modules/mcp/catalogs/builtinComponents.js +170 -0
- package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +50 -0
- package/dist/modules/mcp/catalogs/builtinTransformers.js +148 -0
- package/dist/modules/mcp/catalogs/builtinUtilities.js +90 -0
- package/dist/modules/mcp/catalogs/cssCatalog.js +205 -0
- package/dist/modules/mcp/catalogs/observed.js +90 -0
- package/dist/modules/mcp/catalogs/paramSpec.js +69 -0
- package/dist/modules/mcp/catalogs/registry.js +89 -0
- package/dist/modules/mcp/constants.js +4 -0
- package/dist/modules/mcp/handler.js +24 -20
- package/dist/modules/mcp/helpers/agentPrompt.js +104 -0
- package/dist/modules/mcp/helpers/computeVersion.js +16 -0
- package/dist/modules/mcp/helpers/guide.js +449 -0
- package/dist/modules/mcp/helpers/interactions.js +123 -0
- package/dist/modules/mcp/helpers/log.js +54 -0
- package/dist/modules/mcp/helpers/opResult.js +18 -0
- package/dist/modules/mcp/helpers/space.js +262 -0
- package/dist/modules/mcp/helpers/uris.js +44 -0
- package/dist/modules/mcp/previewClient.js +31 -0
- package/dist/modules/mcp/resources/canonical.js +30 -0
- package/dist/modules/mcp/resources/core.js +15 -0
- package/dist/modules/mcp/resources/envelope.js +14 -0
- package/dist/modules/mcp/resources/primer.js +30 -0
- package/dist/modules/mcp/resources/register.js +174 -0
- package/dist/modules/mcp/resources/router.js +25 -0
- package/dist/modules/mcp/resources/schema.js +43 -0
- package/dist/modules/mcp/resources/style.js +34 -0
- package/dist/modules/mcp/screenshotClient.js +47 -0
- package/dist/modules/mcp/server.js +66 -20
- package/dist/modules/mcp/tools/apply/dispatch.js +103 -0
- package/dist/modules/mcp/tools/apply/index.js +136 -0
- package/dist/modules/mcp/tools/apply/writeResult.js +37 -0
- package/dist/modules/mcp/tools/index.js +20 -148
- package/dist/modules/mcp/tools/operations/index.js +41 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +32 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +36 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +47 -0
- package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +29 -0
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +41 -0
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +58 -0
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +65 -0
- package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +30 -0
- package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +49 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +52 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +47 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +43 -0
- package/dist/modules/mcp/tools/operations/schema/operations.js +39 -0
- package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +25 -0
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +75 -0
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +45 -0
- package/dist/modules/mcp/tools/operations/schema/shared.js +119 -0
- package/dist/modules/mcp/tools/operations/schema/translator.js +215 -0
- package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +18 -0
- package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +42 -0
- package/dist/modules/mcp/tools/operations/schema/write.js +109 -0
- package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +21 -0
- package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +28 -0
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +24 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +21 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +28 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +24 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +21 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +28 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +24 -0
- package/dist/modules/mcp/tools/operations/style/operations.js +27 -0
- package/dist/modules/mcp/tools/operations/style/shared.js +59 -0
- package/dist/modules/mcp/tools/operations/style/translator.js +101 -0
- package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +21 -0
- package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +22 -0
- package/dist/modules/mcp/tools/operations/style/write.js +108 -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 +115 -0
- package/dist/modules/mcp/tools/shared/tool.js +26 -0
- package/dist/modules/mcp/tools/shared/validator/audit.js +124 -0
- package/dist/modules/mcp/tools/shared/validator/batch.js +30 -0
- package/dist/modules/mcp/tools/shared/validator/bindings.js +70 -0
- package/dist/modules/mcp/tools/shared/validator/context.js +35 -0
- package/dist/modules/mcp/tools/shared/validator/css.js +47 -0
- package/dist/modules/mcp/tools/shared/validator/elements.js +55 -0
- package/dist/modules/mcp/tools/shared/validator/index.js +226 -0
- package/dist/modules/mcp/tools/shared/validator/interactions.js +106 -0
- package/dist/modules/mcp/tools/shared/validator/refs.js +28 -0
- package/dist/modules/mcp/tools/validate.js +39 -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/modules/ssr/views/template.ejs +2 -0
- 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/catalogs/builtinCallbacks.d.ts +23 -0
- package/dist/src/modules/mcp/catalogs/builtinComponents.d.ts +4 -0
- package/dist/src/modules/mcp/catalogs/builtinElementCallbacks.d.ts +20 -0
- package/dist/src/modules/mcp/catalogs/builtinTransformers.d.ts +28 -0
- package/dist/src/modules/mcp/catalogs/builtinUtilities.d.ts +18 -0
- package/dist/src/modules/mcp/catalogs/cssCatalog.d.ts +14 -0
- package/dist/src/modules/mcp/catalogs/index.d.ts +9 -0
- package/dist/src/modules/mcp/catalogs/observed.d.ts +48 -0
- package/dist/src/modules/mcp/catalogs/paramSpec.d.ts +42 -0
- package/dist/src/modules/mcp/catalogs/registry.d.ts +35 -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/agentPrompt.d.ts +4 -0
- package/dist/src/modules/mcp/helpers/computeVersion.d.ts +1 -0
- package/dist/src/modules/mcp/helpers/guide.d.ts +3 -0
- package/dist/src/modules/mcp/helpers/index.d.ts +8 -0
- package/dist/src/modules/mcp/helpers/interactions.d.ts +30 -0
- package/dist/src/modules/mcp/helpers/log.d.ts +8 -0
- package/dist/src/modules/mcp/helpers/opResult.d.ts +13 -0
- package/dist/src/modules/mcp/helpers/space.d.ts +105 -0
- package/dist/src/modules/mcp/helpers/uris.d.ts +28 -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 +6 -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 +7 -10
- package/dist/src/modules/mcp/resources/primer.d.ts +7 -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 +21 -3
- package/dist/src/modules/mcp/tools/apply/dispatch.d.ts +6 -0
- package/dist/src/modules/mcp/tools/apply/index.d.ts +420 -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 +828 -0
- package/dist/src/modules/mcp/tools/operations/schema/bindings/deleteBinding.d.ts +17 -0
- package/dist/src/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +25 -0
- package/dist/src/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +27 -0
- package/dist/src/modules/mcp/tools/operations/schema/elements/deleteElement.d.ts +10 -0
- package/dist/src/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +16 -0
- package/dist/src/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +22 -0
- package/dist/src/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +16 -0
- package/dist/src/modules/mcp/tools/operations/schema/folders/deleteFolder.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/schema/folders/upsertFolder.d.ts +12 -0
- package/dist/src/modules/mcp/tools/operations/schema/index.d.ts +20 -0
- package/dist/src/modules/mcp/tools/operations/schema/interactions/deleteInteraction.d.ts +12 -0
- package/dist/src/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +18 -0
- package/dist/src/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +27 -0
- package/dist/src/modules/mcp/tools/operations/schema/operations.d.ts +210 -0
- package/dist/src/modules/mcp/tools/operations/schema/pages/deletePage.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +14 -0
- package/dist/src/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +34 -0
- package/dist/src/modules/mcp/tools/operations/schema/shared.d.ts +77 -0
- package/dist/src/modules/mcp/tools/operations/schema/translator.d.ts +12 -0
- package/dist/src/modules/mcp/tools/operations/schema/variables/deleteVariable.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/schema/variables/upsertVariable.d.ts +16 -0
- package/dist/src/modules/mcp/tools/operations/schema/write.d.ts +42 -0
- package/dist/src/modules/mcp/tools/operations/style/definitions/deleteDefinition.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/index.d.ts +14 -0
- package/dist/src/modules/mcp/tools/operations/style/operations.d.ts +231 -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 +12 -0
- package/dist/src/modules/mcp/tools/operations/style/variables/deleteStyleVariable.d.ts +15 -0
- package/dist/src/modules/mcp/tools/operations/style/variables/upsertStyleVariable.d.ts +20 -0
- package/dist/src/modules/mcp/tools/operations/style/write.d.ts +12 -0
- package/dist/src/modules/mcp/tools/preview.d.ts +415 -0
- package/dist/src/modules/mcp/tools/read.d.ts +8 -0
- package/dist/src/modules/mcp/tools/screenshot.d.ts +420 -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/audit.d.ts +4 -0
- package/dist/src/modules/mcp/tools/shared/validator/batch.d.ts +5 -0
- package/dist/src/modules/mcp/tools/shared/validator/bindings.d.ts +6 -0
- package/dist/src/modules/mcp/tools/shared/validator/context.d.ts +34 -0
- package/dist/src/modules/mcp/tools/shared/validator/css.d.ts +4 -0
- package/dist/src/modules/mcp/tools/shared/validator/elements.d.ts +6 -0
- package/dist/src/modules/mcp/tools/shared/validator/index.d.ts +8 -0
- package/dist/src/modules/mcp/tools/shared/validator/interactions.d.ts +3 -0
- package/dist/src/modules/mcp/tools/shared/validator/refs.d.ts +4 -0
- package/dist/src/modules/mcp/tools/validate.d.ts +417 -0
- package/dist/src/modules/mcp/types/aiSchema.d.ts +218 -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 +16 -14
- 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/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/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/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 → catalogs/builtinTransformers.test.d.ts} +0 -0
- /package/dist/src/modules/mcp/{tools/resources/resources.test.d.ts → helpers/log.test.d.ts} +0 -0
- /package/dist/src/modules/mcp/{tools/segment/schema/elements/segmentElements.test.d.ts → mcp.bench.d.ts} +0 -0
- /package/dist/src/modules/mcp/{tools/segment/schema/variables/segmentVariables.test.d.ts → mcp.test.d.ts} +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/modules/mcp/helpers/opResult.ts
|
|
2
|
+
var empty = () => ({
|
|
3
|
+
created: 0,
|
|
4
|
+
updated: 0,
|
|
5
|
+
deleted: 0,
|
|
6
|
+
staleResources: []
|
|
7
|
+
});
|
|
8
|
+
var fail = (path, message, hint, validValues) => ({
|
|
9
|
+
...empty(),
|
|
10
|
+
errors: [{
|
|
11
|
+
path,
|
|
12
|
+
message,
|
|
13
|
+
hint,
|
|
14
|
+
validValues
|
|
15
|
+
}]
|
|
16
|
+
});
|
|
17
|
+
//#endregion
|
|
18
|
+
export { empty, fail };
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
//#region src/modules/mcp/helpers/space.ts
|
|
2
|
+
var cloneSpace = (space) => ({
|
|
3
|
+
schema: structuredClone(space.schema),
|
|
4
|
+
style: structuredClone(space.style),
|
|
5
|
+
...space.catalog ? { catalog: space.catalog } : {}
|
|
6
|
+
});
|
|
7
|
+
var slugify = (value) => value.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "";
|
|
8
|
+
/** A value when it is a string, otherwise undefined — for the many attributes typed as `unknown` that are strings
|
|
9
|
+
* in practice (name, slug, subType, dom id…). */
|
|
10
|
+
var strOr = (value) => typeof value === "string" ? value : void 0;
|
|
11
|
+
/** Display name of a page or element: its `name` attribute when set, otherwise its definition label. */
|
|
12
|
+
var nameOf = (el) => strOr(el.attributes.name) ?? el.definition.label;
|
|
13
|
+
/** Stable, human-readable ref for a page: its idRef, then slug, then a slugified label. A page without an idRef is
|
|
14
|
+
* still addressable — unlike a data source, a page ref has meaningful fallbacks the agent can read off the tree. */
|
|
15
|
+
var pageRefOf = (el) => {
|
|
16
|
+
if (el.idRef) return el.idRef;
|
|
17
|
+
const slug = strOr(el.attributes.slug)?.trim();
|
|
18
|
+
if (slug) return slugify(slug);
|
|
19
|
+
if (el.attributes.default === true) return "home";
|
|
20
|
+
return slugify(nameOf(el)) || el.id;
|
|
21
|
+
};
|
|
22
|
+
/** Stable ref for ADDRESSING a non-page element in the tree: its idRef when present, otherwise the opaque id so an
|
|
23
|
+
* element without one is still reachable — the agent needs to name it to give it an idRef in the first place.
|
|
24
|
+
* This is not the wiring key: the runtime wires interactions and data sources by idRef only, so an element
|
|
25
|
+
* addressed here by its id alone publishes no source and takes no interactions (see `getSourceName`). */
|
|
26
|
+
var elementRefOf = (el) => el.idRef ?? el.id;
|
|
27
|
+
var buildIndex = (schema) => {
|
|
28
|
+
const flat = schema.flat;
|
|
29
|
+
const lookup = (id) => flat[id];
|
|
30
|
+
const pageIds = new Set(schema.pages);
|
|
31
|
+
for (const el of Object.values(flat)) if (el.definition.type === "page") pageIds.add(el.id);
|
|
32
|
+
const pageElements = [];
|
|
33
|
+
const pageByRef = /* @__PURE__ */ new Map();
|
|
34
|
+
const elementByRef = /* @__PURE__ */ new Map();
|
|
35
|
+
for (const el of Object.values(flat)) if (pageIds.has(el.id)) {
|
|
36
|
+
pageElements.push(el);
|
|
37
|
+
const ref = pageRefOf(el);
|
|
38
|
+
if (!pageByRef.has(ref)) pageByRef.set(ref, el);
|
|
39
|
+
if (!pageByRef.has(el.id)) pageByRef.set(el.id, el);
|
|
40
|
+
} else {
|
|
41
|
+
const ref = elementRefOf(el);
|
|
42
|
+
if (!elementByRef.has(ref)) elementByRef.set(ref, el);
|
|
43
|
+
if (!elementByRef.has(el.id)) elementByRef.set(el.id, el);
|
|
44
|
+
}
|
|
45
|
+
const pageOf = /* @__PURE__ */ new Map();
|
|
46
|
+
for (const page of pageElements) {
|
|
47
|
+
pageOf.set(page.id, page.id);
|
|
48
|
+
const stack = [...page.definition.items ?? []];
|
|
49
|
+
while (stack.length > 0) {
|
|
50
|
+
const id = stack.pop();
|
|
51
|
+
if (id === void 0 || pageOf.has(id)) continue;
|
|
52
|
+
const el = lookup(id);
|
|
53
|
+
if (!el) continue;
|
|
54
|
+
pageOf.set(id, page.id);
|
|
55
|
+
for (const childId of el.definition.items ?? []) stack.push(childId);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
pageIds,
|
|
60
|
+
pageElements,
|
|
61
|
+
pageByRef,
|
|
62
|
+
elementByRef,
|
|
63
|
+
pageOf,
|
|
64
|
+
detailCache: /* @__PURE__ */ new Map()
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
var indexCache = /* @__PURE__ */ new WeakMap();
|
|
68
|
+
/** The index for a schema, built once and memoized on the schema object. */
|
|
69
|
+
var spaceIndex = (schema) => {
|
|
70
|
+
let index = indexCache.get(schema);
|
|
71
|
+
if (!index) {
|
|
72
|
+
index = buildIndex(schema);
|
|
73
|
+
indexCache.set(schema, index);
|
|
74
|
+
}
|
|
75
|
+
return index;
|
|
76
|
+
};
|
|
77
|
+
var cachedIndex = (schema) => indexCache.get(schema);
|
|
78
|
+
/** A new non-page element was created under `pageId`. */
|
|
79
|
+
var indexAddElement = (schema, el, pageId) => {
|
|
80
|
+
const index = cachedIndex(schema);
|
|
81
|
+
if (!index) return;
|
|
82
|
+
index.elementByRef.set(el.id, el);
|
|
83
|
+
if (el.idRef) index.elementByRef.set(el.idRef, el);
|
|
84
|
+
index.pageOf.set(el.id, pageId);
|
|
85
|
+
index.detailCache.clear();
|
|
86
|
+
};
|
|
87
|
+
/** These non-page elements were deleted (an element and its descendants). */
|
|
88
|
+
var indexRemoveElements = (schema, els) => {
|
|
89
|
+
const index = cachedIndex(schema);
|
|
90
|
+
if (!index) return;
|
|
91
|
+
for (const el of els) {
|
|
92
|
+
index.elementByRef.delete(el.id);
|
|
93
|
+
if (el.idRef) index.elementByRef.delete(el.idRef);
|
|
94
|
+
index.pageOf.delete(el.id);
|
|
95
|
+
}
|
|
96
|
+
index.detailCache.clear();
|
|
97
|
+
};
|
|
98
|
+
/** An existing element was just given an idRef (it had none), so it becomes addressable by that ref. */
|
|
99
|
+
var indexReRefElement = (schema, el) => {
|
|
100
|
+
const index = cachedIndex(schema);
|
|
101
|
+
if (!index) return;
|
|
102
|
+
if (el.idRef) index.elementByRef.set(el.idRef, el);
|
|
103
|
+
index.detailCache.clear();
|
|
104
|
+
};
|
|
105
|
+
/** A new page element was created. */
|
|
106
|
+
var indexAddPage = (schema, page) => {
|
|
107
|
+
const index = cachedIndex(schema);
|
|
108
|
+
if (!index) return;
|
|
109
|
+
index.pageIds.add(page.id);
|
|
110
|
+
index.pageElements.push(page);
|
|
111
|
+
index.pageByRef.set(page.id, page);
|
|
112
|
+
index.pageByRef.set(pageRefOf(page), page);
|
|
113
|
+
index.pageOf.set(page.id, page.id);
|
|
114
|
+
index.detailCache.clear();
|
|
115
|
+
};
|
|
116
|
+
/** A page and its `descendants` (its non-page elements) were deleted. */
|
|
117
|
+
var indexRemovePage = (schema, page, descendants) => {
|
|
118
|
+
const index = cachedIndex(schema);
|
|
119
|
+
if (!index) return;
|
|
120
|
+
index.pageIds.delete(page.id);
|
|
121
|
+
const at = index.pageElements.findIndex((p) => p.id === page.id);
|
|
122
|
+
if (at >= 0) index.pageElements.splice(at, 1);
|
|
123
|
+
index.pageByRef.delete(page.id);
|
|
124
|
+
index.pageByRef.delete(pageRefOf(page));
|
|
125
|
+
index.pageOf.delete(page.id);
|
|
126
|
+
for (const el of descendants) {
|
|
127
|
+
index.elementByRef.delete(el.id);
|
|
128
|
+
if (el.idRef) index.elementByRef.delete(el.idRef);
|
|
129
|
+
index.pageOf.delete(el.id);
|
|
130
|
+
}
|
|
131
|
+
index.detailCache.clear();
|
|
132
|
+
};
|
|
133
|
+
/** A page's slug/name/default changed; re-key its pageByRef entry if that changed its ref. `oldRef` is the ref
|
|
134
|
+
* computed BEFORE the attribute change. */
|
|
135
|
+
var indexReRefPage = (schema, page, oldRef) => {
|
|
136
|
+
const index = cachedIndex(schema);
|
|
137
|
+
if (!index) return;
|
|
138
|
+
const newRef = pageRefOf(page);
|
|
139
|
+
if (newRef !== oldRef) {
|
|
140
|
+
index.pageByRef.delete(oldRef);
|
|
141
|
+
index.pageByRef.set(newRef, page);
|
|
142
|
+
index.detailCache.clear();
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
/** A move reparented an element within its page: the ref/page maps are unchanged, but the moved element's
|
|
146
|
+
* parentRef and both parents' childRefs did change, so their memoized detail must be dropped. */
|
|
147
|
+
var indexInvalidateDetails = (schema) => {
|
|
148
|
+
cachedIndex(schema)?.detailCache.clear();
|
|
149
|
+
};
|
|
150
|
+
var isPageElement = (schema, el) => spaceIndex(schema).pageIds.has(el.id) || el.definition.type === "page";
|
|
151
|
+
var getPageElements = (schema) => spaceIndex(schema).pageElements;
|
|
152
|
+
/** Finds a page by its semantic ref (idRef/slug/…) or its raw id, so legacy schemas without an idRef still resolve. */
|
|
153
|
+
var findPageByRef = (schema, pageRef) => spaceIndex(schema).pageByRef.get(pageRef);
|
|
154
|
+
/** Find any non-page element by its semantic ref (idRef) or raw id, across the whole space. */
|
|
155
|
+
var findElementByRef = (schema, ref) => spaceIndex(schema).elementByRef.get(ref);
|
|
156
|
+
var pageFoldersOf = (schema) => {
|
|
157
|
+
schema.pageFolders ??= [];
|
|
158
|
+
return schema.pageFolders;
|
|
159
|
+
};
|
|
160
|
+
/** Resolve a folder by its id, or (for agent convenience) by an exact name or slug when that is unambiguous. */
|
|
161
|
+
var findFolderByRef = (schema, ref) => {
|
|
162
|
+
const folders = pageFoldersOf(schema);
|
|
163
|
+
const byId = folders.find((f) => f.id === ref);
|
|
164
|
+
if (byId) return byId;
|
|
165
|
+
const byName = folders.filter((f) => f.name === ref);
|
|
166
|
+
if (byName.length === 1) return byName[0];
|
|
167
|
+
const bySlug = folders.filter((f) => f.slug === ref);
|
|
168
|
+
return bySlug.length === 1 ? bySlug[0] : void 0;
|
|
169
|
+
};
|
|
170
|
+
/** Order folders so every parent precedes its children — the invariant the schema validator enforces on
|
|
171
|
+
* pageFolders (a parentId must appear earlier in the array). Cycles (rejected upstream) are left in place. */
|
|
172
|
+
var sortFolders = (folders) => {
|
|
173
|
+
const byId = new Map(folders.map((f) => [f.id, f]));
|
|
174
|
+
const placed = /* @__PURE__ */ new Set();
|
|
175
|
+
const result = [];
|
|
176
|
+
const visit = (folder, ancestry) => {
|
|
177
|
+
if (placed.has(folder.id)) return;
|
|
178
|
+
const parent = folder.parentId ? byId.get(folder.parentId) : void 0;
|
|
179
|
+
if (parent && !ancestry.has(parent.id)) visit(parent, new Set(ancestry).add(folder.id));
|
|
180
|
+
if (!placed.has(folder.id)) {
|
|
181
|
+
placed.add(folder.id);
|
|
182
|
+
result.push(folder);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
for (const folder of folders) visit(folder, /* @__PURE__ */ new Set([folder.id]));
|
|
186
|
+
return result;
|
|
187
|
+
};
|
|
188
|
+
/** Ancestor ids of a folder (following parentId), stopping on a cycle. Used to reject a parent change that would
|
|
189
|
+
* make a folder its own ancestor. */
|
|
190
|
+
var folderAncestorIds = (folders, startParentId) => {
|
|
191
|
+
const byId = new Map(folders.map((f) => [f.id, f]));
|
|
192
|
+
const chain = [];
|
|
193
|
+
const seen = /* @__PURE__ */ new Set();
|
|
194
|
+
let current = startParentId ? byId.get(startParentId) : void 0;
|
|
195
|
+
while (current && !seen.has(current.id)) {
|
|
196
|
+
seen.add(current.id);
|
|
197
|
+
chain.push(current.id);
|
|
198
|
+
current = current.parentId ? byId.get(current.parentId) : void 0;
|
|
199
|
+
}
|
|
200
|
+
return chain;
|
|
201
|
+
};
|
|
202
|
+
/** Route params a page's slug binds (e.g. ":spaceId/update/*" → ["spaceId"]). These are valid {{name}}
|
|
203
|
+
* references on that page even though they are not space-level schema variables. */
|
|
204
|
+
var slugRouteParams = (slug) => {
|
|
205
|
+
const params = [];
|
|
206
|
+
for (const segment of slug.split("/")) if (segment.startsWith(":")) params.push(segment.slice(1).replace(/[*+?]+$/, ""));
|
|
207
|
+
return params;
|
|
208
|
+
};
|
|
209
|
+
/** Every route param bound by any page slug in the space (union), so {{name}} validation does not false-flag a
|
|
210
|
+
* page-scoped dynamic binding. */
|
|
211
|
+
var routeParamNames = (schema) => {
|
|
212
|
+
const params = /* @__PURE__ */ new Set();
|
|
213
|
+
for (const page of getPageElements(schema)) {
|
|
214
|
+
const slug = typeof page.attributes.slug === "string" ? page.attributes.slug : "";
|
|
215
|
+
for (const param of slugRouteParams(slug)) params.add(param);
|
|
216
|
+
}
|
|
217
|
+
return [...params];
|
|
218
|
+
};
|
|
219
|
+
/** Indexed lookup that reflects the runtime reality: a flat id may be dangling (rsc placeholders, stale items). */
|
|
220
|
+
var elementById = (schema, id) => schema.flat[id];
|
|
221
|
+
/** All element ids belonging to a page subtree (excluding the page root). */
|
|
222
|
+
var collectDescendants = (schema, rootId, acc) => {
|
|
223
|
+
const el = elementById(schema, rootId);
|
|
224
|
+
if (!el) return;
|
|
225
|
+
const childIds = el.definition.items ?? [];
|
|
226
|
+
for (const childId of childIds) if (elementById(schema, childId)) {
|
|
227
|
+
acc.push(childId);
|
|
228
|
+
collectDescendants(schema, childId, acc);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
var descendantIds = (schema, pageRootId) => {
|
|
232
|
+
const acc = [];
|
|
233
|
+
collectDescendants(schema, pageRootId, acc);
|
|
234
|
+
return acc;
|
|
235
|
+
};
|
|
236
|
+
/** Resolve a ref to a concrete element within a page subtree (or the page root itself). Accepts either the
|
|
237
|
+
* semantic ref (idRef) or the raw element id, so schemas predating idRef keep working through their ids. */
|
|
238
|
+
var resolveRef = (schema, page, ref) => {
|
|
239
|
+
if (elementRefOf(page) === ref || pageRefOf(page) === ref || page.id === ref) return page;
|
|
240
|
+
const index = spaceIndex(schema);
|
|
241
|
+
const el = index.elementByRef.get(ref);
|
|
242
|
+
return el && index.pageOf.get(el.id) === page.id ? el : void 0;
|
|
243
|
+
};
|
|
244
|
+
/** Ordered children of an element, honoring definition.items and skipping dangling ids. */
|
|
245
|
+
var orderedChildren = (schema, el) => {
|
|
246
|
+
return (el.definition.items ?? []).map((id) => schema.flat[id]).filter((child) => Boolean(child));
|
|
247
|
+
};
|
|
248
|
+
/** The page ref an element belongs to. 'unknown' when it has no page ancestor. */
|
|
249
|
+
var pageRefOfElement = (schema, el) => {
|
|
250
|
+
const pageId = spaceIndex(schema).pageOf.get(el.id);
|
|
251
|
+
const page = pageId ? schema.flat[pageId] : void 0;
|
|
252
|
+
return page ? pageRefOf(page) : "unknown";
|
|
253
|
+
};
|
|
254
|
+
/** Total number of descendant elements under a subtree (excluding the root). */
|
|
255
|
+
var descendantCount = (schema, rootId) => descendantIds(schema, rootId).length;
|
|
256
|
+
var emptySpaceMessage = "Space data not available";
|
|
257
|
+
var unauthorizedSpaceMessage = "This tool/resource needs a space, but no spaceId could be resolved from the Authorization token";
|
|
258
|
+
var generateObjectId = () => {
|
|
259
|
+
return `${Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0")}${Array.from({ length: 16 }, () => Math.floor(Math.random() * 16).toString(16)).join("")}`;
|
|
260
|
+
};
|
|
261
|
+
//#endregion
|
|
262
|
+
export { cloneSpace, descendantCount, descendantIds, elementById, elementRefOf, emptySpaceMessage, findElementByRef, findFolderByRef, findPageByRef, folderAncestorIds, generateObjectId, getPageElements, indexAddElement, indexAddPage, indexInvalidateDetails, indexReRefElement, indexReRefPage, indexRemoveElements, indexRemovePage, isPageElement, nameOf, orderedChildren, pageFoldersOf, pageRefOf, pageRefOfElement, resolveRef, routeParamNames, slugRouteParams, slugify, sortFolders, spaceIndex, strOr, unauthorizedSpaceMessage };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#region src/modules/mcp/helpers/uris.ts
|
|
2
|
+
var guideUri = "plitzi://guide";
|
|
3
|
+
var typesUri = "plitzi://types";
|
|
4
|
+
var cssPropertiesUri = "plitzi://css-properties";
|
|
5
|
+
var primerUri = (env) => `plitzi://primer/${env}`;
|
|
6
|
+
var pagesUri = (env) => `plitzi://schema/${env}/pages`;
|
|
7
|
+
var pageUri = (env, ref) => `plitzi://schema/${env}/pages/${ref}`;
|
|
8
|
+
var elementUri = (env, ref) => `plitzi://schema/${env}/elements/${ref}`;
|
|
9
|
+
var schemaVarsUri = (env) => `plitzi://schema-variables/${env}`;
|
|
10
|
+
var settingsUri = (env) => `plitzi://settings/${env}`;
|
|
11
|
+
var interactionsUri = (env) => `plitzi://interactions/${env}`;
|
|
12
|
+
var dataSourcesUri = (env) => `plitzi://data-sources/${env}`;
|
|
13
|
+
var foldersUri = (env) => `plitzi://folders/${env}`;
|
|
14
|
+
var folderUri = (env, ref) => `plitzi://folders/${env}/${ref}`;
|
|
15
|
+
var defsUri = (env) => `plitzi://definitions/${env}`;
|
|
16
|
+
var defUri = (env, ref) => `plitzi://definitions/${env}/${ref}`;
|
|
17
|
+
var globalsUri = (env) => `plitzi://global-styles/${env}`;
|
|
18
|
+
var globalUri = (env, componentType) => `plitzi://global-styles/${env}/${componentType}`;
|
|
19
|
+
var idsUri = (env) => `plitzi://id-styles/${env}`;
|
|
20
|
+
var idUri = (env, targetId) => `plitzi://id-styles/${env}/${targetId}`;
|
|
21
|
+
var styleVarsUri = (env) => `plitzi://style-variables/${env}`;
|
|
22
|
+
var styleVarUri = (env, category) => `plitzi://style-variables/${env}/${category}`;
|
|
23
|
+
var aliasedRoots = [
|
|
24
|
+
"definitions",
|
|
25
|
+
"global-styles",
|
|
26
|
+
"id-styles",
|
|
27
|
+
"style-variables",
|
|
28
|
+
"schema-variables",
|
|
29
|
+
"folders"
|
|
30
|
+
];
|
|
31
|
+
var itemTemplates = (env) => [
|
|
32
|
+
pageUri(env, "{ref}"),
|
|
33
|
+
elementUri(env, "{ref}"),
|
|
34
|
+
defUri(env, "{ref}"),
|
|
35
|
+
globalUri(env, "{componentType}"),
|
|
36
|
+
idUri(env, "{targetId}"),
|
|
37
|
+
styleVarUri(env, "{category}"),
|
|
38
|
+
folderUri(env, "{ref}")
|
|
39
|
+
];
|
|
40
|
+
/** The remainder of `uri` after `prefix`, or undefined when it does not start with it — so a resolver matches a
|
|
41
|
+
* family and extracts its ref in one step, without repeating the prefix string for both the startsWith and slice. */
|
|
42
|
+
var afterPrefix = (uri, prefix) => uri.startsWith(prefix) ? uri.slice(prefix.length) : void 0;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { afterPrefix, aliasedRoots, cssPropertiesUri, dataSourcesUri, defUri, defsUri, elementUri, folderUri, foldersUri, globalUri, globalsUri, guideUri, idUri, idsUri, interactionsUri, itemTemplates, pageUri, pagesUri, primerUri, schemaVarsUri, settingsUri, styleVarUri, styleVarsUri, typesUri };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/modules/mcp/previewClient.ts
|
|
2
|
+
/** Default `PreviewClient`: POSTs the preview request to the SSR `/preview` endpoint over HTTP. Used when the
|
|
3
|
+
* MCP server is a separate process from the SSR renderer (the common case). A network/HTTP failure surfaces as
|
|
4
|
+
* an `ok:false` result rather than throwing, so the calling tool can degrade gracefully. */
|
|
5
|
+
var createHttpPreviewClient = ({ url, secret, fetchImpl = fetch }) => ({ async render(body) {
|
|
6
|
+
let res;
|
|
7
|
+
try {
|
|
8
|
+
res = await fetchImpl(url, {
|
|
9
|
+
method: "POST",
|
|
10
|
+
headers: {
|
|
11
|
+
"content-type": "application/json",
|
|
12
|
+
...secret ? { "x-preview-secret": secret } : {}
|
|
13
|
+
},
|
|
14
|
+
body: JSON.stringify(body)
|
|
15
|
+
});
|
|
16
|
+
} catch (err) {
|
|
17
|
+
return {
|
|
18
|
+
ok: false,
|
|
19
|
+
error: "PREVIEW_UNREACHABLE",
|
|
20
|
+
message: `Preview endpoint unreachable: ${String(err)}`
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (!res.ok && res.status !== 422) return {
|
|
24
|
+
ok: false,
|
|
25
|
+
error: "PREVIEW_REQUEST_FAILED",
|
|
26
|
+
message: `Preview endpoint returned ${res.status}.`
|
|
27
|
+
};
|
|
28
|
+
return await res.json();
|
|
29
|
+
} });
|
|
30
|
+
//#endregion
|
|
31
|
+
export { createHttpPreviewClient };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { afterPrefix, aliasedRoots, itemTemplates, primerUri } from "../helpers/uris.js";
|
|
2
|
+
//#region src/modules/mcp/resources/canonical.ts
|
|
3
|
+
var canonicalUri = (env, uri) => {
|
|
4
|
+
const rest = afterPrefix(uri, `plitzi://schema/${env}/`);
|
|
5
|
+
if (rest === void 0) return uri;
|
|
6
|
+
for (const root of aliasedRoots) {
|
|
7
|
+
if (rest === root) return `plitzi://${root}/${env}`;
|
|
8
|
+
if (rest.startsWith(`${root}/`)) return `plitzi://${root}/${env}/${rest.slice(root.length + 1)}`;
|
|
9
|
+
}
|
|
10
|
+
return uri;
|
|
11
|
+
};
|
|
12
|
+
/** Teachable message for a URI that read as null. Distinguishes a well-formed URI whose ref does not resolve (the
|
|
13
|
+
* resource may be stale/deleted) from a URI whose shape matches no template at all (malformed — echo the valid
|
|
14
|
+
* templates so the agent stops hand-building URIs). See RFC 0004 I2. */
|
|
15
|
+
var resourceErrorMessage = (env, uri) => {
|
|
16
|
+
const canonical = canonicalUri(env, uri);
|
|
17
|
+
if (itemTemplates(env).some((tpl) => canonical.startsWith(tpl.slice(0, tpl.lastIndexOf("/") + 1)))) return JSON.stringify({
|
|
18
|
+
error: "NOT_FOUND",
|
|
19
|
+
message: `No resource at '${uri}'. Its shape is valid but the ref does not resolve.`,
|
|
20
|
+
hint: "It may have been deleted or your URI is stale. Re-list the parent resource (pages/definitions) to refresh."
|
|
21
|
+
});
|
|
22
|
+
return JSON.stringify({
|
|
23
|
+
error: "MALFORMED_URI",
|
|
24
|
+
message: `'${uri}' matches no resource template.`,
|
|
25
|
+
hint: "Do not hand-build element URIs — take the ready-made uri from plitzi_search or a write response.",
|
|
26
|
+
validTemplates: [primerUri(env), ...itemTemplates(env)]
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { canonicalUri, resourceErrorMessage };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { cssProperties } from "../catalogs/cssCatalog.js";
|
|
2
|
+
import { buildTypeRegistry } from "../catalogs/registry.js";
|
|
3
|
+
import "../helpers/uris.js";
|
|
4
|
+
import { guideText } from "../helpers/guide.js";
|
|
5
|
+
import { envelope } from "./envelope.js";
|
|
6
|
+
//#region src/modules/mcp/resources/core.ts
|
|
7
|
+
/** Space-independent singletons: the usage guide, the observed type registry and the CSS property catalog.
|
|
8
|
+
* Returns undefined when the URI is not one of these, so the router falls through to the next resolver. */
|
|
9
|
+
var readCoreResource = (space, uri) => {
|
|
10
|
+
if (uri === "plitzi://guide") return envelope(guideText);
|
|
11
|
+
if (uri === "plitzi://types") return envelope(buildTypeRegistry(space.schema, space.catalog));
|
|
12
|
+
if (uri === "plitzi://css-properties") return envelope(cssProperties);
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { readCoreResource };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { computeVersion } from "../helpers/computeVersion.js";
|
|
2
|
+
//#region src/modules/mcp/resources/envelope.ts
|
|
3
|
+
/** Wrap any read projection with the version its optimistic-concurrency checks key on. */
|
|
4
|
+
var envelope = (data) => ({
|
|
5
|
+
stateVersion: computeVersion(data),
|
|
6
|
+
data
|
|
7
|
+
});
|
|
8
|
+
var jsonContents = (uri, data) => ({ contents: [{
|
|
9
|
+
uri,
|
|
10
|
+
mimeType: "application/json",
|
|
11
|
+
text: JSON.stringify(data)
|
|
12
|
+
}] });
|
|
13
|
+
//#endregion
|
|
14
|
+
export { envelope, jsonContents };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { cssProperties } from "../catalogs/cssCatalog.js";
|
|
2
|
+
import { buildDataSourceCatalog, buildInteractionCatalog } from "../catalogs/observed.js";
|
|
3
|
+
import { buildTypeRegistry } from "../catalogs/registry.js";
|
|
4
|
+
import { guideQuickstart } from "../helpers/guide.js";
|
|
5
|
+
import { envelope } from "./envelope.js";
|
|
6
|
+
import { definitionRefs, styleVariablesToAI } from "../tools/operations/style/translator.js";
|
|
7
|
+
import { foldersToAI, pageSummariesToAI, schemaVariablesToAI, settingsToAI } from "../tools/operations/schema/translator.js";
|
|
8
|
+
//#region src/modules/mcp/resources/primer.ts
|
|
9
|
+
/** The cold-start bundle: everything the guide says to read before the first write, in one round-trip.
|
|
10
|
+
* Summaries only — never full page/element trees (those are opened on demand), so it stays cheap even on a
|
|
11
|
+
* large space. Carries the condensed `guideQuickstart` (not the full guideText, which the agent reads on demand at
|
|
12
|
+
* plitzi://guide) to keep the bundle small. Returns undefined when the URI is not the primer. */
|
|
13
|
+
var readPrimerResource = (space, env, uri) => {
|
|
14
|
+
if (uri !== `plitzi://primer/${env}`) return;
|
|
15
|
+
return envelope({
|
|
16
|
+
guide: guideQuickstart,
|
|
17
|
+
types: buildTypeRegistry(space.schema, space.catalog),
|
|
18
|
+
cssProperties,
|
|
19
|
+
pages: pageSummariesToAI(space.schema),
|
|
20
|
+
folders: foldersToAI(space.schema),
|
|
21
|
+
definitions: definitionRefs(space.style),
|
|
22
|
+
styleVariables: styleVariablesToAI(space.style),
|
|
23
|
+
schemaVariables: schemaVariablesToAI(space.schema, false),
|
|
24
|
+
settings: settingsToAI(space.schema),
|
|
25
|
+
interactions: buildInteractionCatalog(space.schema),
|
|
26
|
+
dataSources: buildDataSourceCatalog(space.schema)
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { readPrimerResource };
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { cssProperties } from "../catalogs/cssCatalog.js";
|
|
2
|
+
import { guideText } from "../helpers/guide.js";
|
|
3
|
+
import { resourceErrorMessage } from "./canonical.js";
|
|
4
|
+
import { envelope, jsonContents } from "./envelope.js";
|
|
5
|
+
import { readResource } from "./router.js";
|
|
6
|
+
import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp";
|
|
7
|
+
//#region src/modules/mcp/resources/register.ts
|
|
8
|
+
/** Register every resource on the MCP server: fixed listings plus templated per-item reads. The space is
|
|
9
|
+
* loaded lazily via getSpace, so listing resources never touches the store — only reading one does. */
|
|
10
|
+
var registerResources = (server, getSpace, env, log) => {
|
|
11
|
+
const emit = async (uri) => {
|
|
12
|
+
const start = performance.now();
|
|
13
|
+
try {
|
|
14
|
+
const result = readResource(await getSpace(), env, uri);
|
|
15
|
+
if (!result) throw new Error(resourceErrorMessage(env, uri));
|
|
16
|
+
log.resourceRead(uri, performance.now() - start);
|
|
17
|
+
return jsonContents(uri, result);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
log.resourceRead(uri, performance.now() - start, error);
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
server.registerResource("Guide", "plitzi://guide", {
|
|
24
|
+
description: "How to read and write this space with mcp-ai",
|
|
25
|
+
mimeType: "text/markdown"
|
|
26
|
+
}, () => ({ contents: [{
|
|
27
|
+
uri: "plitzi://guide",
|
|
28
|
+
mimeType: "text/markdown",
|
|
29
|
+
text: guideText
|
|
30
|
+
}] }));
|
|
31
|
+
server.registerResource("CSS properties", "plitzi://css-properties", {
|
|
32
|
+
description: "Valid kebab-case CSS property keys",
|
|
33
|
+
mimeType: "application/json"
|
|
34
|
+
}, () => jsonContents("plitzi://css-properties", envelope(cssProperties)));
|
|
35
|
+
const fixed = [
|
|
36
|
+
[
|
|
37
|
+
"Primer",
|
|
38
|
+
`plitzi://primer/${env}`,
|
|
39
|
+
"Read this FIRST. Cold-start bundle in one call: guide, types, css-properties and SUMMARIES of pages, definitions and variables — summaries only, never full page/element trees, so it stays small even on a large space. Open a page or element on demand afterwards."
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
"Element types",
|
|
43
|
+
"plitzi://types",
|
|
44
|
+
"Observed element types with props, slots and subTypes"
|
|
45
|
+
],
|
|
46
|
+
[
|
|
47
|
+
"Pages",
|
|
48
|
+
`plitzi://schema/${env}/pages`,
|
|
49
|
+
"Page summaries (ref, label, elementCount) — no element trees"
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
"Folders",
|
|
53
|
+
`plitzi://folders/${env}`,
|
|
54
|
+
"Page folders (the sidebar tree): ref, name, slug, parentId"
|
|
55
|
+
],
|
|
56
|
+
[
|
|
57
|
+
"Style definitions",
|
|
58
|
+
`plitzi://definitions/${env}`,
|
|
59
|
+
"Style definition refs (names)"
|
|
60
|
+
],
|
|
61
|
+
[
|
|
62
|
+
"Global styles",
|
|
63
|
+
`plitzi://global-styles/${env}`,
|
|
64
|
+
"Element types that have a site-wide global style"
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
"Id styles",
|
|
68
|
+
`plitzi://id-styles/${env}`,
|
|
69
|
+
"DOM ids that have an id rule (#id) targeting a single element"
|
|
70
|
+
],
|
|
71
|
+
[
|
|
72
|
+
"Style variables",
|
|
73
|
+
`plitzi://style-variables/${env}`,
|
|
74
|
+
"Design tokens by category"
|
|
75
|
+
],
|
|
76
|
+
[
|
|
77
|
+
"Schema variables",
|
|
78
|
+
`plitzi://schema-variables/${env}`,
|
|
79
|
+
"Space-level values referenced via {{name}}"
|
|
80
|
+
],
|
|
81
|
+
[
|
|
82
|
+
"Settings",
|
|
83
|
+
`plitzi://settings/${env}`,
|
|
84
|
+
"Space-level settings: global customCss and state/auth configuration"
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
"Interactions catalog",
|
|
88
|
+
`plitzi://interactions/${env}`,
|
|
89
|
+
"Interaction actions (observed, grouped by node type) plus the built-in vocabularies — globalCallbacks (with their source module), element callbacks and utilities — each with its full param schema, the vocabulary for upsertInteractionFlow"
|
|
90
|
+
],
|
|
91
|
+
[
|
|
92
|
+
"Data sources catalog",
|
|
93
|
+
`plitzi://data-sources/${env}`,
|
|
94
|
+
"Data-source paths and binding targets observed in this space — the vocabulary for upsertBinding"
|
|
95
|
+
],
|
|
96
|
+
[
|
|
97
|
+
"Style definitions (schema alias)",
|
|
98
|
+
`plitzi://schema/${env}/definitions`,
|
|
99
|
+
"Alias of plitzi://definitions/{env}"
|
|
100
|
+
],
|
|
101
|
+
[
|
|
102
|
+
"Style variables (schema alias)",
|
|
103
|
+
`plitzi://schema/${env}/style-variables`,
|
|
104
|
+
"Alias of plitzi://style-variables/{env}"
|
|
105
|
+
],
|
|
106
|
+
[
|
|
107
|
+
"Schema variables (schema alias)",
|
|
108
|
+
`plitzi://schema/${env}/schema-variables`,
|
|
109
|
+
"Alias of plitzi://schema-variables/{env}"
|
|
110
|
+
]
|
|
111
|
+
];
|
|
112
|
+
for (const [name, uri, description] of fixed) server.registerResource(name, uri, {
|
|
113
|
+
description,
|
|
114
|
+
mimeType: "application/json"
|
|
115
|
+
}, () => emit(uri));
|
|
116
|
+
const templates = [
|
|
117
|
+
[
|
|
118
|
+
"Page",
|
|
119
|
+
`plitzi://schema/${env}/pages/{ref}`,
|
|
120
|
+
"One page as a skeleton tree (ref/type/label/children), no props"
|
|
121
|
+
],
|
|
122
|
+
[
|
|
123
|
+
"Page styles",
|
|
124
|
+
`plitzi://schema/${env}/pages/{ref}/styles`,
|
|
125
|
+
"Every style a page uses in one read: class definitions its elements attach (with CSS) + global styles"
|
|
126
|
+
],
|
|
127
|
+
[
|
|
128
|
+
"Element",
|
|
129
|
+
`plitzi://schema/${env}/elements/{ref}`,
|
|
130
|
+
"One element in full detail (props, style) by ref or id"
|
|
131
|
+
],
|
|
132
|
+
[
|
|
133
|
+
"Folder",
|
|
134
|
+
`plitzi://folders/${env}/{ref}`,
|
|
135
|
+
"One page folder (name, slug, parentId) by folder id"
|
|
136
|
+
],
|
|
137
|
+
[
|
|
138
|
+
"Style definition",
|
|
139
|
+
`plitzi://definitions/${env}/{ref}`,
|
|
140
|
+
"One style definition (CSS) by class ref"
|
|
141
|
+
],
|
|
142
|
+
[
|
|
143
|
+
"Global style",
|
|
144
|
+
`plitzi://global-styles/${env}/{componentType}`,
|
|
145
|
+
"The site-wide CSS applied to every element of one type"
|
|
146
|
+
],
|
|
147
|
+
[
|
|
148
|
+
"Id style",
|
|
149
|
+
`plitzi://id-styles/${env}/{targetId}`,
|
|
150
|
+
"The CSS of an id rule (#id) targeting a single element"
|
|
151
|
+
],
|
|
152
|
+
[
|
|
153
|
+
"Style variables by category",
|
|
154
|
+
`plitzi://style-variables/${env}/{category}`,
|
|
155
|
+
"Design tokens for one category"
|
|
156
|
+
],
|
|
157
|
+
[
|
|
158
|
+
"Style definition (schema alias)",
|
|
159
|
+
`plitzi://schema/${env}/definitions/{ref}`,
|
|
160
|
+
"Alias of plitzi://definitions/{env}/{ref}"
|
|
161
|
+
],
|
|
162
|
+
[
|
|
163
|
+
"Style variables by category (schema alias)",
|
|
164
|
+
`plitzi://schema/${env}/style-variables/{category}`,
|
|
165
|
+
"Alias of plitzi://style-variables/{env}/{category}"
|
|
166
|
+
]
|
|
167
|
+
];
|
|
168
|
+
for (const [name, tpl, description] of templates) server.registerResource(name, new ResourceTemplate(tpl, { list: void 0 }), {
|
|
169
|
+
description,
|
|
170
|
+
mimeType: "application/json"
|
|
171
|
+
}, (uri) => emit(uri.href));
|
|
172
|
+
};
|
|
173
|
+
//#endregion
|
|
174
|
+
export { registerResources };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { canonicalUri } from "./canonical.js";
|
|
2
|
+
import { readCoreResource } from "./core.js";
|
|
3
|
+
import { readPrimerResource } from "./primer.js";
|
|
4
|
+
import { readSchemaResource } from "./schema.js";
|
|
5
|
+
import { readStyleResource } from "./style.js";
|
|
6
|
+
//#region src/modules/mcp/resources/router.ts
|
|
7
|
+
var resolvers = [
|
|
8
|
+
(space, _env, uri) => readCoreResource(space, uri),
|
|
9
|
+
readPrimerResource,
|
|
10
|
+
readSchemaResource,
|
|
11
|
+
readStyleResource
|
|
12
|
+
];
|
|
13
|
+
/** Resolve a resource URI to its versioned envelope, or null if unknown / not found. */
|
|
14
|
+
var readResource = (space, env, rawUri) => {
|
|
15
|
+
const uri = canonicalUri(env, rawUri);
|
|
16
|
+
for (const resolve of resolvers) {
|
|
17
|
+
const result = resolve(space, env, uri);
|
|
18
|
+
if (result !== void 0) return result;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
};
|
|
22
|
+
/** Current version of a resource, for optimistic-concurrency checks. Null when the URI is unknown. */
|
|
23
|
+
var resourceVersion = (space, env, uri) => readResource(space, env, uri)?.stateVersion ?? null;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { readResource, resourceVersion };
|