@plitzi/sdk-server 0.32.25 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +326 -162
- package/dist/adapters/authAdapters.d.ts +21 -0
- package/dist/adapters/authAdapters.js +12 -0
- package/dist/adapters/jsonAdapters.d.ts +15 -0
- package/dist/adapters/jsonAdapters.js +9 -4
- package/dist/core/auth/api.d.ts +148 -0
- package/dist/core/auth/api.js +286 -0
- package/dist/core/auth/authorize.d.ts +96 -0
- package/dist/core/auth/authorize.js +92 -0
- package/dist/core/auth/createAuth.d.ts +165 -0
- package/dist/core/auth/createAuth.js +105 -0
- package/dist/core/auth/credentials.d.ts +29 -0
- package/dist/core/auth/credentials.js +48 -0
- package/dist/core/auth/domains.d.ts +41 -0
- package/dist/core/auth/domains.js +78 -0
- package/dist/core/auth/identity.d.ts +108 -0
- package/dist/core/auth/identity.js +164 -0
- package/dist/core/auth/oauth/client.d.ts +5 -0
- package/dist/core/auth/oauth/client.js +47 -0
- package/dist/core/auth/oauth/index.d.ts +78 -0
- package/dist/core/auth/oauth/index.js +113 -0
- package/dist/core/auth/oauth/providers/github.d.ts +2 -0
- package/dist/core/auth/oauth/providers/github.js +48 -0
- package/dist/core/auth/oauth/providers/google.d.ts +2 -0
- package/dist/core/auth/oauth/providers/google.js +30 -0
- package/dist/core/auth/oauth/state.d.ts +23 -0
- package/dist/core/auth/oauth/state.js +55 -0
- package/dist/core/auth/oauth/types.d.ts +51 -0
- package/dist/core/auth/oauth/types.js +13 -0
- package/dist/core/auth/routes.d.ts +50 -0
- package/dist/core/auth/routes.js +129 -0
- package/dist/core/auth/session.d.ts +128 -0
- package/dist/core/auth/session.js +165 -0
- package/dist/core/auth/spaceTokens.d.ts +137 -0
- package/dist/core/auth/spaceTokens.js +212 -0
- package/dist/core/auth/tokens.d.ts +151 -0
- package/dist/core/auth/tokens.js +221 -0
- package/dist/core/createServer.d.ts +29 -0
- package/dist/core/createServer.js +28 -14
- package/dist/core/handlers/authMiddleware.d.ts +27 -0
- package/dist/core/handlers/authMiddleware.js +38 -0
- package/dist/core/handlers/authRouteHandlers.d.ts +46 -0
- package/dist/core/handlers/authRouteHandlers.js +75 -0
- package/dist/core/handlers/types.d.ts +37 -0
- package/dist/{src/core → core}/http/dispatcher.d.ts +2 -2
- package/dist/core/http/dispatcher.js +8 -6
- package/dist/core/http/navigation.d.ts +11 -0
- package/dist/core/http/navigation.js +16 -0
- package/dist/core/http/securityHeaders.js +6 -4
- package/dist/core/http/stages/authApi.d.ts +17 -0
- package/dist/core/http/stages/authApi.js +66 -0
- package/dist/core/http/stages/authRoutes.js +40 -11
- package/dist/core/http/stages/exchangeRoute.d.ts +15 -0
- package/dist/core/http/stages/exchangeRoute.js +67 -0
- package/dist/core/http/stages/health.d.ts +11 -0
- package/dist/core/http/stages/health.js +25 -3
- package/dist/core/http/stages/middlewares.d.ts +2 -0
- package/dist/core/http/stages/static.d.ts +13 -0
- package/dist/core/http/stages/static.js +21 -6
- package/dist/core/http/types.d.ts +35 -0
- package/dist/{modules/mcp/constants.js → core/previewToken.js} +1 -1
- package/dist/core/sdkAssets.d.ts +16 -0
- package/dist/core/sdkAssets.js +46 -0
- package/dist/core/server/baseServer.js +40 -5
- package/dist/core/server/pageServer.d.ts +7 -0
- package/dist/core/server/pageServer.js +13 -17
- package/dist/core/services/action.d.ts +9 -0
- package/dist/core/services/action.js +21 -0
- package/dist/core/services/registry.d.ts +3 -0
- package/dist/core/services/registry.js +9 -19
- package/dist/{src/core → core}/services/resolve.d.ts +1 -0
- package/dist/core/services/resolve.js +6 -4
- package/dist/core/services/rsc.js +3 -2
- package/dist/core/staticFiles.js +1 -1
- package/dist/{src/core → core}/transports.d.ts +3 -0
- package/dist/core/transports.js +7 -6
- package/dist/handlers.d.ts +58 -0
- package/dist/handlers.js +3 -0
- package/dist/{src/helpers → helpers}/buildResponseHelpers.d.ts +2 -1
- package/dist/helpers/buildResponseHelpers.js +13 -4
- package/dist/helpers/buildServerInfo.d.ts +3 -0
- package/dist/helpers/buildServerInfo.js +25 -3
- package/dist/{src/helpers → helpers}/cache/keys.d.ts +5 -1
- package/dist/helpers/cache/keys.js +1 -1
- package/dist/helpers/compress.d.ts +18 -0
- package/dist/helpers/compress.js +47 -11
- package/dist/helpers/offlineDataLoader.d.ts +11 -0
- package/dist/helpers/offlineDataLoader.js +15 -0
- package/dist/helpers/resolveDebugMode.d.ts +10 -0
- package/dist/helpers/resolveDebugMode.js +13 -0
- package/dist/index.d.ts +16 -2
- package/dist/index.js +9 -20
- package/dist/kernel.d.ts +41 -0
- package/dist/kernel.js +22 -0
- package/dist/middlewares/spaceDeployment.d.ts +2 -0
- package/dist/middlewares/spaceDeployment.js +2 -1
- package/dist/modules/actions/handler.d.ts +11 -0
- package/dist/modules/actions/handler.js +77 -0
- package/dist/modules/connectors/engine.d.ts +42 -0
- package/dist/modules/connectors/engine.js +221 -0
- package/dist/modules/connectors/getByPath.d.ts +8 -0
- package/dist/modules/connectors/getByPath.js +21 -0
- package/dist/modules/connectors/index.d.ts +7 -0
- package/dist/modules/connectors/projection.d.ts +18 -0
- package/dist/modules/connectors/projection.js +108 -0
- package/dist/modules/connectors/resolver.d.ts +18 -0
- package/dist/modules/connectors/resolver.js +68 -0
- package/dist/modules/connectors/types.d.ts +19 -0
- package/dist/{src/modules → modules}/rsc/handler.d.ts +2 -2
- package/dist/modules/rsc/handler.js +54 -2
- package/dist/modules/rsc/resolveRscData.d.ts +35 -0
- package/dist/modules/rsc/resolveRscData.js +74 -0
- package/dist/{src/modules → modules}/ssr/Component.d.ts +4 -1
- package/dist/modules/ssr/Component.js +10 -3
- package/dist/modules/ssr/buildBody.d.ts +9 -0
- package/dist/modules/ssr/handler.d.ts +4 -0
- package/dist/modules/ssr/handler.js +18 -1
- package/dist/{src/modules → modules}/ssr/loadPluginComponents.d.ts +5 -2
- package/dist/modules/ssr/loadPluginComponents.js +20 -2
- package/dist/{src/modules → modules}/ssr/prepareRender.d.ts +2 -2
- package/dist/modules/ssr/prepareRender.js +24 -7
- package/dist/modules/ssr/preview.d.ts +10 -0
- package/dist/modules/ssr/preview.js +5 -78
- package/dist/modules/ssr/registerExternalPlugins.js +1 -1
- package/dist/modules/ssr/streamBody.d.ts +5 -0
- package/dist/modules/ssr/streamBody.js +1 -1
- package/dist/modules/ssr/template.d.ts +2 -0
- package/dist/modules/ssr/template.js +1 -1
- package/dist/plugins/compile.js +1 -1
- package/dist/plugins/manager.js +12 -8
- package/dist/ssr.d.ts +15 -0
- package/dist/ssr.js +4 -0
- package/package.json +29 -25
- package/dist/.gitkeep +0 -0
- package/dist/core/server/mcpServer.js +0 -29
- package/dist/core/services/mcp.js +0 -27
- package/dist/core/services/oauth.js +0 -116
- package/dist/core/services/preview.js +0 -37
- package/dist/core/services/proxy.js +0 -12
- package/dist/mcp.d.ts +0 -2
- package/dist/mcp.js +0 -7
- package/dist/modules/ai/AIEngine.js +0 -120
- package/dist/modules/ai/toolkit.js +0 -59
- package/dist/modules/mcp/apps/example/view/index.tsx +0 -70
- package/dist/modules/mcp/apps/index.js +0 -16
- package/dist/modules/mcp/apps/render/index.js +0 -17
- package/dist/modules/mcp/apps/render/styles.js +0 -54
- package/dist/modules/mcp/apps/render/view/heldBatch.ts +0 -107
- package/dist/modules/mcp/apps/render/view/index.tsx +0 -314
- package/dist/modules/mcp/apps/render/view/streamProgress.ts +0 -137
- package/dist/modules/mcp/apps/shared/assets.js +0 -10
- package/dist/modules/mcp/apps/shared/bundle.js +0 -23
- package/dist/modules/mcp/apps/shared/page.js +0 -34
- package/dist/modules/mcp/apps/shared/registerApp.js +0 -43
- package/dist/modules/mcp/apps/shared/resolve.js +0 -5
- package/dist/modules/mcp/apps/shared/shell.ejs +0 -59
- package/dist/modules/mcp/apps/shared/zodEnglishOnly.js +0 -23
- package/dist/modules/mcp/catalogs/builtinCallbacks.js +0 -204
- package/dist/modules/mcp/catalogs/builtinComponents.js +0 -170
- package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +0 -50
- package/dist/modules/mcp/catalogs/builtinTransformers.js +0 -148
- package/dist/modules/mcp/catalogs/builtinUtilities.js +0 -90
- package/dist/modules/mcp/catalogs/cssCatalog/border.js +0 -30
- package/dist/modules/mcp/catalogs/cssCatalog/box.js +0 -31
- package/dist/modules/mcp/catalogs/cssCatalog/helpers.js +0 -185
- package/dist/modules/mcp/catalogs/cssCatalog/index.js +0 -131
- package/dist/modules/mcp/catalogs/cssCatalog/layout.js +0 -98
- package/dist/modules/mcp/catalogs/cssCatalog/visual.js +0 -144
- package/dist/modules/mcp/catalogs/observed.js +0 -90
- package/dist/modules/mcp/catalogs/paramSpec.js +0 -69
- package/dist/modules/mcp/catalogs/registry.js +0 -89
- package/dist/modules/mcp/handler.js +0 -83
- package/dist/modules/mcp/helpers/agentPrompt.js +0 -104
- package/dist/modules/mcp/helpers/computeVersion.js +0 -16
- package/dist/modules/mcp/helpers/guide.js +0 -467
- package/dist/modules/mcp/helpers/interactions.js +0 -123
- package/dist/modules/mcp/helpers/log.js +0 -64
- package/dist/modules/mcp/helpers/opResult.js +0 -18
- package/dist/modules/mcp/helpers/space.js +0 -300
- package/dist/modules/mcp/helpers/uris.js +0 -44
- package/dist/modules/mcp/previewClient.js +0 -31
- package/dist/modules/mcp/proxy/config.js +0 -63
- package/dist/modules/mcp/proxy/fetch.js +0 -91
- package/dist/modules/mcp/proxy/grant.js +0 -67
- package/dist/modules/mcp/proxy/guard.js +0 -38
- package/dist/modules/mcp/proxy/handler.js +0 -99
- package/dist/modules/mcp/proxy/payload.js +0 -29
- package/dist/modules/mcp/proxy/rewrite.js +0 -138
- package/dist/modules/mcp/proxy/sign.js +0 -15
- package/dist/modules/mcp/proxy/types.js +0 -9
- package/dist/modules/mcp/resources/canonical.js +0 -30
- package/dist/modules/mcp/resources/core.js +0 -18
- package/dist/modules/mcp/resources/envelope.js +0 -14
- package/dist/modules/mcp/resources/primer.js +0 -31
- package/dist/modules/mcp/resources/register.js +0 -190
- package/dist/modules/mcp/resources/renderGuide.js +0 -451
- package/dist/modules/mcp/resources/router.js +0 -37
- package/dist/modules/mcp/resources/schema.js +0 -43
- package/dist/modules/mcp/resources/style.js +0 -34
- package/dist/modules/mcp/screenshotClient.js +0 -47
- package/dist/modules/mcp/server.js +0 -113
- package/dist/modules/mcp/tools/apply/dispatch.js +0 -105
- package/dist/modules/mcp/tools/apply/index.js +0 -150
- package/dist/modules/mcp/tools/apply/writeResult.js +0 -37
- package/dist/modules/mcp/tools/index.js +0 -24
- package/dist/modules/mcp/tools/operations/index.js +0 -45
- package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +0 -32
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +0 -36
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +0 -47
- package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +0 -29
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +0 -41
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +0 -58
- package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +0 -148
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +0 -65
- package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +0 -30
- package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +0 -49
- package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +0 -52
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +0 -47
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +0 -44
- package/dist/modules/mcp/tools/operations/schema/operations.js +0 -41
- package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +0 -25
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +0 -75
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +0 -45
- package/dist/modules/mcp/tools/operations/schema/shared.js +0 -122
- package/dist/modules/mcp/tools/operations/schema/translator.js +0 -215
- package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +0 -18
- package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +0 -42
- package/dist/modules/mcp/tools/operations/schema/write.js +0 -109
- package/dist/modules/mcp/tools/operations/schemaIds.js +0 -54
- package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +0 -21
- package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +0 -28
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +0 -24
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.js +0 -40
- package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +0 -21
- package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +0 -28
- package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +0 -24
- package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +0 -21
- package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +0 -28
- package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +0 -24
- package/dist/modules/mcp/tools/operations/style/operations.js +0 -29
- package/dist/modules/mcp/tools/operations/style/shared.js +0 -59
- package/dist/modules/mcp/tools/operations/style/translator.js +0 -101
- package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +0 -21
- package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +0 -22
- package/dist/modules/mcp/tools/operations/style/write.js +0 -108
- package/dist/modules/mcp/tools/preview.js +0 -37
- package/dist/modules/mcp/tools/read.js +0 -51
- package/dist/modules/mcp/tools/render.js +0 -184
- package/dist/modules/mcp/tools/screenshot.js +0 -83
- package/dist/modules/mcp/tools/search.js +0 -115
- package/dist/modules/mcp/tools/shared/expandOperations.js +0 -44
- package/dist/modules/mcp/tools/shared/tool.js +0 -33
- package/dist/modules/mcp/tools/shared/validator/audit.js +0 -124
- package/dist/modules/mcp/tools/shared/validator/batch.js +0 -39
- package/dist/modules/mcp/tools/shared/validator/bindings.js +0 -70
- package/dist/modules/mcp/tools/shared/validator/context.js +0 -35
- package/dist/modules/mcp/tools/shared/validator/css.js +0 -39
- package/dist/modules/mcp/tools/shared/validator/elements.js +0 -68
- package/dist/modules/mcp/tools/shared/validator/index.js +0 -246
- package/dist/modules/mcp/tools/shared/validator/interactions.js +0 -103
- package/dist/modules/mcp/tools/shared/validator/refs.js +0 -28
- package/dist/modules/mcp/tools/validate.js +0 -47
- package/dist/modules/oauth/authorize.js +0 -177
- package/dist/modules/oauth/challenge.js +0 -33
- package/dist/modules/oauth/consentPage.js +0 -118
- package/dist/modules/oauth/metadata.js +0 -69
- package/dist/modules/oauth/params.js +0 -5
- package/dist/modules/oauth/pkce.js +0 -15
- package/dist/modules/oauth/records.js +0 -46
- package/dist/modules/oauth/register.js +0 -55
- package/dist/modules/oauth/respond.js +0 -44
- package/dist/modules/oauth/token.js +0 -100
- package/dist/public/.gitkeep +0 -0
- package/dist/src/adapters/jsonAdapters.d.ts +0 -7
- package/dist/src/core/createServer.d.ts +0 -14
- package/dist/src/core/http/stages/health.d.ts +0 -2
- package/dist/src/core/http/stages/middlewares.d.ts +0 -2
- package/dist/src/core/http/stages/static.d.ts +0 -5
- package/dist/src/core/http/types.d.ts +0 -22
- package/dist/src/core/server/mcpServer.d.ts +0 -2
- package/dist/src/core/server/pageServer.d.ts +0 -10
- package/dist/src/core/services/mcp.d.ts +0 -3
- package/dist/src/core/services/oauth.d.ts +0 -18
- package/dist/src/core/services/preview.d.ts +0 -2
- package/dist/src/core/services/proxy.d.ts +0 -2
- package/dist/src/core/services/registry.d.ts +0 -4
- package/dist/src/helpers/buildServerInfo.d.ts +0 -2
- package/dist/src/helpers/compress.d.ts +0 -3
- package/dist/src/index.d.ts +0 -15
- package/dist/src/mcp.d.ts +0 -14
- package/dist/src/middlewares/spaceDeployment.d.ts +0 -2
- package/dist/src/modules/ai/AIEngine.d.ts +0 -20
- package/dist/src/modules/ai/index.d.ts +0 -4
- package/dist/src/modules/ai/toolkit.d.ts +0 -17
- package/dist/src/modules/mcp/apps/example/index.d.ts +0 -8
- package/dist/src/modules/mcp/apps/index.d.ts +0 -11
- package/dist/src/modules/mcp/apps/render/index.d.ts +0 -4
- package/dist/src/modules/mcp/apps/render/styles.d.ts +0 -10
- package/dist/src/modules/mcp/apps/shared/assets.d.ts +0 -10
- package/dist/src/modules/mcp/apps/shared/bundle.d.ts +0 -4
- package/dist/src/modules/mcp/apps/shared/index.d.ts +0 -3
- package/dist/src/modules/mcp/apps/shared/page.d.ts +0 -2
- package/dist/src/modules/mcp/apps/shared/registerApp.d.ts +0 -5
- package/dist/src/modules/mcp/apps/shared/resolve.d.ts +0 -1
- package/dist/src/modules/mcp/apps/shared/zodEnglishOnly.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/builtinCallbacks.d.ts +0 -23
- package/dist/src/modules/mcp/catalogs/builtinComponents.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/builtinElementCallbacks.d.ts +0 -20
- package/dist/src/modules/mcp/catalogs/builtinTransformers.d.ts +0 -28
- package/dist/src/modules/mcp/catalogs/builtinUtilities.d.ts +0 -18
- package/dist/src/modules/mcp/catalogs/cssCatalog/border.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/cssCatalog/box.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/cssCatalog/helpers.d.ts +0 -34
- package/dist/src/modules/mcp/catalogs/cssCatalog/index.d.ts +0 -19
- package/dist/src/modules/mcp/catalogs/cssCatalog/layout.d.ts +0 -9
- package/dist/src/modules/mcp/catalogs/cssCatalog/visual.d.ts +0 -8
- package/dist/src/modules/mcp/catalogs/index.d.ts +0 -9
- package/dist/src/modules/mcp/catalogs/observed.d.ts +0 -48
- package/dist/src/modules/mcp/catalogs/paramSpec.d.ts +0 -42
- package/dist/src/modules/mcp/catalogs/registry.d.ts +0 -35
- package/dist/src/modules/mcp/e2e/index.d.ts +0 -6
- package/dist/src/modules/mcp/e2e/mcpEndpoint.d.ts +0 -27
- package/dist/src/modules/mcp/e2e/postMessageChannel.d.ts +0 -22
- package/dist/src/modules/mcp/e2e/renderingHost.d.ts +0 -34
- package/dist/src/modules/mcp/handler.d.ts +0 -22
- package/dist/src/modules/mcp/helpers/agentPrompt.d.ts +0 -4
- package/dist/src/modules/mcp/helpers/computeVersion.d.ts +0 -1
- package/dist/src/modules/mcp/helpers/guide.d.ts +0 -4
- package/dist/src/modules/mcp/helpers/index.d.ts +0 -8
- package/dist/src/modules/mcp/helpers/interactions.d.ts +0 -30
- package/dist/src/modules/mcp/helpers/log.d.ts +0 -8
- package/dist/src/modules/mcp/helpers/opResult.d.ts +0 -13
- package/dist/src/modules/mcp/helpers/space.d.ts +0 -115
- package/dist/src/modules/mcp/helpers/uris.d.ts +0 -28
- package/dist/src/modules/mcp/index.d.ts +0 -13
- package/dist/src/modules/mcp/previewClient.d.ts +0 -13
- package/dist/src/modules/mcp/proxy/config.d.ts +0 -19
- package/dist/src/modules/mcp/proxy/fetch.d.ts +0 -18
- package/dist/src/modules/mcp/proxy/grant.d.ts +0 -25
- package/dist/src/modules/mcp/proxy/guard.d.ts +0 -6
- package/dist/src/modules/mcp/proxy/handler.d.ts +0 -8
- package/dist/src/modules/mcp/proxy/index.d.ts +0 -8
- package/dist/src/modules/mcp/proxy/payload.d.ts +0 -8
- package/dist/src/modules/mcp/proxy/rewrite.d.ts +0 -18
- package/dist/src/modules/mcp/proxy/sign.d.ts +0 -6
- package/dist/src/modules/mcp/proxy/types.d.ts +0 -45
- package/dist/src/modules/mcp/resources/canonical.d.ts +0 -6
- package/dist/src/modules/mcp/resources/core.d.ts +0 -5
- package/dist/src/modules/mcp/resources/envelope.d.ts +0 -10
- package/dist/src/modules/mcp/resources/index.d.ts +0 -8
- package/dist/src/modules/mcp/resources/primer.d.ts +0 -7
- package/dist/src/modules/mcp/resources/register.d.ts +0 -10
- package/dist/src/modules/mcp/resources/renderGuide.d.ts +0 -10
- package/dist/src/modules/mcp/resources/router.d.ts +0 -10
- package/dist/src/modules/mcp/resources/schema.d.ts +0 -5
- package/dist/src/modules/mcp/resources/style.d.ts +0 -5
- package/dist/src/modules/mcp/screenshotClient.d.ts +0 -13
- package/dist/src/modules/mcp/server.d.ts +0 -31
- package/dist/src/modules/mcp/tests/helpers.d.ts +0 -13
- package/dist/src/modules/mcp/tools/apply/dispatch.d.ts +0 -6
- package/dist/src/modules/mcp/tools/apply/index.d.ts +0 -470
- package/dist/src/modules/mcp/tools/apply/writeResult.d.ts +0 -8
- package/dist/src/modules/mcp/tools/index.d.ts +0 -18
- package/dist/src/modules/mcp/tools/operations/index.d.ts +0 -928
- package/dist/src/modules/mcp/tools/operations/schema/bindings/deleteBinding.d.ts +0 -17
- package/dist/src/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +0 -25
- package/dist/src/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +0 -27
- package/dist/src/modules/mcp/tools/operations/schema/elements/deleteElement.d.ts +0 -10
- package/dist/src/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +0 -16
- package/dist/src/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +0 -22
- package/dist/src/modules/mcp/tools/operations/schema/elements/repeatElement.d.ts +0 -55
- package/dist/src/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +0 -16
- package/dist/src/modules/mcp/tools/operations/schema/folders/deleteFolder.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/schema/folders/upsertFolder.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/schema/index.d.ts +0 -21
- package/dist/src/modules/mcp/tools/operations/schema/interactions/deleteInteraction.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +0 -18
- package/dist/src/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +0 -27
- package/dist/src/modules/mcp/tools/operations/schema/operations.d.ts +0 -229
- package/dist/src/modules/mcp/tools/operations/schema/pages/deletePage.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +0 -14
- package/dist/src/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +0 -34
- package/dist/src/modules/mcp/tools/operations/schema/shared.d.ts +0 -92
- package/dist/src/modules/mcp/tools/operations/schema/translator.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/schema/variables/deleteVariable.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/schema/variables/upsertVariable.d.ts +0 -16
- package/dist/src/modules/mcp/tools/operations/schema/write.d.ts +0 -42
- package/dist/src/modules/mcp/tools/operations/schemaIds.d.ts +0 -6
- package/dist/src/modules/mcp/tools/operations/style/definitions/deleteDefinition.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinitions.d.ts +0 -41
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/index.d.ts +0 -15
- package/dist/src/modules/mcp/tools/operations/style/operations.d.ts +0 -264
- package/dist/src/modules/mcp/tools/operations/style/shared.d.ts +0 -116
- package/dist/src/modules/mcp/tools/operations/style/translator.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/style/variables/deleteStyleVariable.d.ts +0 -15
- package/dist/src/modules/mcp/tools/operations/style/variables/upsertStyleVariable.d.ts +0 -20
- package/dist/src/modules/mcp/tools/operations/style/write.d.ts +0 -12
- package/dist/src/modules/mcp/tools/preview.d.ts +0 -465
- package/dist/src/modules/mcp/tools/read.d.ts +0 -9
- package/dist/src/modules/mcp/tools/render.d.ts +0 -499
- package/dist/src/modules/mcp/tools/render.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/screenshot.d.ts +0 -470
- package/dist/src/modules/mcp/tools/search.d.ts +0 -15
- package/dist/src/modules/mcp/tools/shared/expandOperations.d.ts +0 -13
- package/dist/src/modules/mcp/tools/shared/tool.d.ts +0 -72
- package/dist/src/modules/mcp/tools/shared/validator/audit.d.ts +0 -4
- package/dist/src/modules/mcp/tools/shared/validator/batch.d.ts +0 -5
- package/dist/src/modules/mcp/tools/shared/validator/bindings.d.ts +0 -6
- package/dist/src/modules/mcp/tools/shared/validator/context.d.ts +0 -38
- package/dist/src/modules/mcp/tools/shared/validator/css.d.ts +0 -4
- package/dist/src/modules/mcp/tools/shared/validator/elements.d.ts +0 -7
- package/dist/src/modules/mcp/tools/shared/validator/index.d.ts +0 -8
- package/dist/src/modules/mcp/tools/shared/validator/interactions.d.ts +0 -3
- package/dist/src/modules/mcp/tools/shared/validator/refs.d.ts +0 -4
- package/dist/src/modules/mcp/tools/validate.d.ts +0 -467
- package/dist/src/modules/mcp/types/aiSchema.d.ts +0 -218
- package/dist/src/modules/mcp/types/appTypes.d.ts +0 -26
- package/dist/src/modules/mcp/types/index.d.ts +0 -5
- package/dist/src/modules/mcp/types/previewTypes.d.ts +0 -25
- package/dist/src/modules/mcp/types/screenshotTypes.d.ts +0 -29
- package/dist/src/modules/mcp/types/toolTypes.d.ts +0 -138
- package/dist/src/modules/oauth/authorize.d.ts +0 -7
- package/dist/src/modules/oauth/challenge.d.ts +0 -11
- package/dist/src/modules/oauth/consentPage.d.ts +0 -7
- package/dist/src/modules/oauth/metadata.d.ts +0 -40
- package/dist/src/modules/oauth/params.d.ts +0 -5
- package/dist/src/modules/oauth/pkce.d.ts +0 -6
- package/dist/src/modules/oauth/records.d.ts +0 -71
- package/dist/src/modules/oauth/register.d.ts +0 -5
- package/dist/src/modules/oauth/respond.d.ts +0 -13
- package/dist/src/modules/oauth/token.d.ts +0 -5
- package/dist/src/modules/ssr/buildBody.d.ts +0 -9
- package/dist/src/modules/ssr/handler.d.ts +0 -4
- package/dist/src/modules/ssr/preview.d.ts +0 -16
- package/dist/src/modules/ssr/streamBody.d.ts +0 -5
- package/dist/src/modules/ssr/template.d.ts +0 -6
- package/dist/src/standalone/alias-loader.d.mts +0 -2
- package/dist/src/standalone/plugins/ClientInfo.d.ts +0 -2
- package/dist/src/standalone/plugins/ServerInfo.d.ts +0 -2
- package/dist/src/standalone/plugins/SharedInfo.d.ts +0 -2
- package/dist/src/standalone/plugins/styles.d.ts +0 -5
- package/dist/src/standalone/register-alias.d.mts +0 -1
- package/dist/src/standalone/server.d.ts +0 -1
- package/dist/src/standalone/stubs/react-syntax-highlighter.d.mts +0 -31
- package/skills/plitzi-render/SKILL.md +0 -174
- /package/dist/{src/core/http/dispatcher.test.d.ts → core/auth/api.test.d.ts} +0 -0
- /package/dist/{src/core/server/mcpServer.test.d.ts → core/auth/authorize.test.d.ts} +0 -0
- /package/dist/{src/modules/ai/toolkit.test.d.ts → core/auth/createAuth.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/apps/apps.test.d.ts → core/auth/domains.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/apps/render/styles.test.d.ts → core/auth/identity.test.d.ts} +0 -0
- /package/dist/{src/modules → core/auth}/oauth/oauth.test.d.ts +0 -0
- /package/dist/{src/modules/mcp/catalogs/builtinTransformers.test.d.ts → core/auth/routes.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/catalogs/cssCatalog/cssCatalog.test.d.ts → core/auth/session.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/e2e/connector.test.d.ts → core/auth/spaceTokens.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/e2e/host.test.d.ts → core/auth/tokens.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/e2e/oauthConnector.test.d.ts → core/createServer.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/helpers/log.test.d.ts → core/handlers/handlers.test.d.ts} +0 -0
- /package/dist/{src/core → core}/health.d.ts +0 -0
- /package/dist/{src/modules/mcp/mcp.bench.d.ts → core/http/dispatcher.test.d.ts} +0 -0
- /package/dist/{src/core → core}/http/securityHeaders.d.ts +0 -0
- /package/dist/{src/core → core}/http/stages/authRoutes.d.ts +0 -0
- /package/dist/{src/core → core}/http/stages/pluginAssets.d.ts +0 -0
- /package/dist/{src/core → core}/mimeTypes.d.ts +0 -0
- /package/dist/{src/modules/mcp/constants.d.ts → core/previewToken.d.ts} +0 -0
- /package/dist/{src/core → core}/requestParser.d.ts +0 -0
- /package/dist/{src/core → core}/server/baseServer.d.ts +0 -0
- /package/dist/{src/modules/mcp/proxy/endpoint.test.d.ts → core/server/baseServer.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/proxy/proxy.test.d.ts → core/services/resolve.test.d.ts} +0 -0
- /package/dist/{src/core → core}/services/rsc.d.ts +0 -0
- /package/dist/{src/core → core}/services/ssr.d.ts +0 -0
- /package/dist/{src/core → core}/staticFiles.d.ts +0 -0
- /package/dist/{src/modules/mcp/proxy/wiring.test.d.ts → helpers/buildResponseHelpers.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/cache/TtlCache.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/cache/cacheManager.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/cache/defaults.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/cache/index.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/apply.test.d.ts → helpers/cache/keys.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/cache/serverCaches.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/bindings.test.d.ts → helpers/compress.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/escapeJson.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/metrics.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/normalizePlugins.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/css.test.d.ts → helpers/offlineDataLoader.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/readCookie.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/interactions.test.d.ts → helpers/resolveDebugMode.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/runMiddlewares.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/serverLog.d.ts +0 -0
- /package/dist/{src/middlewares → middlewares}/auth.d.ts +0 -0
- /package/dist/{src/middlewares → middlewares}/basicAuth.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/pages.test.d.ts → middlewares/spaceDeployment.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/reads.test.d.ts → modules/actions/handler.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/schemaIds.test.d.ts → modules/connectors/engine.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/search.test.d.ts → modules/connectors/projection.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/skill.test.d.ts → modules/connectors/resolver.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/styles.test.d.ts → modules/rsc/resolveRscData.test.d.ts} +0 -0
- /package/dist/{src/modules → modules}/ssr/applySSRResult.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/tools.test.d.ts → modules/ssr/loadPluginComponents.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/validation.test.d.ts → modules/ssr/metering.test.d.ts} +0 -0
- /package/dist/{src/modules → modules}/ssr/registerExternalPlugins.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/compile.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/copy.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/detect.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/manager.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/validate.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/validate.test.d.ts +0 -0
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { emptySpace } from "../helpers/space.js";
|
|
2
|
-
import "../helpers/uris.js";
|
|
3
|
-
import { canonicalUri } from "./canonical.js";
|
|
4
|
-
import { readCoreResource } from "./core.js";
|
|
5
|
-
import { readPrimerResource } from "./primer.js";
|
|
6
|
-
import { readRenderResource } from "./renderGuide.js";
|
|
7
|
-
import { readSchemaResource } from "./schema.js";
|
|
8
|
-
import { readStyleResource } from "./style.js";
|
|
9
|
-
//#region src/modules/mcp/resources/router.ts
|
|
10
|
-
var resolvers = [
|
|
11
|
-
(space, _env, uri) => readCoreResource(space, uri),
|
|
12
|
-
(_space, _env, uri) => readRenderResource(uri),
|
|
13
|
-
readPrimerResource,
|
|
14
|
-
readSchemaResource,
|
|
15
|
-
readStyleResource
|
|
16
|
-
];
|
|
17
|
-
/** Resolve a resource URI to its versioned envelope, or null if unknown / not found. */
|
|
18
|
-
var readResource = (space, env, rawUri) => {
|
|
19
|
-
const uri = canonicalUri(env, rawUri);
|
|
20
|
-
for (const resolve of resolvers) {
|
|
21
|
-
const result = resolve(space, env, uri);
|
|
22
|
-
if (result !== void 0) return result;
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
};
|
|
26
|
-
/** What a connection carrying NO space (a guest / widgets-only grant) can still read: the space-independent
|
|
27
|
-
* singletons and the render docs. Undefined for everything else, so the caller says the connection has no space
|
|
28
|
-
* instead of answering out of an empty one — an empty page list would read as "this space has no pages". */
|
|
29
|
-
var readPublicResource = (env, rawUri) => {
|
|
30
|
-
const uri = canonicalUri(env, rawUri);
|
|
31
|
-
if (uri === "plitzi://types") return;
|
|
32
|
-
return readRenderResource(uri) ?? readCoreResource(emptySpace(), uri);
|
|
33
|
-
};
|
|
34
|
-
/** Current version of a resource, for optimistic-concurrency checks. Null when the URI is unknown. */
|
|
35
|
-
var resourceVersion = (space, env, uri) => readResource(space, env, uri)?.stateVersion ?? null;
|
|
36
|
-
//#endregion
|
|
37
|
-
export { readPublicResource, readResource, resourceVersion };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { buildDataSourceCatalog, buildInteractionCatalog } from "../catalogs/observed.js";
|
|
2
|
-
import { findElementByRef, findPageByRef } from "../helpers/space.js";
|
|
3
|
-
import { afterPrefix, dataSourcesUri, elementUri, folderUri, foldersUri, interactionsUri, pageUri, pagesUri, schemaVarsUri, settingsUri } from "../helpers/uris.js";
|
|
4
|
-
import { envelope } from "./envelope.js";
|
|
5
|
-
import { elementView, folderRefToAI, foldersToAI, pageSkeletonToAI, pageStylesToAI, pageSummariesToAI, schemaVariablesToAI, settingsToAI } from "../tools/operations/schema/translator.js";
|
|
6
|
-
//#region src/modules/mcp/resources/schema.ts
|
|
7
|
-
/** Element-schema reads: page listings/skeletons/styles, folders, single elements and schema variables. Returns
|
|
8
|
-
* undefined when the URI belongs to another domain, null when the shape is ours but the ref does not resolve. */
|
|
9
|
-
var readSchemaResource = (space, env, uri) => {
|
|
10
|
-
if (uri === pagesUri(env)) return envelope(pageSummariesToAI(space.schema));
|
|
11
|
-
if (uri === foldersUri(env)) return envelope(foldersToAI(space.schema));
|
|
12
|
-
const folderRef = afterPrefix(uri, folderUri(env, ""));
|
|
13
|
-
if (folderRef !== void 0) {
|
|
14
|
-
const folder = folderRefToAI(space.schema, folderRef);
|
|
15
|
-
return folder ? envelope(folder) : null;
|
|
16
|
-
}
|
|
17
|
-
const pageItem = afterPrefix(uri, pageUri(env, ""));
|
|
18
|
-
if (pageItem !== void 0) {
|
|
19
|
-
if (pageItem.endsWith("/styles")) {
|
|
20
|
-
const ref = pageItem.slice(0, -7);
|
|
21
|
-
const page = findPageByRef(space.schema, ref);
|
|
22
|
-
return page ? envelope(pageStylesToAI(space.schema, space.style, page)) : null;
|
|
23
|
-
}
|
|
24
|
-
const page = findPageByRef(space.schema, pageItem);
|
|
25
|
-
return page ? envelope(pageSkeletonToAI(space.schema, page, space.style)) : null;
|
|
26
|
-
}
|
|
27
|
-
const elementRef = afterPrefix(uri, elementUri(env, ""));
|
|
28
|
-
if (elementRef !== void 0) {
|
|
29
|
-
const el = findElementByRef(space.schema, elementRef);
|
|
30
|
-
if (!el) return null;
|
|
31
|
-
const view = elementView(space.schema, el, space.style);
|
|
32
|
-
return {
|
|
33
|
-
stateVersion: view.version,
|
|
34
|
-
data: view.detail
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
if (uri === schemaVarsUri(env)) return envelope(schemaVariablesToAI(space.schema));
|
|
38
|
-
if (uri === settingsUri(env)) return envelope(settingsToAI(space.schema));
|
|
39
|
-
if (uri === interactionsUri(env)) return envelope(buildInteractionCatalog(space.schema));
|
|
40
|
-
if (uri === dataSourcesUri(env)) return envelope(buildDataSourceCatalog(space.schema));
|
|
41
|
-
};
|
|
42
|
-
//#endregion
|
|
43
|
-
export { readSchemaResource };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { afterPrefix, defUri, defsUri, globalUri, globalsUri, idUri, idsUri, styleVarUri, styleVarsUri } from "../helpers/uris.js";
|
|
2
|
-
import { envelope } from "./envelope.js";
|
|
3
|
-
import { definitionRefs, definitionToAI, globalStyleToAI, globalStyleTypes, idStyleIds, idStyleToAI, styleVariablesToAI } from "../tools/operations/style/translator.js";
|
|
4
|
-
//#region src/modules/mcp/resources/style.ts
|
|
5
|
-
/** Style-schema reads: definitions, global (per-type) styles and design-token variables by category. Returns
|
|
6
|
-
* undefined when the URI belongs to another domain, null when the shape is ours but the ref does not resolve. */
|
|
7
|
-
var readStyleResource = (space, env, uri) => {
|
|
8
|
-
if (uri === defsUri(env)) return envelope(definitionRefs(space.style));
|
|
9
|
-
const defRef = afterPrefix(uri, defUri(env, ""));
|
|
10
|
-
if (defRef !== void 0) {
|
|
11
|
-
const def = definitionToAI(space.style, defRef);
|
|
12
|
-
return def ? envelope(def) : null;
|
|
13
|
-
}
|
|
14
|
-
if (uri === globalsUri(env)) return envelope(globalStyleTypes(space.style));
|
|
15
|
-
const componentType = afterPrefix(uri, globalUri(env, ""));
|
|
16
|
-
if (componentType !== void 0) {
|
|
17
|
-
const global = globalStyleToAI(space.style, componentType);
|
|
18
|
-
return global ? envelope(global) : null;
|
|
19
|
-
}
|
|
20
|
-
if (uri === idsUri(env)) return envelope(idStyleIds(space.style));
|
|
21
|
-
const targetId = afterPrefix(uri, idUri(env, ""));
|
|
22
|
-
if (targetId !== void 0) {
|
|
23
|
-
const idStyle = idStyleToAI(space.style, targetId);
|
|
24
|
-
return idStyle ? envelope(idStyle) : null;
|
|
25
|
-
}
|
|
26
|
-
if (uri === styleVarsUri(env)) return envelope(styleVariablesToAI(space.style));
|
|
27
|
-
const category = afterPrefix(uri, styleVarUri(env, ""));
|
|
28
|
-
if (category !== void 0) {
|
|
29
|
-
const byCategory = styleVariablesToAI(space.style);
|
|
30
|
-
return envelope(Object.hasOwn(byCategory, category) ? byCategory[category] : []);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
//#endregion
|
|
34
|
-
export { readStyleResource };
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { PREVIEW_TOKEN_PARAM } from "./constants.js";
|
|
2
|
-
//#region src/modules/mcp/screenshotClient.ts
|
|
3
|
-
var composeUrl = (base, pagePath, token) => {
|
|
4
|
-
const url = new URL(pagePath, base);
|
|
5
|
-
if (token) url.searchParams.set(PREVIEW_TOKEN_PARAM, token);
|
|
6
|
-
return url.toString();
|
|
7
|
-
};
|
|
8
|
-
/** Default `ScreenshotClient`: composes the navigable preview URL (renderBaseUrl + pagePath + `?__pt=token`) and
|
|
9
|
-
* POSTs it to the browser service. Any network/HTTP failure surfaces as `ok:false` so the tool can fall back to
|
|
10
|
-
* the HTML preview instead of hard-failing. */
|
|
11
|
-
var createHttpScreenshotClient = ({ serviceUrl, renderBaseUrl, fetchImpl = fetch }) => ({ async capture({ pagePath, token, viewports }) {
|
|
12
|
-
const url = composeUrl(renderBaseUrl, pagePath, token);
|
|
13
|
-
let res;
|
|
14
|
-
try {
|
|
15
|
-
res = await fetchImpl(serviceUrl, {
|
|
16
|
-
method: "POST",
|
|
17
|
-
headers: { "content-type": "application/json" },
|
|
18
|
-
body: JSON.stringify({
|
|
19
|
-
url,
|
|
20
|
-
viewports
|
|
21
|
-
})
|
|
22
|
-
});
|
|
23
|
-
} catch (err) {
|
|
24
|
-
return {
|
|
25
|
-
ok: false,
|
|
26
|
-
error: "SCREENSHOT_UNREACHABLE",
|
|
27
|
-
message: `Browser service unreachable: ${String(err)}`
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
if (!res.ok) return {
|
|
31
|
-
ok: false,
|
|
32
|
-
error: "SCREENSHOT_FAILED",
|
|
33
|
-
message: `Browser service returned ${res.status}.`
|
|
34
|
-
};
|
|
35
|
-
const body = await res.json();
|
|
36
|
-
if (!body.images || body.images.length === 0) return {
|
|
37
|
-
ok: false,
|
|
38
|
-
error: "SCREENSHOT_EMPTY",
|
|
39
|
-
message: "Browser service returned no images."
|
|
40
|
-
};
|
|
41
|
-
return {
|
|
42
|
-
ok: true,
|
|
43
|
-
images: body.images
|
|
44
|
-
};
|
|
45
|
-
} });
|
|
46
|
-
//#endregion
|
|
47
|
-
export { createHttpScreenshotClient };
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { registerApps } from "./apps/index.js";
|
|
2
|
-
import { NoSpaceError, emptySpace, emptySpaceMessage, noSpaceError } from "./helpers/space.js";
|
|
3
|
-
import { serverInstructions, widgetsOnlyInstructions } from "./helpers/guide.js";
|
|
4
|
-
import { createMcpLog } from "./helpers/log.js";
|
|
5
|
-
import { proxyForTool } from "./proxy/config.js";
|
|
6
|
-
import { registerResources } from "./resources/register.js";
|
|
7
|
-
import { tools } from "./tools/index.js";
|
|
8
|
-
import { isCallToolResult } from "../ai/toolkit.js";
|
|
9
|
-
import { registerAppTool } from "@modelcontextprotocol/ext-apps/server";
|
|
10
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
11
|
-
//#region src/modules/mcp/server.ts
|
|
12
|
-
var MCP_ENV = "main";
|
|
13
|
-
var asText = (data) => ({ content: [{
|
|
14
|
-
type: "text",
|
|
15
|
-
text: JSON.stringify(data)
|
|
16
|
-
}] });
|
|
17
|
-
var createMcpServer = async ({ adapters, getSpaceId, preview, screenshot, logger, renderStreaming = true, proxy }) => {
|
|
18
|
-
const log = createMcpLog(logger);
|
|
19
|
-
const spaceId = await getSpaceId().catch(() => void 0);
|
|
20
|
-
const hasSpace = spaceId !== void 0;
|
|
21
|
-
const requireSpaceId = () => {
|
|
22
|
-
if (spaceId === void 0) throw new NoSpaceError();
|
|
23
|
-
return spaceId;
|
|
24
|
-
};
|
|
25
|
-
const loadSpace = async () => {
|
|
26
|
-
const id = requireSpaceId();
|
|
27
|
-
const [schema, style, catalog] = await Promise.all([
|
|
28
|
-
adapters.getSchema?.(id, MCP_ENV),
|
|
29
|
-
adapters.getStyle?.(id, MCP_ENV),
|
|
30
|
-
adapters.getComponentCatalog?.(id, MCP_ENV).catch(() => void 0)
|
|
31
|
-
]);
|
|
32
|
-
if (!schema || !style) throw new Error(emptySpaceMessage);
|
|
33
|
-
return {
|
|
34
|
-
schema,
|
|
35
|
-
style,
|
|
36
|
-
catalog
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
const { saveSchema, saveStyle } = adapters;
|
|
40
|
-
const persisters = {
|
|
41
|
-
schema: saveSchema ? (schema) => saveSchema(requireSpaceId(), MCP_ENV, schema) : void 0,
|
|
42
|
-
style: saveStyle ? (style) => saveStyle(requireSpaceId(), MCP_ENV, style) : void 0
|
|
43
|
-
};
|
|
44
|
-
let spacePromise;
|
|
45
|
-
const getSpace = () => spacePromise ??= loadSpace();
|
|
46
|
-
const server = new McpServer({
|
|
47
|
-
name: "plitzi-mcp",
|
|
48
|
-
version: "0.32.25"
|
|
49
|
-
}, { instructions: hasSpace ? serverInstructions : widgetsOnlyInstructions });
|
|
50
|
-
registerResources(server, getSpace, MCP_ENV, log, hasSpace);
|
|
51
|
-
registerApps(server, {
|
|
52
|
-
streaming: renderStreaming,
|
|
53
|
-
proxyEndpoint: proxy?.endpoint
|
|
54
|
-
});
|
|
55
|
-
const toolContext = async (tool) => ({
|
|
56
|
-
space: await getSpace(),
|
|
57
|
-
env: MCP_ENV,
|
|
58
|
-
persisters,
|
|
59
|
-
spaceId: requireSpaceId(),
|
|
60
|
-
preview,
|
|
61
|
-
screenshot,
|
|
62
|
-
proxy: proxyForTool(proxy, tool)
|
|
63
|
-
});
|
|
64
|
-
const spacelessContext = (tool) => ({
|
|
65
|
-
space: emptySpace(),
|
|
66
|
-
env: MCP_ENV,
|
|
67
|
-
persisters,
|
|
68
|
-
preview,
|
|
69
|
-
screenshot,
|
|
70
|
-
proxy: proxyForTool(proxy, tool)
|
|
71
|
-
});
|
|
72
|
-
const behaviorOf = (tool) => {
|
|
73
|
-
if (tool.spaceless) return (args) => tool.execute(args, spacelessContext(tool.name));
|
|
74
|
-
if (hasSpace) return async (args) => tool.execute(args, await toolContext(tool.name));
|
|
75
|
-
return tool.executePublic ? (args) => tool.executePublic?.(args, MCP_ENV) : void 0;
|
|
76
|
-
};
|
|
77
|
-
for (const tool of tools) {
|
|
78
|
-
if (tool.requires === "screenshot" && !screenshot) continue;
|
|
79
|
-
const behavior = behaviorOf(tool);
|
|
80
|
-
if (!behavior) continue;
|
|
81
|
-
const run = async (args) => {
|
|
82
|
-
const start = performance.now();
|
|
83
|
-
try {
|
|
84
|
-
const result = await behavior(args);
|
|
85
|
-
log.toolCall(tool.name, args, performance.now() - start);
|
|
86
|
-
return isCallToolResult(result) ? result : asText(result);
|
|
87
|
-
} catch (error) {
|
|
88
|
-
log.toolCall(tool.name, args, performance.now() - start, error);
|
|
89
|
-
if (error instanceof NoSpaceError) return asText({
|
|
90
|
-
error: noSpaceError,
|
|
91
|
-
message: error.message
|
|
92
|
-
});
|
|
93
|
-
throw error;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
const config = {
|
|
97
|
-
title: tool.title,
|
|
98
|
-
description: tool.description,
|
|
99
|
-
inputSchema: tool.inputShape
|
|
100
|
-
};
|
|
101
|
-
if (tool.ui) {
|
|
102
|
-
registerAppTool(server, tool.name, {
|
|
103
|
-
...config,
|
|
104
|
-
_meta: { ui: tool.ui }
|
|
105
|
-
}, run);
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
server.registerTool(tool.name, config, run);
|
|
109
|
-
}
|
|
110
|
-
return server;
|
|
111
|
-
};
|
|
112
|
-
//#endregion
|
|
113
|
-
export { createMcpServer };
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { fail } from "../../helpers/opResult.js";
|
|
2
|
-
import { deleteBinding } from "../operations/schema/bindings/deleteBinding.js";
|
|
3
|
-
import { patchBinding } from "../operations/schema/bindings/patchBinding.js";
|
|
4
|
-
import { upsertBinding } from "../operations/schema/bindings/upsertBinding.js";
|
|
5
|
-
import { deleteElement } from "../operations/schema/elements/deleteElement.js";
|
|
6
|
-
import { moveElement } from "../operations/schema/elements/moveElement.js";
|
|
7
|
-
import { patchElement } from "../operations/schema/elements/patchElement.js";
|
|
8
|
-
import { upsertElement } from "../operations/schema/elements/upsertElement.js";
|
|
9
|
-
import { deleteFolder } from "../operations/schema/folders/deleteFolder.js";
|
|
10
|
-
import { upsertFolder } from "../operations/schema/folders/upsertFolder.js";
|
|
11
|
-
import { deleteInteraction } from "../operations/schema/interactions/deleteInteraction.js";
|
|
12
|
-
import { patchInteractionNode } from "../operations/schema/interactions/patchInteractionNode.js";
|
|
13
|
-
import { upsertInteractionFlow } from "../operations/schema/interactions/upsertInteractionFlow.js";
|
|
14
|
-
import { deletePage } from "../operations/schema/pages/deletePage.js";
|
|
15
|
-
import { upsertPage } from "../operations/schema/pages/upsertPage.js";
|
|
16
|
-
import { patchSettings } from "../operations/schema/settings/patchSettings.js";
|
|
17
|
-
import { deleteVariable } from "../operations/schema/variables/deleteVariable.js";
|
|
18
|
-
import { upsertVariable } from "../operations/schema/variables/upsertVariable.js";
|
|
19
|
-
import { deleteDefinition } from "../operations/style/definitions/deleteDefinition.js";
|
|
20
|
-
import { patchDefinition } from "../operations/style/definitions/patchDefinition.js";
|
|
21
|
-
import { upsertDefinition } from "../operations/style/definitions/upsertDefinition.js";
|
|
22
|
-
import { upsertDefinitions } from "../operations/style/definitions/upsertDefinitions.js";
|
|
23
|
-
import { deleteGlobalStyle } from "../operations/style/globalStyles/deleteGlobalStyle.js";
|
|
24
|
-
import { patchGlobalStyle } from "../operations/style/globalStyles/patchGlobalStyle.js";
|
|
25
|
-
import { upsertGlobalStyle } from "../operations/style/globalStyles/upsertGlobalStyle.js";
|
|
26
|
-
import { deleteIdStyle } from "../operations/style/idStyles/deleteIdStyle.js";
|
|
27
|
-
import { patchIdStyle } from "../operations/style/idStyles/patchIdStyle.js";
|
|
28
|
-
import { upsertIdStyle } from "../operations/style/idStyles/upsertIdStyle.js";
|
|
29
|
-
import { deleteStyleVariable } from "../operations/style/variables/deleteStyleVariable.js";
|
|
30
|
-
import { upsertStyleVariable } from "../operations/style/variables/upsertStyleVariable.js";
|
|
31
|
-
import { isStyleOp } from "../operations/index.js";
|
|
32
|
-
//#region src/modules/mcp/tools/apply/dispatch.ts
|
|
33
|
-
var executeOp = (space, env, op) => {
|
|
34
|
-
switch (op.type) {
|
|
35
|
-
case "upsertElement": return upsertElement(space, env, op);
|
|
36
|
-
case "patchElement": return patchElement(space, env, op);
|
|
37
|
-
case "deleteElement": return deleteElement(space, env, op);
|
|
38
|
-
case "moveElement": return moveElement(space, env, op);
|
|
39
|
-
case "upsertPage": return upsertPage(space, env, op);
|
|
40
|
-
case "deletePage": return deletePage(space, env, op);
|
|
41
|
-
case "upsertFolder": return upsertFolder(space, env, op);
|
|
42
|
-
case "deleteFolder": return deleteFolder(space, env, op);
|
|
43
|
-
case "upsertVariable": return upsertVariable(space, env, op);
|
|
44
|
-
case "deleteVariable": return deleteVariable(space, env, op);
|
|
45
|
-
case "upsertBinding": return upsertBinding(space, env, op);
|
|
46
|
-
case "patchBinding": return patchBinding(space, env, op);
|
|
47
|
-
case "deleteBinding": return deleteBinding(space, env, op);
|
|
48
|
-
case "upsertInteractionFlow": return upsertInteractionFlow(space, env, op);
|
|
49
|
-
case "patchInteractionNode": return patchInteractionNode(space, env, op);
|
|
50
|
-
case "deleteInteraction": return deleteInteraction(space, env, op);
|
|
51
|
-
case "patchSettings": return patchSettings(space, env, op);
|
|
52
|
-
case "upsertDefinition": return upsertDefinition(space, env, op);
|
|
53
|
-
case "upsertDefinitions": return upsertDefinitions(space, env, op);
|
|
54
|
-
case "patchDefinition": return patchDefinition(space, env, op);
|
|
55
|
-
case "deleteDefinition": return deleteDefinition(space, env, op);
|
|
56
|
-
case "upsertGlobalStyle": return upsertGlobalStyle(space, env, op);
|
|
57
|
-
case "patchGlobalStyle": return patchGlobalStyle(space, env, op);
|
|
58
|
-
case "deleteGlobalStyle": return deleteGlobalStyle(space, env, op);
|
|
59
|
-
case "upsertIdStyle": return upsertIdStyle(space, env, op);
|
|
60
|
-
case "patchIdStyle": return patchIdStyle(space, env, op);
|
|
61
|
-
case "deleteIdStyle": return deleteIdStyle(space, env, op);
|
|
62
|
-
case "upsertStyleVariable": return upsertStyleVariable(space, env, op);
|
|
63
|
-
case "deleteStyleVariable": return deleteStyleVariable(space, env, op);
|
|
64
|
-
default: return fail("type", `Unknown operation "${op.type}"`, "See the Operation union");
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
/** Apply operations in order to the space (mutating it). Records which schema(s) changed so the caller can
|
|
68
|
-
* persist each independently. Stops collecting counts for a failed op but records its errors. */
|
|
69
|
-
var applyOperations = (space, env, ops) => {
|
|
70
|
-
const outcome = {
|
|
71
|
-
created: 0,
|
|
72
|
-
updated: 0,
|
|
73
|
-
deleted: 0,
|
|
74
|
-
staleResources: [],
|
|
75
|
-
elementRefs: [],
|
|
76
|
-
errors: [],
|
|
77
|
-
changedSchema: false,
|
|
78
|
-
changedStyle: false
|
|
79
|
-
};
|
|
80
|
-
const stale = /* @__PURE__ */ new Set();
|
|
81
|
-
const elements = /* @__PURE__ */ new Set();
|
|
82
|
-
for (let i = 0; i < ops.length; i++) {
|
|
83
|
-
const op = ops[i];
|
|
84
|
-
const result = executeOp(space, env, op);
|
|
85
|
-
if (result.errors) {
|
|
86
|
-
outcome.errors.push(...result.errors.map((e) => ({
|
|
87
|
-
...e,
|
|
88
|
-
path: `operations[${i}].${e.path}`
|
|
89
|
-
})));
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (isStyleOp(op.type)) outcome.changedStyle = true;
|
|
93
|
-
else outcome.changedSchema = true;
|
|
94
|
-
outcome.created += result.created;
|
|
95
|
-
outcome.updated += result.updated;
|
|
96
|
-
outcome.deleted += result.deleted;
|
|
97
|
-
for (const uri of result.staleResources) stale.add(uri);
|
|
98
|
-
for (const ref of result.elementRefs ?? []) elements.add(ref);
|
|
99
|
-
}
|
|
100
|
-
outcome.staleResources = Array.from(stale);
|
|
101
|
-
outcome.elementRefs = Array.from(elements);
|
|
102
|
-
return outcome;
|
|
103
|
-
};
|
|
104
|
-
//#endregion
|
|
105
|
-
export { applyOperations };
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { cloneSpace } from "../../helpers/space.js";
|
|
2
|
-
import { environment, operations } from "../operations/index.js";
|
|
3
|
-
import { applyOperations } from "./dispatch.js";
|
|
4
|
-
import { changedResources, conflictMessage, detectConflicts, resolvedElements } from "./writeResult.js";
|
|
5
|
-
import { expandOperations } from "../shared/expandOperations.js";
|
|
6
|
-
import { defineTool } from "../shared/tool.js";
|
|
7
|
-
import { validateOperations } from "../shared/validator/index.js";
|
|
8
|
-
import { auditResources } from "../shared/validator/audit.js";
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
import { validateSchema } from "@plitzi/sdk-schema/helpers/schemaValidator";
|
|
11
|
-
//#region src/modules/mcp/tools/apply/index.ts
|
|
12
|
-
var applyShape = {
|
|
13
|
-
environment,
|
|
14
|
-
dryRun: z.boolean().optional().describe("Validate and apply in memory only, WITHOUT persisting. Returns the same result (changed versions + full element detail) so you can inspect the outcome and decide on more changes before committing for real."),
|
|
15
|
-
expectedResourceVersions: z.record(z.string(), z.string()).optional().describe("Resource URI → the stateVersion you read; guards against concurrent edits"),
|
|
16
|
-
operations
|
|
17
|
-
};
|
|
18
|
-
var noWarnings = (warnings) => warnings.length > 0 ? warnings : void 0;
|
|
19
|
-
var schemaErrorToValidation = (error) => ({
|
|
20
|
-
path: error.elementId ? `schema.${error.elementId}` : "schema",
|
|
21
|
-
message: error.message,
|
|
22
|
-
hint: "This batch would leave the schema inconsistent (broken parent/child link or a cycle); nothing was applied."
|
|
23
|
-
});
|
|
24
|
-
var apply = async (input, space, persisters) => {
|
|
25
|
-
const env = input.environment ?? "main";
|
|
26
|
-
const expansion = expandOperations(input.operations);
|
|
27
|
-
if (expansion.errors.length > 0) return {
|
|
28
|
-
applied: false,
|
|
29
|
-
persisted: false,
|
|
30
|
-
summary: {
|
|
31
|
-
created: 0,
|
|
32
|
-
updated: 0,
|
|
33
|
-
deleted: 0
|
|
34
|
-
},
|
|
35
|
-
changed: [],
|
|
36
|
-
errors: expansion.errors
|
|
37
|
-
};
|
|
38
|
-
const ops = expansion.operations;
|
|
39
|
-
const validation = validateOperations(space, ops);
|
|
40
|
-
if (!validation.valid) return {
|
|
41
|
-
applied: false,
|
|
42
|
-
persisted: false,
|
|
43
|
-
summary: {
|
|
44
|
-
created: 0,
|
|
45
|
-
updated: 0,
|
|
46
|
-
deleted: 0
|
|
47
|
-
},
|
|
48
|
-
changed: [],
|
|
49
|
-
errors: validation.errors,
|
|
50
|
-
warnings: noWarnings(validation.warnings)
|
|
51
|
-
};
|
|
52
|
-
const conflicts = detectConflicts(space, env, input.expectedResourceVersions);
|
|
53
|
-
if (conflicts.length > 0) return {
|
|
54
|
-
applied: false,
|
|
55
|
-
persisted: false,
|
|
56
|
-
summary: {
|
|
57
|
-
created: 0,
|
|
58
|
-
updated: 0,
|
|
59
|
-
deleted: 0
|
|
60
|
-
},
|
|
61
|
-
changed: [],
|
|
62
|
-
conflict: {
|
|
63
|
-
message: conflictMessage,
|
|
64
|
-
conflicts
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
const draft = cloneSpace(space);
|
|
68
|
-
const outcome = applyOperations(draft, env, ops);
|
|
69
|
-
if (outcome.errors.length > 0) return {
|
|
70
|
-
applied: false,
|
|
71
|
-
persisted: false,
|
|
72
|
-
summary: {
|
|
73
|
-
created: 0,
|
|
74
|
-
updated: 0,
|
|
75
|
-
deleted: 0
|
|
76
|
-
},
|
|
77
|
-
changed: [],
|
|
78
|
-
errors: outcome.errors,
|
|
79
|
-
warnings: noWarnings(validation.warnings)
|
|
80
|
-
};
|
|
81
|
-
const integrity = validateSchema(draft.schema);
|
|
82
|
-
if (!integrity.valid) return {
|
|
83
|
-
applied: false,
|
|
84
|
-
persisted: false,
|
|
85
|
-
summary: {
|
|
86
|
-
created: 0,
|
|
87
|
-
updated: 0,
|
|
88
|
-
deleted: 0
|
|
89
|
-
},
|
|
90
|
-
changed: [],
|
|
91
|
-
errors: integrity.errors.map(schemaErrorToValidation),
|
|
92
|
-
warnings: noWarnings(validation.warnings)
|
|
93
|
-
};
|
|
94
|
-
const audit = auditResources(draft, ops);
|
|
95
|
-
const warnings = [...validation.warnings, ...audit.warnings];
|
|
96
|
-
if (audit.errors.length > 0) return {
|
|
97
|
-
applied: false,
|
|
98
|
-
persisted: false,
|
|
99
|
-
summary: {
|
|
100
|
-
created: 0,
|
|
101
|
-
updated: 0,
|
|
102
|
-
deleted: 0
|
|
103
|
-
},
|
|
104
|
-
changed: [],
|
|
105
|
-
errors: audit.errors,
|
|
106
|
-
warnings: noWarnings(warnings)
|
|
107
|
-
};
|
|
108
|
-
if (input.dryRun) return {
|
|
109
|
-
applied: false,
|
|
110
|
-
dryRun: true,
|
|
111
|
-
summary: {
|
|
112
|
-
created: outcome.created,
|
|
113
|
-
updated: outcome.updated,
|
|
114
|
-
deleted: outcome.deleted
|
|
115
|
-
},
|
|
116
|
-
changed: changedResources(draft, env, outcome.staleResources),
|
|
117
|
-
elements: resolvedElements(draft, env, outcome.elementRefs),
|
|
118
|
-
warnings: noWarnings(warnings)
|
|
119
|
-
};
|
|
120
|
-
let persisted = true;
|
|
121
|
-
if (outcome.changedSchema) if (persisters?.schema) await persisters.schema(draft.schema);
|
|
122
|
-
else persisted = false;
|
|
123
|
-
if (outcome.changedStyle) if (persisters?.style) await persisters.style(draft.style);
|
|
124
|
-
else persisted = false;
|
|
125
|
-
return {
|
|
126
|
-
applied: true,
|
|
127
|
-
persisted,
|
|
128
|
-
summary: {
|
|
129
|
-
created: outcome.created,
|
|
130
|
-
updated: outcome.updated,
|
|
131
|
-
deleted: outcome.deleted
|
|
132
|
-
},
|
|
133
|
-
changed: changedResources(draft, env, outcome.staleResources),
|
|
134
|
-
elements: resolvedElements(draft, env, outcome.elementRefs),
|
|
135
|
-
warnings: noWarnings(warnings)
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
var applyTool = defineTool({
|
|
139
|
-
name: "plitzi_apply",
|
|
140
|
-
title: "Apply",
|
|
141
|
-
description: "Validate, apply and persist a batch of operations atomically. Returns the changed resources and their new versions, plus the full detail of every element it created or updated. Pass dryRun to apply in memory only (inspect the outcome without committing). Rejects the whole batch on any error or version conflict — INCLUDING a pre-existing malformation in any resource the batch touches (fix it in the same batch to unblock the save).",
|
|
142
|
-
inputShape: applyShape,
|
|
143
|
-
access: "write",
|
|
144
|
-
run: (input, ctx) => apply({
|
|
145
|
-
...input,
|
|
146
|
-
environment: ctx.env
|
|
147
|
-
}, ctx.space, ctx.persisters)
|
|
148
|
-
});
|
|
149
|
-
//#endregion
|
|
150
|
-
export { apply, applyShape, applyTool };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { elementUri } from "../../helpers/uris.js";
|
|
2
|
-
import { readResource, resourceVersion } from "../../resources/router.js";
|
|
3
|
-
//#region src/modules/mcp/tools/apply/writeResult.ts
|
|
4
|
-
var detectConflicts = (space, env, expected) => {
|
|
5
|
-
if (!expected) return [];
|
|
6
|
-
const conflicts = [];
|
|
7
|
-
for (const [uri, version] of Object.entries(expected)) {
|
|
8
|
-
const current = resourceVersion(space, env, uri);
|
|
9
|
-
if (current !== null && current !== version) conflicts.push({
|
|
10
|
-
resourceUri: uri,
|
|
11
|
-
expectedVersion: version,
|
|
12
|
-
currentVersion: current
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
return conflicts;
|
|
16
|
-
};
|
|
17
|
-
var changedResources = (space, env, uris) => uris.map((uri) => ({
|
|
18
|
-
uri,
|
|
19
|
-
stateVersion: resourceVersion(space, env, uri) ?? ""
|
|
20
|
-
}));
|
|
21
|
-
/** Full detail of each created/updated element (by ref), skipping any that no longer resolve (e.g. deleted later
|
|
22
|
-
* in the same batch). Returns undefined when there is nothing, so the field stays off the response. */
|
|
23
|
-
var resolvedElements = (space, env, refs) => {
|
|
24
|
-
const elements = refs.map((ref) => {
|
|
25
|
-
const uri = elementUri(env, ref);
|
|
26
|
-
const res = readResource(space, env, uri);
|
|
27
|
-
return res ? {
|
|
28
|
-
uri,
|
|
29
|
-
stateVersion: res.stateVersion,
|
|
30
|
-
...res.data
|
|
31
|
-
} : void 0;
|
|
32
|
-
}).filter((el) => el !== void 0);
|
|
33
|
-
return elements.length > 0 ? elements : void 0;
|
|
34
|
-
};
|
|
35
|
-
var conflictMessage = "Cannot apply: your data is stale. Re-read the changed resources and retry.";
|
|
36
|
-
//#endregion
|
|
37
|
-
export { changedResources, conflictMessage, detectConflicts, resolvedElements };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { operation } from "./operations/index.js";
|
|
2
|
-
import { applyOperations } from "./apply/dispatch.js";
|
|
3
|
-
import { validateOperations } from "./shared/validator/index.js";
|
|
4
|
-
import { apply, applyShape, applyTool } from "./apply/index.js";
|
|
5
|
-
import { previewTool } from "./preview.js";
|
|
6
|
-
import { read, readShape, readTool } from "./read.js";
|
|
7
|
-
import { renderTool } from "./render.js";
|
|
8
|
-
import { screenshotTool } from "./screenshot.js";
|
|
9
|
-
import { search, searchShape, searchTool } from "./search.js";
|
|
10
|
-
import { validate, validateShape, validateTool } from "./validate.js";
|
|
11
|
-
//#region src/modules/mcp/tools/index.ts
|
|
12
|
-
/** The MCP tool registry — the single source both hosts (the standalone server and the in-process AI bridge)
|
|
13
|
-
* register from. Adding a tool is: create its file with a ToolDef descriptor and append it here. */
|
|
14
|
-
var tools = [
|
|
15
|
-
applyTool,
|
|
16
|
-
validateTool,
|
|
17
|
-
searchTool,
|
|
18
|
-
readTool,
|
|
19
|
-
renderTool,
|
|
20
|
-
previewTool,
|
|
21
|
-
screenshotTool
|
|
22
|
-
];
|
|
23
|
-
//#endregion
|
|
24
|
-
export { apply, applyOperations, applyShape, operation, read, readShape, search, searchShape, tools, validate, validateOperations, validateShape };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { elementOps } from "./schema/operations.js";
|
|
2
|
-
import { registerSharedSchemaIds } from "./schemaIds.js";
|
|
3
|
-
import { styleOps } from "./style/operations.js";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
//#region src/modules/mcp/tools/operations/index.ts
|
|
6
|
-
registerSharedSchemaIds();
|
|
7
|
-
var operation = z.discriminatedUnion("type", [
|
|
8
|
-
elementOps.upsertElement,
|
|
9
|
-
elementOps.repeatElement,
|
|
10
|
-
elementOps.patchElement,
|
|
11
|
-
elementOps.deleteElement,
|
|
12
|
-
elementOps.moveElement,
|
|
13
|
-
elementOps.upsertPage,
|
|
14
|
-
elementOps.deletePage,
|
|
15
|
-
elementOps.upsertFolder,
|
|
16
|
-
elementOps.deleteFolder,
|
|
17
|
-
elementOps.upsertVariable,
|
|
18
|
-
elementOps.deleteVariable,
|
|
19
|
-
elementOps.upsertBinding,
|
|
20
|
-
elementOps.patchBinding,
|
|
21
|
-
elementOps.deleteBinding,
|
|
22
|
-
elementOps.upsertInteractionFlow,
|
|
23
|
-
elementOps.patchInteractionNode,
|
|
24
|
-
elementOps.deleteInteraction,
|
|
25
|
-
elementOps.patchSettings,
|
|
26
|
-
styleOps.upsertDefinition,
|
|
27
|
-
styleOps.upsertDefinitions,
|
|
28
|
-
styleOps.patchDefinition,
|
|
29
|
-
styleOps.deleteDefinition,
|
|
30
|
-
styleOps.upsertGlobalStyle,
|
|
31
|
-
styleOps.patchGlobalStyle,
|
|
32
|
-
styleOps.deleteGlobalStyle,
|
|
33
|
-
styleOps.upsertIdStyle,
|
|
34
|
-
styleOps.patchIdStyle,
|
|
35
|
-
styleOps.deleteIdStyle,
|
|
36
|
-
styleOps.upsertStyleVariable,
|
|
37
|
-
styleOps.deleteStyleVariable
|
|
38
|
-
]);
|
|
39
|
-
var STYLE_OP_TYPES = new Set(Object.keys(styleOps));
|
|
40
|
-
var isStyleOp = (type) => STYLE_OP_TYPES.has(type);
|
|
41
|
-
var MAX_OPS = 1e3;
|
|
42
|
-
var environment = z.string().optional().describe("Environment; default main");
|
|
43
|
-
var operations = z.array(operation).max(MAX_OPS).describe(`Operations applied atomically, in order (max ${MAX_OPS})`);
|
|
44
|
-
//#endregion
|
|
45
|
-
export { MAX_OPS, environment, isStyleOp, operation, operations };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { pageUri } from "../../../../helpers/uris.js";
|
|
2
|
-
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
3
|
-
import { bindingCategory } from "../shared.js";
|
|
4
|
-
import { resolveElement } from "../write.js";
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
//#region src/modules/mcp/tools/operations/schema/bindings/deleteBinding.ts
|
|
7
|
-
var deleteBindingOp = z.object({
|
|
8
|
-
type: z.literal("deleteBinding"),
|
|
9
|
-
pageRef: z.string().describe("Page ref or id"),
|
|
10
|
-
ref: z.string().describe("Element ref or id"),
|
|
11
|
-
category: bindingCategory,
|
|
12
|
-
to: z.string().describe("Target of the binding to remove"),
|
|
13
|
-
id: z.string().optional().describe("Match by id instead of to")
|
|
14
|
-
}).describe("Remove a data binding from an element (matched by id when given, else by to). Fails if none matches.");
|
|
15
|
-
var deleteBinding = (space, env, op) => {
|
|
16
|
-
const found = resolveElement(space, env, op.pageRef, op.ref);
|
|
17
|
-
if ("error" in found) return found.error;
|
|
18
|
-
const bindings = found.el.definition.bindings;
|
|
19
|
-
const list = bindings?.[op.category];
|
|
20
|
-
const index = list ? list.findIndex((b) => op.id ? b.id === op.id : b.to === op.to) : -1;
|
|
21
|
-
if (!bindings || !list || index < 0) return fail("to", `No ${op.category} binding matching "${op.id ?? op.to}" on "${op.ref}"`, "Nothing to delete");
|
|
22
|
-
list.splice(index, 1);
|
|
23
|
-
if (list.length === 0) Reflect.deleteProperty(bindings, op.category);
|
|
24
|
-
return {
|
|
25
|
-
...empty(),
|
|
26
|
-
deleted: 1,
|
|
27
|
-
staleResources: [pageUri(env, op.pageRef)],
|
|
28
|
-
elementRefs: [op.ref]
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
//#endregion
|
|
32
|
-
export { deleteBinding, deleteBindingOp };
|